HarmonyOS 鸿蒙Next:Video 在全屏播放模式视频没有显示全
HarmonyOS 鸿蒙Next:Video 在全屏播放模式视频没有显示全 使用官方的demo,参考链接:视频播放 (Video)-添加常用组件-添加组件-UI开发 (ArkTS声明式开发范式)-ArkUI(方舟UI框架)-应用框架 - 华为HarmonyOS开发者 (huawei.com),点击全屏,视频没有全屏显示
更多关于HarmonyOS 鸿蒙Next:Video 在全屏播放模式视频没有显示全的实战教程也可以访问 https://www.itying.com/category-93-b0.html
参考这个demo:
import { window } from '@kit.ArkUI'
import { BusinessError } from '@kit.BasicServicesKit'
@Entry
@Component
struct VideoGuide {
@State videoSrc: Resource = $rawfile('videoTest.mp4')
@State previewUri: string = 'common/videoIcon.png'
@State curRate: PlaybackSpeed = PlaybackSpeed.Speed_Forward_1_00_X
@State flag: boolean = true
build() {
Row() {
Column() {
Video({
src: this.videoSrc,
previewUri: this.previewUri,
currentProgressRate: this.curRate
})
.objectFit(ImageFit.Contain)
.onFullscreenChange((e) => {
if (this.flag) {
let windowClass: window.Window | undefined = undefined;
try {
window.getLastWindow(getContext(), (err: BusinessError, data) => {
const errCode: number = err.code;
if (errCode) {
console.error(`Failed to obtain the top window. Cause code: ${err.code}, message: ${err.message}`);
return;
}
windowClass = data;
let orientation = window.Orientation.LANDSCAPE;
try {
windowClass.setPreferredOrientation(orientation, (err: BusinessError) => {
const errCode: number = err.code;
if (errCode) {
console.error(`Failed to set window orientation. Cause code: ${err.code}, message: ${err.message}`);
return;
}
this.flag = false
console.info('Succeeded in setting window orientation.');
});
} catch (exception) {
console.error(`Failed to set window orientation. Cause code: ${exception.code}, message: ${exception.message}`);
}
console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
});
} catch (exception) {
console.error(`Failed to obtain the top window. Cause code: ${exception.code}, message: ${exception.message}`);
}
} else{
let windowClass: window.Window | undefined = undefined;
try {
window.getLastWindow(getContext(), (err: BusinessError, data) => {
const errCode: number = err.code;
if (errCode) {
console.error(`Failed to obtain the top window. Cause code: ${err.code}, message: ${err.message}`);
return;
}
windowClass = data;
let orientation = window.Orientation.PORTRAIT;
try {
windowClass.setPreferredOrientation(orientation, (err: BusinessError) => {
const errCode: number = err.code;
if (errCode) {
console.error(`Failed to set window orientation. Cause code: ${err.code}, message: ${err.message}`);
return;
}
this.flag = true
console.info('Succeeded in setting window orientation.');
});
} catch (exception) {
console.error(`Failed to set window orientation. Cause code: ${exception.code}, message: ${exception.message}`);
}
console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
});
} catch (exception) {
console.error(`Failed to obtain the top window. Cause code: ${exception.code}, message: ${exception.message}`);
}
}
})
}
.width('100%')
}
.height('100%')
}
}
更多关于HarmonyOS 鸿蒙Next:Video 在全屏播放模式视频没有显示全的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
针对帖子标题“HarmonyOS 鸿蒙Next:Video 在全屏播放模式视频没有显示全”的问题,以下是专业且简洁的回答:
在HarmonyOS鸿蒙Next系统中,若全屏播放视频时未能完整显示,可能是由于视频播放器或系统UI的适配问题导致。首先,请确认视频文件的分辨率与屏幕分辨率是否匹配。若视频分辨率低于屏幕分辨率,可能导致黑边或视频内容未能完整填充屏幕。
此外,检查视频播放器的全屏适配设置。部分播放器在全屏模式下可能未正确调整画面比例,导致视频内容被裁剪或未能完整显示。可以尝试更新播放器至最新版本,或尝试使用其他视频播放器查看问题是否依旧存在。
同时,系统UI的显示设置也可能影响视频全屏播放效果。请检查系统设置中的显示与亮度、屏幕缩放等选项,确保未对视频显示造成干扰。
若上述方法均未能解决问题,可能是系统层面的bug或特定应用兼容性问题。建议备份数据后尝试重启设备,或等待系统更新修复该问题。
如果问题依旧没法解决请联系官网客服,官网地址是:https://www.itying.com/category-93-b0.html