wangliang_wd

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

... ... @@ -19,7 +19,7 @@ export struct VideoPlayPage {
@State totalTime: string = ''
@State progressVal: number = 0;
@Provide topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0
@State isPlayEnd: boolean = false
aboutToAppear(): void {
let par: Action = router.getParams() as Action
... ... @@ -35,6 +35,9 @@ export struct VideoPlayPage {
this.playerController.onCanplay = () => {
this.playerController.play()
}
this.playerController.onStatusChange = (status: number) =>{
this.isPlayEnd = status === 5 ? true:false
}
}
build() {
... ... @@ -55,6 +58,22 @@ export struct VideoPlayPage {
this.getTopUIComponent()
Stack()
.layoutWeight(1)
Column(){
Image($r('app.media.icon_live_player_replay')).width(40).height(40)
.onClick(() => {
this.progressVal = 0
this.isPlayEnd = false
this.playerController.firstPlay(this.videoUrl)
})
Text('重播').fontColor(Color.White).fontSize(14)
}
.justifyContent(FlexAlign.Center)
.backgroundColor("#80000000")
.width('100%')
.height('60%')
.visibility(this.isPlayEnd ? Visibility.Visible : Visibility.None)
Stack()
.layoutWeight(1)
this.getBottomUIComponent()
}
}
... ... @@ -82,17 +101,12 @@ export struct VideoPlayPage {
.alignItems(VerticalAlign.Center)
.margin({ top: `${this.topSafeHeight}px` })
}.width('100%')
// .padding({
// top: 20,
// bottom: 6,
// left: 10,
// right: 10
// })
.alignItems(HorizontalAlign.Start)
}
@Builder
getBottomUIComponent() {
Column(){
Row() {
this.playOrPauseBtn()
Text(this.currentTime)
... ... @@ -112,14 +126,18 @@ export struct VideoPlayPage {
})
}
.alignItems(VerticalAlign.Center)
.height(40)
.width('100%')
.visibility(this.isPlayEnd ? Visibility.None:Visibility.Visible)
.padding({
left: 10,
right: 10,
top: 15,
bottom: 15
})
}
.align(Alignment.Top)
.height(64)
.width('100%')
}
@Builder
playOrPauseBtn() {
... ...