yuzhilin
@@ -7,7 +7,8 @@ import { MorningEveningViewModel } from '../../viewmodel/MorningEveningViewModel @@ -7,7 +7,8 @@ import { MorningEveningViewModel } from '../../viewmodel/MorningEveningViewModel
7 import { PaperTitleComponent } from './PaperTitleComponent'; 7 import { PaperTitleComponent } from './PaperTitleComponent';
8 import { SingleColumn999Component } from './SingleColumn999Component'; 8 import { SingleColumn999Component } from './SingleColumn999Component';
9 import { topicInfoView } from './topicInfoView'; 9 import { topicInfoView } from './topicInfoView';
10 -import { PlayerConstants, WDPlayerController } from 'wdPlayer'; 10 +import { DateFormatUtil, PlayerConstants, WDPlayerController } from 'wdPlayer';
  11 +import { AudioDataList } from 'wdBean/src/main/ets/bean/morningevening/AudioDataList';
11 12
12 const TAG = 'MorningEveningPaperComponent'; 13 const TAG = 'MorningEveningPaperComponent';
13 14
@@ -39,13 +40,19 @@ export struct MorningEveningPaperComponent { @@ -39,13 +40,19 @@ export struct MorningEveningPaperComponent {
39 // } as MorningEveningPaperDTO 40 // } as MorningEveningPaperDTO
40 @Provide title: string = '' 41 @Provide title: string = ''
41 @Provide subTitle: string = '' 42 @Provide subTitle: string = ''
  43 + @Provide audioTitle: string = ''
42 @Provide isAudioPlaying: boolean = false 44 @Provide isAudioPlaying: boolean = false
43 @Provide status: number = PlayerConstants.STATUS_START; 45 @Provide status: number = PlayerConstants.STATUS_START;
  46 + @Provide currentTime: string = "00:00";
  47 + @Provide totalTime: string = "00:00";
  48 + @Provide progressVal: number = 0;
  49 + private audioDataList: AudioDataList[] = []
44 private playerController: WDPlayerController = new WDPlayerController(); 50 private playerController: WDPlayerController = new WDPlayerController();
45 simpleAudioDialog: CustomDialogController = new CustomDialogController({ 51 simpleAudioDialog: CustomDialogController = new CustomDialogController({
46 builder: PaperReaderSimpleDialog({ 52 builder: PaperReaderSimpleDialog({
47 cancel: this.onCancel, 53 cancel: this.onCancel,
48 - confirm: this.onConfirm 54 + confirm: this.onConfirm,
  55 + playerController: this.playerController
49 }), 56 }),
50 autoCancel: false, 57 autoCancel: false,
51 customStyle: true, 58 customStyle: true,
@@ -58,13 +65,30 @@ export struct MorningEveningPaperComponent { @@ -58,13 +65,30 @@ export struct MorningEveningPaperComponent {
58 Logger.info(TAG, "cj2024 onCancel = ") 65 Logger.info(TAG, "cj2024 onCancel = ")
59 } 66 }
60 67
  68 + /**
  69 + * 回调无用
  70 + **/
61 onConfirm() { 71 onConfirm() {
62 Logger.info(TAG, "cj2024 onConfirm = ") 72 Logger.info(TAG, "cj2024 onConfirm = ")
63 // if (this.playerController != undefined) { 73 // if (this.playerController != undefined) {
64 // 74 //
65 // } 75 // }
66 - this.status = PlayerConstants.STATUS_PAUSE;  
67 - this.playerController?.pause() 76 + // this.status = PlayerConstants.STATUS_PAUSE;
  77 + // this.playerController?.pause()
  78 + }
  79 +
  80 + // 续播判断
  81 + changeContinue() {
  82 + Logger.info(TAG, "cj2024 changeContinue = 1")
  83 + // if (this.nextContId) {
  84 + this.playerController.continue = () => {
  85 + Logger.info(TAG, "cj2024 changeContinue = 2")
  86 + this.playerController?.stop();
  87 + // this.playVM.playWithContentId(this.nextContId ?? '');
  88 + }
  89 + return;
  90 + // }
  91 + this.playerController.continue = undefined;
68 } 92 }
69 93
70 async aboutToAppear() { 94 async aboutToAppear() {
@@ -91,11 +115,16 @@ export struct MorningEveningPaperComponent { @@ -91,11 +115,16 @@ export struct MorningEveningPaperComponent {
91 this.compListItem = compInfoBean?.compList[0] 115 this.compListItem = compInfoBean?.compList[0]
92 if (compInfoBean?.compList[0].audioDataList) { 116 if (compInfoBean?.compList[0].audioDataList) {
93 this.audioPlayUrl = compInfoBean?.compList[0].audioDataList[0].audioUrl 117 this.audioPlayUrl = compInfoBean?.compList[0].audioDataList[0].audioUrl
  118 + this.audioTitle = compInfoBean?.compList[0].audioDataList[0].title
94 } 119 }
95 } 120 }
96 121
97 Logger.info(TAG, "compInfoBean compStyle = " + compInfoBean.compList[0].compStyle) 122 Logger.info(TAG, "compInfoBean compStyle = " + compInfoBean.compList[0].compStyle)
98 - 123 + this.playerController.onTimeUpdate = (position, duration) => {
  124 + this.currentTime = DateFormatUtil.secondToTime(position);
  125 + this.totalTime = DateFormatUtil.secondToTime(duration);
  126 + this.progressVal = Math.floor(position * 100 / duration);
  127 + }
99 } catch (exception) { 128 } catch (exception) {
100 129
101 } 130 }
1 /** 1 /**
2 * 简易音频对话框 2 * 简易音频对话框
3 * */ 3 * */
  4 +import { PlayerConstants, WDPlayerController } from 'wdPlayer/Index'
4 5
5 @CustomDialog 6 @CustomDialog
6 export struct PaperReaderSimpleDialog { 7 export struct PaperReaderSimpleDialog {
@@ -8,13 +9,16 @@ export struct PaperReaderSimpleDialog { @@ -8,13 +9,16 @@ export struct PaperReaderSimpleDialog {
8 } 9 }
9 confirm: () => void = () => { 10 confirm: () => void = () => {
10 } 11 }
  12 + playerController: WDPlayerController = new WDPlayerController()
11 paperReaderDialog: CustomDialogController = new CustomDialogController({ 13 paperReaderDialog: CustomDialogController = new CustomDialogController({
12 builder: PaperReaderDialog({ 14 builder: PaperReaderDialog({
13 onCancel: this.cancel, 15 onCancel: this.cancel,
14 - onConfirm: this.confirm 16 + onConfirm: this.confirm,
  17 + playerController: this.playerController
15 }), 18 }),
16 autoCancel: false, 19 autoCancel: false,
17 customStyle: true, 20 customStyle: true,
  21 +
18 alignment: DialogAlignment.CenterStart, 22 alignment: DialogAlignment.CenterStart,
19 offset: { dx: 12, dy: -150 } 23 offset: { dx: 12, dy: -150 }
20 }) 24 })
@@ -44,7 +48,7 @@ export struct PaperReaderSimpleDialog { @@ -44,7 +48,7 @@ export struct PaperReaderSimpleDialog {
44 if (this.controllerSimple != undefined) { 48 if (this.controllerSimple != undefined) {
45 this.controllerSimple.open() 49 this.controllerSimple.open()
46 } 50 }
47 - }, 100000); 51 + }, 500000);
48 } 52 }
49 } 53 }
50 54
@@ -58,6 +62,12 @@ export struct PaperReaderSimpleDialog { @@ -58,6 +62,12 @@ export struct PaperReaderSimpleDialog {
58 * */ 62 * */
59 @CustomDialog 63 @CustomDialog
60 export struct PaperReaderDialog { 64 export struct PaperReaderDialog {
  65 + @Consume audioTitle: string;
  66 + @Consume currentTime: string;
  67 + @Consume totalTime: string;
  68 + @Consume progressVal: number;
  69 + @State currentStatus: number = 0;
  70 + playerController: WDPlayerController = new WDPlayerController()
61 controllerDetail?: CustomDialogController 71 controllerDetail?: CustomDialogController
62 onCancel: () => void = () => { 72 onCancel: () => void = () => {
63 } 73 }
@@ -72,7 +82,7 @@ export struct PaperReaderDialog { @@ -72,7 +82,7 @@ export struct PaperReaderDialog {
72 step: 5, 82 step: 5,
73 loop: Number.POSITIVE_INFINITY, 83 loop: Number.POSITIVE_INFINITY,
74 fromStart: true, 84 fromStart: true,
75 - src: "Running Marquee starts rolling" 85 + src: this.audioTitle
76 }) 86 })
77 .width("60%") 87 .width("60%")
78 .height(20) 88 .height(20)
@@ -91,12 +101,12 @@ export struct PaperReaderDialog { @@ -91,12 +101,12 @@ export struct PaperReaderDialog {
91 }) 101 })
92 102
93 Row() { 103 Row() {
94 - Text("00:00") 104 + Text(this.currentTime)
95 .fontSize($r('app.float.font_size_12')) 105 .fontSize($r('app.float.font_size_12'))
96 .fontColor($r('app.color.color_999999')) 106 .fontColor($r('app.color.color_999999'))
97 .height("100%") 107 .height("100%")
98 .alignSelf(ItemAlign.Start) 108 .alignSelf(ItemAlign.Start)
99 - Text("/00:00") 109 + Text("/" + this.totalTime)
100 .fontSize($r('app.float.font_size_12')) 110 .fontSize($r('app.float.font_size_12'))
101 .fontColor($r('app.color.color_999999')) 111 .fontColor($r('app.color.color_999999'))
102 .height("100%") 112 .height("100%")
@@ -107,7 +117,7 @@ export struct PaperReaderDialog { @@ -107,7 +117,7 @@ export struct PaperReaderDialog {
107 .height(16) 117 .height(16)
108 .margin({ top: 4, left: 10 }) 118 .margin({ top: 4, left: 10 })
109 119
110 - Progress({ value: 50, total: 100, type: ProgressType.Capsule }) 120 + Progress({ value: this.progressVal, total: 100, type: ProgressType.Capsule })
111 .color($r('app.color.color_ED2800')) 121 .color($r('app.color.color_ED2800'))
112 .backgroundColor($r('app.color.white')) 122 .backgroundColor($r('app.color.white'))
113 .width("100%") 123 .width("100%")
@@ -119,14 +129,16 @@ export struct PaperReaderDialog { @@ -119,14 +129,16 @@ export struct PaperReaderDialog {
119 .justifyContent(FlexAlign.Start) 129 .justifyContent(FlexAlign.Start)
120 130
121 Row() { 131 Row() {
122 - Image($r("app.media.icon_audio_pause")) 132 + Image(this.currentStatus != PlayerConstants.STATUS_START ? $r("app.media.icon_audio_pause") : $r("app.media.icon_audio_playing"))
123 .objectFit(ImageFit.Contain) 133 .objectFit(ImageFit.Contain)
124 .width(24) 134 .width(24)
125 .height(24) 135 .height(24)
126 .margin({ right: 12 }) 136 .margin({ right: 12 })
127 .onClick(() => { 137 .onClick(() => {
128 - if (this.controllerDetail) {  
129 - this.onConfirm() 138 + if (this.playerController) {
  139 + // this.onConfirm()
  140 + this.playerController.switchPlayOrPause()
  141 + this.currentStatus = this.playerController.getStatus()
130 } 142 }
131 }) 143 })
132 144
@@ -135,6 +147,9 @@ export struct PaperReaderDialog { @@ -135,6 +147,9 @@ export struct PaperReaderDialog {
135 .width(24) 147 .width(24)
136 .height(24) 148 .height(24)
137 .onClick(() => { 149 .onClick(() => {
  150 + if (this.playerController) {
  151 + this.playerController.stop()
  152 + }
138 if (this.controllerDetail) { 153 if (this.controllerDetail) {
139 this.controllerDetail.close() 154 this.controllerDetail.close()
140 } 155 }