PlayerDetailContainer.ets 1.77 KB
/**
 * 详情view&播放器view的容器布局组件
 */

@Component
export struct PlayerDetailContainer {
  @BuilderParam playerView: () => void
  @BuilderParam playControlView: () => void
  @BuilderParam detailView: () => void
  @Consume isFullScreen: boolean
  @Consume videoLandScape?: number // 视频朝向, 横屏视频:1;竖屏视频:2

  aboutToAppear() {
    console.log(`PlayerDetailContainer aboutToAppear`)
  }

  buildVideoHeight() {
    let videoHeight: string | number = 200
    if (this.videoLandScape == 2) {
      videoHeight = '100%'
    } else {
      videoHeight = 200
    }
    console.log(`PlayerDetailContainer buildVideoHeight:${videoHeight}  `)
    return videoHeight
  }

  buildVideoTo() {
    let videoTop: number;
    if (this.videoLandScape == 2) {
      videoTop = 0
    } else {
      videoTop = 174
    }
    console.log(`PlayerDetailContainer videoTop:${videoTop} `)
    return videoTop
  }

  buildVideoBottom() {
    let videoBottom: number;
    if (this.videoLandScape == 2) {
      videoBottom = 0
    } else {
      videoBottom = 320
    }
    console.log(`PlayerDetailContainer buildVideoBottom:${videoBottom} `)
    return videoBottom
  }

  isShowBottomView() {
    console.log(`PlayerDetailContainer videoLandScape:${this.videoLandScape} `)
    let isShowBottom: boolean = false
    if (this.isFullScreen) {
      isShowBottom = false
    } else {
      isShowBottom = true
    }
    console.log(`PlayerDetailContainer isShowBottom:${isShowBottom} `)
    return isShowBottom
  }

  build() {
    Stack() {
      this.playerView()
      this.detailView()
    }
    .width('100%')
    .height('100%')

    // .backgroundColor(Color.Black) // 扩展至所有非安全区域
    // .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM])
  }
}