chenjun3_wd

早晚报 音频播放

  1 +import { ReLInfo } from './ReLInfo';
  2 +
  3 +export interface AudioDataList {
  4 + audioUrl: string;
  5 + coverUrl: string;
  6 + duration: number;
  7 + objectId: number;
  8 + objectType: number;
  9 + reLInfo: ReLInfo;
  10 + title: string;
  11 +}
  1 +import { AudioDataList } from './AudioDataList';
1 import { OperDataList } from './OperDataList'; 2 import { OperDataList } from './OperDataList';
2 3
3 export interface CompList { 4 export interface CompList {
4 - // audioDataList: any[]; 5 + audioDataList: AudioDataList[];
5 backgroundImgUrl: string; 6 backgroundImgUrl: string;
  7 +
6 // bottomNavId?: any; 8 // bottomNavId?: any;
7 cardItemId: string; 9 cardItemId: string;
  10 +
8 // cardUpdateStrategy?: any; 11 // cardUpdateStrategy?: any;
9 compStyle: string; 12 compStyle: string;
10 compType: string; 13 compType: string;
11 dataSourceType: string; 14 dataSourceType: string;
12 expIds: string; 15 expIds: string;
13 extraData: string; 16 extraData: string;
  17 +
14 // fullColumnImgUrls: any[]; 18 // fullColumnImgUrls: any[];
15 hasMore: number; 19 hasMore: number;
16 id: number; 20 id: number;
  21 +
17 // imageScale?: any; 22 // imageScale?: any;
18 imgSize: string; 23 imgSize: string;
19 itemId: string; 24 itemId: string;
20 itemType: string; 25 itemType: string;
21 itemTypeCode: string; 26 itemTypeCode: string;
22 linkUrl: string; 27 linkUrl: string;
  28 +
23 // localGovernance?: any; 29 // localGovernance?: any;
24 name: string; 30 name: string;
25 objectId: string; 31 objectId: string;
@@ -27,13 +33,16 @@ export interface CompList { @@ -27,13 +33,16 @@ export interface CompList {
27 objectSummary: string; 33 objectSummary: string;
28 objectTitle: string; 34 objectTitle: string;
29 objectType: string; 35 objectType: string;
  36 +
30 // openComment?: any; 37 // openComment?: any;
31 // openLikes?: any; 38 // openLikes?: any;
32 operDataList: OperDataList[]; 39 operDataList: OperDataList[];
33 pageId: string; 40 pageId: string;
  41 +
34 // position?: any; 42 // position?: any;
35 posterSize: string; 43 posterSize: string;
36 posterUrl: string; 44 posterUrl: string;
  45 +
37 // questionSection?: any; 46 // questionSection?: any;
38 recommend: number; 47 recommend: number;
39 relId: number; 48 relId: number;
@@ -41,8 +50,10 @@ export interface CompList { @@ -41,8 +50,10 @@ export interface CompList {
41 sortValue: number; 50 sortValue: number;
42 subSceneId: string; 51 subSceneId: string;
43 summaryName: string; 52 summaryName: string;
  53 +
44 // tabOperDataList: any[]; 54 // tabOperDataList: any[];
45 titleShowPolicy: number; 55 titleShowPolicy: number;
  56 +
46 // topicTemplate?: any; 57 // topicTemplate?: any;
47 traceId: string; 58 traceId: string;
48 traceInfo: string; 59 traceInfo: string;
  1 +export interface ReLInfo {
  2 + channelId?: string;
  3 + relId: string;
  4 + relObjectId: number;
  5 + relType: string;
  6 +}
@@ -13,6 +13,7 @@ @@ -13,6 +13,7 @@
13 "wdBean": "file:../../features/wdBean", 13 "wdBean": "file:../../features/wdBean",
14 "wdRouter": "file:../../commons/wdRouter", 14 "wdRouter": "file:../../commons/wdRouter",
15 "wdNetwork": "file:../../commons/wdNetwork", 15 "wdNetwork": "file:../../commons/wdNetwork",
  16 + "wdPlayer": "file:../../features/wdPlayer",
16 "wdLogin": "file:../../features/wdLogin" 17 "wdLogin": "file:../../features/wdLogin"
17 } 18 }
18 } 19 }
1 import { AudioDTO } from 'wdBean'; 1 import { AudioDTO } from 'wdBean';
  2 +import { Logger } from 'wdKit/Index';
2 3
3 /** 4 /**
4 * 早晚报页面音频bar 5 * 早晚报页面音频bar
5 */ 6 */
6 -@Entry 7 +// @Entry
7 @Component 8 @Component
8 export struct AudioBarView { 9 export struct AudioBarView {
9 @State audioDataList?: AudioDTO[] = [] 10 @State audioDataList?: AudioDTO[] = []
  11 + @Consume isAudioPlaying?: boolean
10 12
11 aboutToAppear() { 13 aboutToAppear() {
12 } 14 }
@@ -45,6 +47,11 @@ export struct AudioBarView { @@ -45,6 +47,11 @@ export struct AudioBarView {
45 .height(24) 47 .height(24)
46 .margin({ left: 10 })// .alignSelf(ItemAlign.Center) 48 .margin({ left: 10 })// .alignSelf(ItemAlign.Center)
47 .objectFit(ImageFit.Contain) 49 .objectFit(ImageFit.Contain)
  50 + .onClick(() => {
  51 + Logger.info("TAG", "cj compInfoBean onClick1 = " + this.isAudioPlaying)
  52 + this.isAudioPlaying = !this.isAudioPlaying
  53 + Logger.info("TAG", "cj compInfoBean onClick2 = " + this.isAudioPlaying)
  54 + })
48 } 55 }
49 // .aspectRatio(7 / 4) 56 // .aspectRatio(7 / 4)
50 .height('100%') 57 .height('100%')
1 // import { FrontLinkObject, MorningEveningPaperDTO, PageInfoBean } from 'wdBean'; 1 // import { FrontLinkObject, MorningEveningPaperDTO, PageInfoBean } from 'wdBean';
2 import { CompList, PageInfoBean } from 'wdBean'; 2 import { CompList, PageInfoBean } from 'wdBean';
3 import { DateTimeUtils, Logger } from 'wdKit/Index'; 3 import { DateTimeUtils, Logger } from 'wdKit/Index';
  4 +import { PaperReaderSimpleDialog } from '../../dialog/PaperReaderDialog';
4 import { MorningEveningViewModel } from '../../viewmodel/MorningEveningViewModel'; 5 import { MorningEveningViewModel } from '../../viewmodel/MorningEveningViewModel';
5 -import { AudioBarView } from './AudioBarView'; 6 +// import { AudioBarView } from './AudioBarView';
6 import { PaperTitleComponent } from './PaperTitleComponent'; 7 import { PaperTitleComponent } from './PaperTitleComponent';
7 import { SingleColumn999Component } from './SingleColumn999Component'; 8 import { SingleColumn999Component } from './SingleColumn999Component';
8 import { topicInfoView } from './topicInfoView'; 9 import { topicInfoView } from './topicInfoView';
  10 +import { WDPlayerController } from 'wdPlayer';
9 11
10 const TAG = 'MorningEveningPaperComponent'; 12 const TAG = 'MorningEveningPaperComponent';
11 13
@@ -17,6 +19,7 @@ export struct MorningEveningPaperComponent { @@ -17,6 +19,7 @@ export struct MorningEveningPaperComponent {
17 @State pageInfoBean: PageInfoBean = {} as PageInfoBean 19 @State pageInfoBean: PageInfoBean = {} as PageInfoBean
18 // @State compInfoBean: CompInfoBean = {} as CompInfoBean 20 // @State compInfoBean: CompInfoBean = {} as CompInfoBean
19 @State compListItem: CompList = {} as CompList 21 @State compListItem: CompList = {} as CompList
  22 + @State audioPlayUrl: string = ""
20 // @Provide compListItem: CompList = {} as CompList 23 // @Provide compListItem: CompList = {} as CompList
21 // @State morningEveningPaperDTO: MorningEveningPaperDTO = { 24 // @State morningEveningPaperDTO: MorningEveningPaperDTO = {
22 // name: "新闻夜读", 25 // name: "新闻夜读",
@@ -36,6 +39,16 @@ export struct MorningEveningPaperComponent { @@ -36,6 +39,16 @@ export struct MorningEveningPaperComponent {
36 // } as MorningEveningPaperDTO 39 // } as MorningEveningPaperDTO
37 @Provide title: string = '' 40 @Provide title: string = ''
38 @Provide subTitle: string = '' 41 @Provide subTitle: string = ''
  42 + @Provide isAudioPlaying: boolean = false
  43 + private playerController: WDPlayerController = new WDPlayerController();
  44 + private xComponentController: XComponentController = new XComponentController();
  45 + simpleAudioDialog: CustomDialogController = new CustomDialogController({
  46 + builder: PaperReaderSimpleDialog(),
  47 + autoCancel: false,
  48 + customStyle: true,
  49 + alignment: DialogAlignment.CenterStart,
  50 + offset: { dx: 12, dy: -150 }
  51 + })
39 52
40 async aboutToAppear() { 53 async aboutToAppear() {
41 console.info(TAG, `aboutToAppear`) 54 console.info(TAG, `aboutToAppear`)
@@ -44,7 +57,7 @@ export struct MorningEveningPaperComponent { @@ -44,7 +57,7 @@ export struct MorningEveningPaperComponent {
44 Logger.info(TAG, "currentTime = " + currentTime) 57 Logger.info(TAG, "currentTime = " + currentTime)
45 Logger.info(TAG, `currentTime = ${currentTime}`) 58 Logger.info(TAG, `currentTime = ${currentTime}`)
46 try { 59 try {
47 - let pageInfoBean = await MorningEveningViewModel.getMorningEveningPageInfo("28949") 60 + let pageInfoBean = await MorningEveningViewModel.getMorningEveningPageInfo("25091")
48 this.pageInfoBean = pageInfoBean; 61 this.pageInfoBean = pageInfoBean;
49 this.title = this.pageInfoBean?.topicInfo?.title 62 this.title = this.pageInfoBean?.topicInfo?.title
50 let dateTime = DateTimeUtils.parseDate(this.pageInfoBean?.topicInfo?.topicDate ?? '', DateTimeUtils.PATTERN_DATE_HYPHEN); 63 let dateTime = DateTimeUtils.parseDate(this.pageInfoBean?.topicInfo?.topicDate ?? '', DateTimeUtils.PATTERN_DATE_HYPHEN);
@@ -59,9 +72,13 @@ export struct MorningEveningPaperComponent { @@ -59,9 +72,13 @@ export struct MorningEveningPaperComponent {
59 // this.compInfoBean = compInfoBean 72 // this.compInfoBean = compInfoBean
60 if (compInfoBean?.compList[0]) { 73 if (compInfoBean?.compList[0]) {
61 this.compListItem = compInfoBean?.compList[0] 74 this.compListItem = compInfoBean?.compList[0]
  75 + if (compInfoBean?.compList[0].audioDataList) {
  76 + this.audioPlayUrl = compInfoBean?.compList[0].audioDataList[0].audioUrl
  77 + }
62 } 78 }
63 79
64 Logger.info(TAG, "compInfoBean compStyle = " + compInfoBean.compList[0].compStyle) 80 Logger.info(TAG, "compInfoBean compStyle = " + compInfoBean.compList[0].compStyle)
  81 +
65 } catch (exception) { 82 } catch (exception) {
66 83
67 } 84 }
@@ -77,12 +94,15 @@ export struct MorningEveningPaperComponent { @@ -77,12 +94,15 @@ export struct MorningEveningPaperComponent {
77 } 94 }
78 95
79 ListItem() { 96 ListItem() {
80 - AudioBarView() 97 + this.AudioBarView(this.simpleAudioDialog)
81 } 98 }
82 } 99 }
83 100
84 ListItem() { 101 ListItem() {
85 - SingleColumn999Component({ compListItem: this.compListItem }).margin({ top: $r('app.float.top_bar_height') }) 102 + SingleColumn999Component({ compListItem: this.compListItem })
  103 + .margin({
  104 + top: this.pageInfoBean?.topicInfo?.frontLinkObject ? 10 : 44
  105 + })
86 } 106 }
87 } 107 }
88 // .backgroundColor('#FFF1F3F5') 108 // .backgroundColor('#FFF1F3F5')
@@ -104,4 +124,63 @@ export struct MorningEveningPaperComponent { @@ -104,4 +124,63 @@ export struct MorningEveningPaperComponent {
104 // .backgroundColor(Color.Black) 124 // .backgroundColor(Color.Black)
105 .backgroundColor(this.pageInfoBean?.backgroundColor ?? Color.Black) 125 .backgroundColor(this.pageInfoBean?.backgroundColor ?? Color.Black)
106 } 126 }
  127 +
  128 + @Builder
  129 + AudioBarView(dialog: CustomDialogController) {
  130 + Row() {
  131 + Stack({ alignContent: Alignment.Start }) {
  132 + Image($r('app.media.listen_left_bg'))
  133 + .width('100%')
  134 + .height('100%')
  135 + .objectFit(ImageFit.Contain)
  136 + Image($r('app.media.icon_listen'))
  137 + .width(24)
  138 + .height(24)
  139 + .margin({ left: 10 })
  140 + .alignSelf(ItemAlign.Start)
  141 +
  142 + Text('晚上好, 请收听今日新闻播报')
  143 + .fontSize(14)
  144 + .margin({ left: 50 })
  145 + .fontColor(Color.Black)
  146 + .maxLines(1)
  147 + .textOverflow({ overflow: TextOverflow.Ellipsis })
  148 + }
  149 + .layoutWeight(1)
  150 + .height('100%')
  151 +
  152 + Stack({ alignContent: Alignment.Center }) {
  153 + Image($r('app.media.listen_right_bg'))
  154 + .width('100%')
  155 + .height('100%')
  156 + .objectFit(ImageFit.Contain)
  157 +
  158 + Image($r('app.media.ic_red_triangle'))
  159 + .width(24)
  160 + .height(24)
  161 + .margin({ left: 10 })// .alignSelf(ItemAlign.Center)
  162 + .objectFit(ImageFit.Contain)
  163 + .onClick(() => {
  164 + Logger.info("TAG", "cj compInfoBean onClick1 = " + this.isAudioPlaying)
  165 + dialog.open()
  166 + this.playerController.firstPlay(this.audioPlayUrl)
  167 + Logger.info("TAG", "cj compInfoBean onClick2 = " + this.isAudioPlaying)
  168 + })
  169 + }
  170 + // .aspectRatio(7 / 4)
  171 + .height('100%')
  172 + // .justifyContent(FlexAlign.Center)
  173 + // .width(94)
  174 + // .width(140)
  175 + .width('20%')
  176 + // .height(56)
  177 + .onClick(() => {
  178 + // console.info(TAG, `onClick listen_right_bg`);
  179 + })
  180 + }
  181 + // .width('100%')
  182 + .height(56)
  183 + .alignItems(VerticalAlign.Center)
  184 + .justifyContent(FlexAlign.SpaceBetween)
  185 + }
107 } 186 }
  1 +/**
  2 + * 简易音频对话框
  3 + * */
  4 +@CustomDialog
  5 +export struct PaperReaderSimpleDialog {
  6 + private controllerSimple?: CustomDialogController;
  7 +
  8 + build() {
  9 + Row() {
  10 + Image($r("app.media.icon_audio_pause"))
  11 + .objectFit(ImageFit.Contain)
  12 + .margin(18)
  13 + .width(24)
  14 + .height(24)
  15 + }
  16 + .width(60)
  17 + .height(60)
  18 + .backgroundColor(Color.White)
  19 + .onClick(() => {
  20 + if (this.controllerSimple) {
  21 + this.controllerSimple.close()
  22 + }
  23 +
  24 + })
  25 +
  26 + }
  27 +}
  28 +
  29 +/**
  30 + * 图文音频对话框
  31 + * */
  32 +@CustomDialog
  33 +export struct PaperReaderDialog {
  34 + controllerDetail?: CustomDialogController
  35 +
  36 + build() {
  37 + Stack() {
  38 + Column() { //标题 时间 进度条
  39 + Marquee({
  40 + start: true,
  41 + step: 50,
  42 + loop: Number.POSITIVE_INFINITY,
  43 + fromStart: true,
  44 + src: "Running Marquee starts rolling"
  45 + })
  46 + .width("60%")
  47 + .height(20)
  48 + .fontColor($r("app.color.color_222222"))
  49 + .fontSize(14)
  50 + .margin({ top: 10 })
  51 + .onStart(() => {
  52 + console.info('Marquee animation complete onStart')
  53 + })
  54 + .onBounce(() => {
  55 + console.info('Marquee animation complete onBounce')
  56 + })
  57 + .onFinish(() => {
  58 + console.info('Marquee animation complete onFinish')
  59 + })
  60 +
  61 + Row() {
  62 + Text("00:00")
  63 + .fontSize($r('app.float.font_size_12'))
  64 + .fontColor($r('app.color.color_999999'))
  65 + .width("49%")
  66 + .height("100%")
  67 + Text("/00:00")
  68 + .fontSize($r('app.float.font_size_12'))
  69 + .fontColor($r('app.color.color_999999'))
  70 + .width("51%")
  71 + .height("100%")
  72 +
  73 + }
  74 + .width("100%")
  75 + .height(16)
  76 + .margin({ top: 4 })
  77 + }
  78 + .width("100%")
  79 + .height("100%")
  80 +
  81 + Progress({ value: 0, total: 100, type: ProgressType.Linear })
  82 + .color($r('app.color.color_ED2800'))
  83 + .width("100%")
  84 + .height(3)
  85 +
  86 + Image($r("app.media.icon_audio_pause"))
  87 + .objectFit(ImageFit.Auto)
  88 + .align(Alignment.End)
  89 + .margin({ right: 12 })
  90 +
  91 + Image($r("app.media.icon_audio_close"))
  92 + .objectFit(ImageFit.Auto)
  93 + .align(Alignment.End)
  94 + .margin({ right: 48 })
  95 + .onClick(() => {
  96 + if (this.controllerDetail) {
  97 + this.controllerDetail.close()
  98 + }
  99 + })
  100 + }
  101 + .width("65%")
  102 + .height(60)
  103 + .backgroundColor(Color.White)
  104 + .borderRadius(5)
  105 + }
  106 +}