yuzhilin
... ... @@ -7,7 +7,8 @@ import { MorningEveningViewModel } from '../../viewmodel/MorningEveningViewModel
import { PaperTitleComponent } from './PaperTitleComponent';
import { SingleColumn999Component } from './SingleColumn999Component';
import { topicInfoView } from './topicInfoView';
import { PlayerConstants, WDPlayerController } from 'wdPlayer';
import { DateFormatUtil, PlayerConstants, WDPlayerController } from 'wdPlayer';
import { AudioDataList } from 'wdBean/src/main/ets/bean/morningevening/AudioDataList';
const TAG = 'MorningEveningPaperComponent';
... ... @@ -39,13 +40,19 @@ export struct MorningEveningPaperComponent {
// } as MorningEveningPaperDTO
@Provide title: string = ''
@Provide subTitle: string = ''
@Provide audioTitle: string = ''
@Provide isAudioPlaying: boolean = false
@Provide status: number = PlayerConstants.STATUS_START;
@Provide currentTime: string = "00:00";
@Provide totalTime: string = "00:00";
@Provide progressVal: number = 0;
private audioDataList: AudioDataList[] = []
private playerController: WDPlayerController = new WDPlayerController();
simpleAudioDialog: CustomDialogController = new CustomDialogController({
builder: PaperReaderSimpleDialog({
cancel: this.onCancel,
confirm: this.onConfirm
confirm: this.onConfirm,
playerController: this.playerController
}),
autoCancel: false,
customStyle: true,
... ... @@ -58,13 +65,30 @@ export struct MorningEveningPaperComponent {
Logger.info(TAG, "cj2024 onCancel = ")
}
/**
* 回调无用
**/
onConfirm() {
Logger.info(TAG, "cj2024 onConfirm = ")
// if (this.playerController != undefined) {
//
// }
this.status = PlayerConstants.STATUS_PAUSE;
this.playerController?.pause()
// this.status = PlayerConstants.STATUS_PAUSE;
// this.playerController?.pause()
}
// 续播判断
changeContinue() {
Logger.info(TAG, "cj2024 changeContinue = 1")
// if (this.nextContId) {
this.playerController.continue = () => {
Logger.info(TAG, "cj2024 changeContinue = 2")
this.playerController?.stop();
// this.playVM.playWithContentId(this.nextContId ?? '');
}
return;
// }
this.playerController.continue = undefined;
}
async aboutToAppear() {
... ... @@ -91,11 +115,16 @@ export struct MorningEveningPaperComponent {
this.compListItem = compInfoBean?.compList[0]
if (compInfoBean?.compList[0].audioDataList) {
this.audioPlayUrl = compInfoBean?.compList[0].audioDataList[0].audioUrl
this.audioTitle = compInfoBean?.compList[0].audioDataList[0].title
}
}
Logger.info(TAG, "compInfoBean compStyle = " + compInfoBean.compList[0].compStyle)
this.playerController.onTimeUpdate = (position, duration) => {
this.currentTime = DateFormatUtil.secondToTime(position);
this.totalTime = DateFormatUtil.secondToTime(duration);
this.progressVal = Math.floor(position * 100 / duration);
}
} catch (exception) {
}
... ...
/**
* 简易音频对话框
* */
import { PlayerConstants, WDPlayerController } from 'wdPlayer/Index'
@CustomDialog
export struct PaperReaderSimpleDialog {
... ... @@ -8,13 +9,16 @@ export struct PaperReaderSimpleDialog {
}
confirm: () => void = () => {
}
playerController: WDPlayerController = new WDPlayerController()
paperReaderDialog: CustomDialogController = new CustomDialogController({
builder: PaperReaderDialog({
onCancel: this.cancel,
onConfirm: this.confirm
onConfirm: this.confirm,
playerController: this.playerController
}),
autoCancel: false,
customStyle: true,
alignment: DialogAlignment.CenterStart,
offset: { dx: 12, dy: -150 }
})
... ... @@ -44,7 +48,7 @@ export struct PaperReaderSimpleDialog {
if (this.controllerSimple != undefined) {
this.controllerSimple.open()
}
}, 100000);
}, 500000);
}
}
... ... @@ -58,6 +62,12 @@ export struct PaperReaderSimpleDialog {
* */
@CustomDialog
export struct PaperReaderDialog {
@Consume audioTitle: string;
@Consume currentTime: string;
@Consume totalTime: string;
@Consume progressVal: number;
@State currentStatus: number = 0;
playerController: WDPlayerController = new WDPlayerController()
controllerDetail?: CustomDialogController
onCancel: () => void = () => {
}
... ... @@ -72,7 +82,7 @@ export struct PaperReaderDialog {
step: 5,
loop: Number.POSITIVE_INFINITY,
fromStart: true,
src: "Running Marquee starts rolling"
src: this.audioTitle
})
.width("60%")
.height(20)
... ... @@ -91,12 +101,12 @@ export struct PaperReaderDialog {
})
Row() {
Text("00:00")
Text(this.currentTime)
.fontSize($r('app.float.font_size_12'))
.fontColor($r('app.color.color_999999'))
.height("100%")
.alignSelf(ItemAlign.Start)
Text("/00:00")
Text("/" + this.totalTime)
.fontSize($r('app.float.font_size_12'))
.fontColor($r('app.color.color_999999'))
.height("100%")
... ... @@ -107,7 +117,7 @@ export struct PaperReaderDialog {
.height(16)
.margin({ top: 4, left: 10 })
Progress({ value: 50, total: 100, type: ProgressType.Capsule })
Progress({ value: this.progressVal, total: 100, type: ProgressType.Capsule })
.color($r('app.color.color_ED2800'))
.backgroundColor($r('app.color.white'))
.width("100%")
... ... @@ -119,14 +129,16 @@ export struct PaperReaderDialog {
.justifyContent(FlexAlign.Start)
Row() {
Image($r("app.media.icon_audio_pause"))
Image(this.currentStatus != PlayerConstants.STATUS_START ? $r("app.media.icon_audio_pause") : $r("app.media.icon_audio_playing"))
.objectFit(ImageFit.Contain)
.width(24)
.height(24)
.margin({ right: 12 })
.onClick(() => {
if (this.controllerDetail) {
this.onConfirm()
if (this.playerController) {
// this.onConfirm()
this.playerController.switchPlayOrPause()
this.currentStatus = this.playerController.getStatus()
}
})
... ... @@ -135,6 +147,9 @@ export struct PaperReaderDialog {
.width(24)
.height(24)
.onClick(() => {
if (this.playerController) {
this.playerController.stop()
}
if (this.controllerDetail) {
this.controllerDetail.close()
}
... ...