PlayDialog.ets 1.11 KB
import { PlayerConstants, SpeedBean } from 'wdPlayer';

// 倍速Dialog
@Preview
@CustomDialog
export struct PlaySpeedDialog {
  @Link playSpeed: number;
  @Link @Watch('closeDialog') isFullScreen: boolean
  controller: CustomDialogController;

  closeDialog(propName: string) {
    if (this.isFullScreen == false) {
      this.controller.close();
    }
  }

  build() {
    Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
      List({ space: '10%', initialIndex: 0 }) {
        ForEach(PlayerConstants.SPEED_ARRAY, (item: SpeedBean) => {
          ListItem() {
            Text(item.text)
              .width('100%')
              .textAlign(TextAlign.Center)
              .fontColor(this.playSpeed == item.value ? Color.Blue : Color.White)
              .fontSize(16)
              .fontWeight(FontWeight.Medium)
              .onClick(() => {
                this.playSpeed = item.value;
              })
          }
        })
      }
      .padding(12)
      .alignListItem(ListItemAlign.Center)
    }
    .width('20%')
    .height('100%')
    .backgroundColor('rgba(0,0,0,0.8)')
  }
}

// 码率..