HarmonyOS 无法全屏问题

底部的白条隐藏,视频全屏是留白.播放视频需要全屏都是下边有白条,应该是底部的白条,全屏时白条挡住了视频,这个应该怎么处理,彻底全屏头部状态栏可以隐藏了,但是底部的白条没法处理

HarmonyOS
2天前
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
shlp

demo如下:

import { window } from '@kit.ArkUI'
@Entry
@Component
struct VideoPage {
 @State videoSrc: Resource = $rawfile('video1.mp4')
 @State curRate: PlaybackSpeed = PlaybackSpeed.Speed_Forward_1_00_X
 @State isAutoPlay: boolean = false
 @State showControls: boolean = false
 @State isPlay: boolean = false
 @State videoHeight: string = '300vp'
 controller: VideoController = new VideoController()
 @State windowClass:window.Window|undefined = undefined
 aboutToAppear(): void {
  window.getLastWindow(getContext(this)).then((window)=>{ this.windowClass = window })
 }
 build() {
  Stack() {
   Video({ src: this.videoSrc,  currentProgressRate: this.curRate, controller: this.controller })
    .onClick(()=>{
     if(this.isPlay){
      this.controller.pause()
     }else{
      this.controller.start()
     }
     this.isPlay = !this.isPlay
    })
    .width('100%')
    .height(this.videoHeight)
    .autoPlay(this.isAutoPlay)
    .controls(this.showControls)
   Row() {
    Button('fullscreen').onClick(async () => {
     if(!this.windowClass){ return; }
     if(this.videoHeight === '100%'){
      // 非全屏模式
      this.windowClass.setWindowLayoutFullScreen(false).then(()=>{
       this.videoHeight = '300vp'
      })
      this.windowClass.setPreferredOrientation(window.Orientation.PORTRAIT)
      this.windowClass.setWindowSystemBarEnable(['status'])
     }else{
      // 全屏模式
      this.windowClass.setWindowLayoutFullScreen(true).then(()=>{
       this.videoHeight = '100%'
      })
      this.windowClass.setPreferredOrientation(window.Orientation.LANDSCAPE)
      this.windowClass.setWindowSystemBarEnable([])
     }
    }).margin(5)
   }
  }.alignContent(Alignment.Bottom)
 }
}import { window } from '@kit.ArkUI'
@Entry
@Component
struct VideoPage {
 @State videoSrc: Resource = $rawfile('video1.mp4')
 @State curRate: PlaybackSpeed = PlaybackSpeed.Speed_Forward_1_00_X
 @State isAutoPlay: boolean = false
 @State showControls: boolean = false
 @State isPlay: boolean = false
 @State videoHeight: string = '300vp'
 controller: VideoController = new VideoController()
 @State windowClass:window.Window|undefined = undefined
 aboutToAppear(): void {
  window.getLastWindow(getContext(this)).then((window)=>{ this.windowClass = window })
 }
 build() {
  Stack() {
   Video({ src: this.videoSrc,  currentProgressRate: this.curRate, controller: this.controller })
    .onClick(()=>{
     if(this.isPlay){
      this.controller.pause()
     }else{
      this.controller.start()
     }
     this.isPlay = !this.isPlay
    })
    .width('100%')
    .height(this.videoHeight)
    .autoPlay(this.isAutoPlay)
    .controls(this.showControls)
   Row() {
    Button('fullscreen').onClick(async () => {
     if(!this.windowClass){ return; }
     if(this.videoHeight === '100%'){
      // 非全屏模式
      this.windowClass.setWindowLayoutFullScreen(false).then(()=>{
       this.videoHeight = '300vp'
      })
      this.windowClass.setPreferredOrientation(window.Orientation.PORTRAIT)
      this.windowClass.setWindowSystemBarEnable(['status'])
     }else{
      // 全屏模式
      this.windowClass.setWindowLayoutFullScreen(true).then(()=>{
       this.videoHeight = '100%'
      })
      this.windowClass.setPreferredOrientation(window.Orientation.LANDSCAPE)
      this.windowClass.setWindowSystemBarEnable([])
     }
    }).margin(5)
   }
  }.alignContent(Alignment.Bottom)
 }
}
分享
微博
QQ
微信
回复
2天前
相关问题
HarmonyOS poppuwindow无法全屏
291浏览 • 1回复 待解决
HarmonyOS Lottie无法全屏加载
86浏览 • 1回复 待解决
HarmonyOS struct全屏问题
245浏览 • 1回复 待解决
Ability 全屏模式无法实现
329浏览 • 2回复 待解决
video requestFullscreen 全屏问题
976浏览 • 1回复 待解决
HarmonyOS Web全屏播放适配
255浏览 • 1回复 待解决
HarmonyOS 列表视频全屏播放实现
426浏览 • 1回复 待解决
HarmonyOS 页面如何设置全屏显示?
471浏览 • 1回复 待解决
HarmonyOS 页面内组件全屏怎么处理?
482浏览 • 1回复 待解决
HarmonyOS 自定义弹窗遮罩未全屏
691浏览 • 1回复 待解决
HarmonyOS 用启动首帧图片怎么全屏
533浏览 • 1回复 待解决
HarmonyOS 自定义弹框不能全屏
75浏览 • 1回复 待解决