PlayerTitleComment.ets 3.92 KB
import router from '@ohos.router';
import window from '@ohos.window';
import deviceInfo from '@ohos.deviceInfo'
import { WindowModel } from 'wdKit';
import { WDPlayerController } from 'wdPlayer';
import { devicePLSensorManager } from 'wdDetailPlayApi';
import { OperationListView } from './OperationListView';

@Component
export struct PlayerTitleComment {
  private playerController?: WDPlayerController;
  @Consume title?: string
  @Consume newsSummary?: string;
  @State @Watch('watchSpeed') playSpeed: number = 1;
  @Consume isFullScreen: boolean;
  @State comment: string = '';
  @Consume progressVal: number;

  aboutToAppear() {
  }

  watchSpeed() {
    this.playerController?.setSpeed(this.playSpeed);
  }

  build() {
    Column() {
      Column() {
        Row() {
          Image($r('app.media.ic_switch_orientation'))
            .width(34)
            .aspectRatio(1)
            .objectFit(ImageFit.Contain)
            .padding({ left: 10, right: 5 })
          Text("全屏观看")
            .fontColor(Color.White)
            .fontSize('14fp')
            .maxLines(2)
            .layoutWeight(1)
        }
        .width(100)
        .backgroundColor(Color.Gray)
        .borderRadius(10)
        .alignItems(VerticalAlign.Center)
        .onClick(() => {
          this.isFullScreen = !this.isFullScreen;
          WindowModel.shared.setPreferredOrientation(window.Orientation.LANDSCAPE);
          devicePLSensorManager.devicePLSensorOn(window.Orientation.LANDSCAPE);
        })
      }
      .width('100%')
      .margin({ bottom: 120 })
      .alignItems(HorizontalAlign.Center)

      Row() {
        Column() {
          Text(this.title)
            .fontColor(Color.White)
            .fontSize(14)
            .maxLines(1)

          Text('查看详情 > ')
            .fontColor(Color.White)
            .fontSize('14fp')
            .maxLines(2)
        }
        .layoutWeight(1)
        .alignItems(HorizontalAlign.Start)

        // OperationListView()
        //   .width(48)
        //   .height(150)
        //   .zIndex(3)
      }
      .width('100%')

      Slider({
        value: this.progressVal,
        step: 1,
        style: SliderStyle.OutSet
      })
        .blockColor(Color.White)
        .trackColor($r('app.color.track_color'))
        .selectedColor($r('app.color.index_tab_selected_font_color'))
        .trackThickness(1)
        .width('100%')
        .onChange((value: number, mode: SliderChangeMode) => {
          this.playerController?.setSeekTime(value, mode);
        })

      Row() {
        Image($r('app.media.ic_back'))
          .width(44)
          .aspectRatio(1)
          .padding(13)
          .margin({ left: 13 })
          .onClick(() => {
            if (this.isFullScreen) {
              if (deviceInfo.deviceType != "phone") {
                WindowModel.shared.getWindowSize().then((size) => {
                  if (size.width > size.height) {
                    router.back();
                  } else {
                    this.isFullScreen = !this.isFullScreen;
                    WindowModel.shared.setPreferredOrientation(window.Orientation.PORTRAIT);
                    devicePLSensorManager.devicePLSensorOn(window.Orientation.PORTRAIT);
                  }
                })
              } else {
                this.isFullScreen = !this.isFullScreen;
                WindowModel.shared.setPreferredOrientation(window.Orientation.PORTRAIT);
                devicePLSensorManager.devicePLSensorOn(window.Orientation.PORTRAIT);
              }
            } else {
              router.back();
            }
          })

        TextInput({ placeholder: '说两句...', text: this.comment })
          .placeholderColor(Color.White)
          .placeholderFont({ size: 14 })
          .fontColor(Color.White)
          .fontSize(14)
          .maxLines(1)
          .layoutWeight(1)
      }.alignItems(VerticalAlign.Center)
    }
    .width('100%')
    // .height('40%')
    .alignItems(HorizontalAlign.Start)
  }
}