HarmonyOS Web组件如何实现视频全屏播放

Web中的视频要实现全屏播放,具体怎么让视频全屏,我看onFullScreenEnter回调没有播放视频的view,只有一个handler。

HarmonyOS
2024-09-04 11:58:33
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
Heiang

参考示例如下:

import { webview } from '@kit.ArkWeb'; 
 
@Entry 
@Component 
struct ShortWebPage { 
  controller: webview.WebviewController = new webview.WebviewController() 
  CONSTANT_HEIGHT = 100; 
  @State marginTop: number = this.CONSTANT_HEIGHT; 
  @State isVisible:boolean= true; 
 
  build() { 
    Column() { 
      Text('Stack').width('100%').height(this.CONSTANT_HEIGHT).backgroundColor('#e1dede').visibility(this.isVisible?Visibility.Visible:Visibility.None) 
      Web({ 
        src: "www.huawei.com", 
        controller: this.controller 
      }) 
        .onFullScreenEnter((event) => { 
          console.log("onFullScreenEnter...") 
          this.isVisible = false; 
        }) 
        .onFullScreenExit(() => { 
          console.log("onFullScreenExit...") 
          this.isVisible = true; 
        }) 
        .width('100%') 
        .height("100%") 
        .zIndex(10) 
        .zoomAccess(true) 
    }.width('100%').height('100%') 
  } 
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
分享
微博
QQ
微信
回复
2024-09-04 18:18:06
相关问题
HarmonyOS 列表视频全屏播放实现
1212浏览 • 1回复 待解决
HarmonyOS Web全屏播放适配
1026浏览 • 1回复 待解决
求告知如何全屏播放一个视频
1274浏览 • 1回复 待解决