PlayerUIComponent.ets 1.51 KB
import { WDAliPlayerController } from 'wdPlayer/Index';
import { PlayerCommentComponent } from './PlayerCommentComponent';
import { PlayerTitleComponent } from './PlayerTitleComponent';
import { PlayerVideoControlComponent } from './PlayerVideoControlComponent';

/**
 * 沉浸直播  --- 横滑展示组件
 */
@Component
export struct PlayerUIComponent {
  private playerController?: WDAliPlayerController
  @State isSmall:boolean = false
  @Consume isShowControl: boolean
  aboutToAppear() {
    if (!this.playerController) {
      return
    }
    this.playerController.onVideoSizePlayerUIComponentMethod = (width: number, height: number) => {
      if(width>height){
        this.isSmall = true
      }else{
        this.isSmall = false
      }
    }
  }
  build() {
    Stack() {
      //  标题
      PlayerTitleComponent({ playerController: this.playerController })

      PlayerCommentComponent()
        .visibility(this.isShowControl ? Visibility.Hidden : Visibility.Visible)
        .animation({ duration: 500 })
        .position({ y: '100%' })
        .markAnchor({ y: '100%' })

      PlayerVideoControlComponent({ playerController: this.playerController })
        .visibility(this.isShowControl ? Visibility.Visible : this.isSmall? Visibility.Visible:Visibility.Hidden)
        .animation({ duration: 500 })
        // .position({ y: '100%' })
        // .markAnchor({ y: '100%' })
        .margin({ top:  this.isSmall ? 195 + 211 - 105 : 0})
    }
    .height('100%')
    .width('100%')
    .alignContent(Alignment.TopStart)

  }
}