王士厅

音频dialog开发

  1 +import { WDPlayerController } from 'wdPlayer';
  2 +import { PaperReaderSimpleDialog } from './PaperReaderDialog';
  3 +import { Logger } from 'wdKit/Index';
  4 +
  5 +const TAG = 'AudioDialog';
  6 +
  7 +@Preview
  8 +@CustomDialog
  9 +export struct AudioDialog {
  10 + private playerController: WDPlayerController = new WDPlayerController();
  11 + private simpleAudioDialog: CustomDialogController = new CustomDialogController({
  12 + builder: PaperReaderSimpleDialog({
  13 + cancel: this.onCancel,
  14 + confirm: this.onConfirm,
  15 + playerController: this.playerController
  16 + }),
  17 + autoCancel: false,
  18 + customStyle: true,
  19 + alignment: DialogAlignment.CenterStart,
  20 + offset: { dx: 12, dy: -150 },
  21 +
  22 + })
  23 +
  24 + onCancel() {
  25 + Logger.info(TAG, "cj2024 onCancel = ")
  26 + }
  27 +
  28 + /**
  29 + * 回调无用
  30 + **/
  31 + onConfirm() {
  32 + Logger.info(TAG, "cj2024 onConfirm = ")
  33 + // if (this.playerController != undefined) {
  34 + //
  35 + // }
  36 + // this.status = PlayerConstants.STATUS_PAUSE;
  37 + // this.playerController?.pause()
  38 + }
  39 +
  40 + build() {
  41 + Row() {
  42 + Image($r("app.media.icon_audio_pause"))
  43 + .objectFit(ImageFit.Contain)
  44 + .margin(18)
  45 + .width(24)
  46 + .height(24)
  47 + }
  48 + .width(60)
  49 + .height(60)
  50 + .backgroundColor(Color.White)
  51 + .onClick(() => {
  52 + if (this.simpleAudioDialog) {
  53 + this.simpleAudioDialog.close()
  54 + this.simpleAudioDialog.open()
  55 + if (this.simpleAudioDialog) {
  56 + setTimeout(() => {
  57 + console.log('PaperReaderSimpleDialog delay 1s');
  58 + if (this.simpleAudioDialog != undefined) {
  59 + this.simpleAudioDialog.close()
  60 + }
  61 + if (this.simpleAudioDialog != undefined) {
  62 + this.simpleAudioDialog.open()
  63 + }
  64 + }, 500000);
  65 + }
  66 + }
  67 +
  68 + })
  69 +
  70 + }
  71 +}