HarmonyOS 鸿蒙Next Video组件播放视频时先黑屏再播放,如何解决?
HarmonyOS 鸿蒙Next Video组件播放视频时先黑屏再播放,如何解决?
关于HarmonyOS 鸿蒙Next Video组件播放视频时先黑屏再播放,如何解决?的问题,您也可以访问:https://www.itying.com/category-93-b0.html 联系官网客服。
方案二:给Video设置显隐控制,在Video进入start状态时,在start回调里,控制Video展示,示例代码如下:
[@Entry](/user/Entry)
[@Component](/user/Component)
struct HeiSebeijing {
build() {
Row() {
Column() {
Text('before')
VideoComponent({url:'https://img.xxx.cn/xxx/images/xxx.mp4'})
Text('after')
}
.width('100%')
}
.height('100%')
}
}
[@Component](/user/Component)
struct VideoComponent {
[@State](/user/State) isVisibile:Visibility=Visibility.Hidden
controller: VideoController = new VideoController();
private url:string=''
build() {
Row() {
Video({
src: this.url,
controller: this.controller
})
.visibility(this.isVisibile)
.autoPlay(true)
.loop(true)
.controls(false)
.width('100%')
.height('200vp')
.onStart(() => {
this.isVisibile=Visibility.Visible
})
.onPrepared(()=>{
this.controller.setCurrentTime(0,SeekMode.NextKeyframe)
})
}
}
}
感谢感谢,解决了。