wangliang_wd

feat:增加视频播放器重播UI

@@ -19,7 +19,7 @@ export struct VideoPlayPage { @@ -19,7 +19,7 @@ export struct VideoPlayPage {
19 @State totalTime: string = '' 19 @State totalTime: string = ''
20 @State progressVal: number = 0; 20 @State progressVal: number = 0;
21 @Provide topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0 21 @Provide topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0
22 - 22 + @State isPlayEnd: boolean = false
23 23
24 aboutToAppear(): void { 24 aboutToAppear(): void {
25 let par: Action = router.getParams() as Action 25 let par: Action = router.getParams() as Action
@@ -35,6 +35,9 @@ export struct VideoPlayPage { @@ -35,6 +35,9 @@ export struct VideoPlayPage {
35 this.playerController.onCanplay = () => { 35 this.playerController.onCanplay = () => {
36 this.playerController.play() 36 this.playerController.play()
37 } 37 }
  38 + this.playerController.onStatusChange = (status: number) =>{
  39 + this.isPlayEnd = status === 5 ? true:false
  40 + }
38 } 41 }
39 42
40 build() { 43 build() {
@@ -55,6 +58,22 @@ export struct VideoPlayPage { @@ -55,6 +58,22 @@ export struct VideoPlayPage {
55 this.getTopUIComponent() 58 this.getTopUIComponent()
56 Stack() 59 Stack()
57 .layoutWeight(1) 60 .layoutWeight(1)
  61 + Column(){
  62 + Image($r('app.media.icon_live_player_replay')).width(40).height(40)
  63 + .onClick(() => {
  64 + this.progressVal = 0
  65 + this.isPlayEnd = false
  66 + this.playerController.firstPlay(this.videoUrl)
  67 + })
  68 + Text('重播').fontColor(Color.White).fontSize(14)
  69 + }
  70 + .justifyContent(FlexAlign.Center)
  71 + .backgroundColor("#80000000")
  72 + .width('100%')
  73 + .height('60%')
  74 + .visibility(this.isPlayEnd ? Visibility.Visible : Visibility.None)
  75 + Stack()
  76 + .layoutWeight(1)
58 this.getBottomUIComponent() 77 this.getBottomUIComponent()
59 } 78 }
60 } 79 }
@@ -82,43 +101,42 @@ export struct VideoPlayPage { @@ -82,43 +101,42 @@ export struct VideoPlayPage {
82 .alignItems(VerticalAlign.Center) 101 .alignItems(VerticalAlign.Center)
83 .margin({ top: `${this.topSafeHeight}px` }) 102 .margin({ top: `${this.topSafeHeight}px` })
84 }.width('100%') 103 }.width('100%')
85 - // .padding({  
86 - // top: 20,  
87 - // bottom: 6,  
88 - // left: 10,  
89 - // right: 10  
90 - // })  
91 .alignItems(HorizontalAlign.Start) 104 .alignItems(HorizontalAlign.Start)
92 } 105 }
93 106
94 @Builder 107 @Builder
95 getBottomUIComponent() { 108 getBottomUIComponent() {
96 - Row() {  
97 - this.playOrPauseBtn()  
98 - Text(this.currentTime)  
99 - .fontColor(Color.White)  
100 - .fontWeight(600)  
101 - .fontSize('12fp')  
102 - .margin({  
103 - left: 16  
104 - })  
105 - this.playProgressView()  
106 - Text(this.totalTime)  
107 - .fontColor(Color.White)  
108 - .fontWeight(600)  
109 - .fontSize('12fp')  
110 - .margin({  
111 - right: 16  
112 - }) 109 + Column(){
  110 + Row() {
  111 + this.playOrPauseBtn()
  112 + Text(this.currentTime)
  113 + .fontColor(Color.White)
  114 + .fontWeight(600)
  115 + .fontSize('12fp')
  116 + .margin({
  117 + left: 16
  118 + })
  119 + this.playProgressView()
  120 + Text(this.totalTime)
  121 + .fontColor(Color.White)
  122 + .fontWeight(600)
  123 + .fontSize('12fp')
  124 + .margin({
  125 + right: 16
  126 + })
  127 + }
  128 + .alignItems(VerticalAlign.Center)
  129 + .height(40)
  130 + .width('100%')
  131 + .visibility(this.isPlayEnd ? Visibility.None:Visibility.Visible)
  132 + .padding({
  133 + left: 10,
  134 + right: 10,
  135 + })
113 } 136 }
114 - .alignItems(VerticalAlign.Center) 137 + .align(Alignment.Top)
  138 + .height(64)
115 .width('100%') 139 .width('100%')
116 - .padding({  
117 - left: 10,  
118 - right: 10,  
119 - top: 15,  
120 - bottom: 15  
121 - })  
122 } 140 }
123 141
124 @Builder 142 @Builder