Showing
6 changed files
with
64 additions
and
56 deletions
| @@ -546,45 +546,45 @@ export struct TopNavigationComponent { | @@ -546,45 +546,45 @@ export struct TopNavigationComponent { | ||
| 546 | return null | 546 | return null |
| 547 | } | 547 | } |
| 548 | 548 | ||
| 549 | - private getTextInfo(index: number): Record<string, number> { | ||
| 550 | - let strJson = getInspectorByKey(index.toString()) | ||
| 551 | - try { | ||
| 552 | - let obj: Record<string, string> = JSON.parse(strJson) | ||
| 553 | - let rectInfo: number[][] = JSON.parse('[' + obj.$rect + ']') | ||
| 554 | - return { 'left': px2vp(rectInfo[0][0]), 'width': px2vp(rectInfo[1][0] - rectInfo[0][0]) } | ||
| 555 | - } catch (error) { | ||
| 556 | - return { 'left': 0, 'width': 0 } | ||
| 557 | - } | ||
| 558 | - } | ||
| 559 | - | ||
| 560 | - private getCurrentIndicatorInfo(index: number, event: TabsAnimationEvent): Record<string, number> { | ||
| 561 | - let nextIndex = index | ||
| 562 | - if (index > 0 && event.currentOffset > 0) { | ||
| 563 | - nextIndex-- | ||
| 564 | - } else if (index < 3 && event.currentOffset < 0) { | ||
| 565 | - nextIndex++ | ||
| 566 | - } | ||
| 567 | - let indexInfo = this.getTextInfo(index) | ||
| 568 | - let nextIndexInfo = this.getTextInfo(nextIndex) | ||
| 569 | - let swipeRatio = Math.abs(event.currentOffset / this.tabsWidth) | ||
| 570 | - let currentIndex = swipeRatio > 0.5 ? nextIndex : index // 页面滑动超过一半,tabBar切换到下一页。 | ||
| 571 | - let currentLeft = indexInfo.left + (nextIndexInfo.left - indexInfo.left) * swipeRatio | ||
| 572 | - let currentWidth = indexInfo.width + (nextIndexInfo.width - indexInfo.width) * swipeRatio | ||
| 573 | - return { 'index': currentIndex, 'left': currentLeft, 'width': currentWidth } | ||
| 574 | - } | ||
| 575 | - | ||
| 576 | - private startAnimateTo(duration: number, leftMargin: number, width: number) { | ||
| 577 | - animateTo({ | ||
| 578 | - duration: duration, // 动画时长 | ||
| 579 | - curve: Curve.Linear, // 动画曲线 | ||
| 580 | - iterations: 1, // 播放次数 | ||
| 581 | - playMode: PlayMode.Normal, // 动画模式 | ||
| 582 | - onFinish: () => { | ||
| 583 | - console.info('play end') | ||
| 584 | - } | ||
| 585 | - }, () => { | ||
| 586 | - this.indicatorLeftMargin = leftMargin | ||
| 587 | - this.indicatorWidth = width | ||
| 588 | - }) | ||
| 589 | - } | 549 | + // private getTextInfo(index: number): Record<string, number> { |
| 550 | + // let strJson = getInspectorByKey(index.toString()) | ||
| 551 | + // try { | ||
| 552 | + // let obj: Record<string, string> = JSON.parse(strJson) | ||
| 553 | + // let rectInfo: number[][] = JSON.parse('[' + obj.$rect + ']') | ||
| 554 | + // return { 'left': px2vp(rectInfo[0][0]), 'width': px2vp(rectInfo[1][0] - rectInfo[0][0]) } | ||
| 555 | + // } catch (error) { | ||
| 556 | + // return { 'left': 0, 'width': 0 } | ||
| 557 | + // } | ||
| 558 | + // } | ||
| 559 | + // | ||
| 560 | + // private getCurrentIndicatorInfo(index: number, event: TabsAnimationEvent): Record<string, number> { | ||
| 561 | + // let nextIndex = index | ||
| 562 | + // if (index > 0 && event.currentOffset > 0) { | ||
| 563 | + // nextIndex-- | ||
| 564 | + // } else if (index < 3 && event.currentOffset < 0) { | ||
| 565 | + // nextIndex++ | ||
| 566 | + // } | ||
| 567 | + // let indexInfo = this.getTextInfo(index) | ||
| 568 | + // let nextIndexInfo = this.getTextInfo(nextIndex) | ||
| 569 | + // let swipeRatio = Math.abs(event.currentOffset / this.tabsWidth) | ||
| 570 | + // let currentIndex = swipeRatio > 0.5 ? nextIndex : index // 页面滑动超过一半,tabBar切换到下一页。 | ||
| 571 | + // let currentLeft = indexInfo.left + (nextIndexInfo.left - indexInfo.left) * swipeRatio | ||
| 572 | + // let currentWidth = indexInfo.width + (nextIndexInfo.width - indexInfo.width) * swipeRatio | ||
| 573 | + // return { 'index': currentIndex, 'left': currentLeft, 'width': currentWidth } | ||
| 574 | + // } | ||
| 575 | + | ||
| 576 | + // private startAnimateTo(duration: number, leftMargin: number, width: number) { | ||
| 577 | + // animateTo({ | ||
| 578 | + // duration: duration, // 动画时长 | ||
| 579 | + // curve: Curve.Linear, // 动画曲线 | ||
| 580 | + // iterations: 1, // 播放次数 | ||
| 581 | + // playMode: PlayMode.Normal, // 动画模式 | ||
| 582 | + // onFinish: () => { | ||
| 583 | + // console.info('play end') | ||
| 584 | + // } | ||
| 585 | + // }, () => { | ||
| 586 | + // this.indicatorLeftMargin = leftMargin | ||
| 587 | + // this.indicatorWidth = width | ||
| 588 | + // }) | ||
| 589 | + // } | ||
| 590 | } | 590 | } |
| @@ -83,23 +83,30 @@ export struct DetailPlayLiveCommon { | @@ -83,23 +83,30 @@ export struct DetailPlayLiveCommon { | ||
| 83 | * 获取直播信息,可区分横竖屏直播 | 83 | * 获取直播信息,可区分横竖屏直播 |
| 84 | */ | 84 | */ |
| 85 | getLiveDetails() { | 85 | getLiveDetails() { |
| 86 | + | ||
| 87 | + | ||
| 86 | this.liveViewModel.getLiveDetails(this.contentId, this.relId, this.relType) | 88 | this.liveViewModel.getLiveDetails(this.contentId, this.relId, this.relType) |
| 87 | .then( | 89 | .then( |
| 88 | (data) => { | 90 | (data) => { |
| 89 | if (data.length > 0) { | 91 | if (data.length > 0) { |
| 92 | + | ||
| 93 | + //todo 不加setTimeOut ,接口返回的数据 就没法让PlayerComponent #@Consume @Watch('updateData') liveDetailsBean 的updateData方法运行 | ||
| 94 | + setTimeout(() => { | ||
| 90 | this.liveDetailsBean = data[0] | 95 | this.liveDetailsBean = data[0] |
| 91 | - this.liveState = this.liveDetailsBean.liveInfo?.liveState | ||
| 92 | - this.liveStyle = this.liveDetailsBean.liveInfo.liveStyle | 96 | + }, 10) |
| 97 | + | ||
| 98 | + this.liveState = data[0].liveInfo?.liveState | ||
| 99 | + this.liveStyle = data[0].liveInfo.liveStyle | ||
| 93 | 100 | ||
| 94 | - if (this.liveDetailsBean.fullColumnImgUrls && this.liveDetailsBean.fullColumnImgUrls.length > 0) { | ||
| 95 | - this.imgUrl = this.liveDetailsBean.fullColumnImgUrls[0].url | 101 | + if (data[0].fullColumnImgUrls && data[0].fullColumnImgUrls.length > 0) { |
| 102 | + this.imgUrl = data[0].fullColumnImgUrls[0].url | ||
| 96 | } | 103 | } |
| 97 | 104 | ||
| 98 | - if (this.liveDetailsBean.liveInfo.liveState == 'end') { | ||
| 99 | - this.playUrl = this.liveDetailsBean.liveInfo.vlive[0].replayUri | 105 | + if (data[0].liveInfo.liveState == 'end') { |
| 106 | + this.playUrl = data[0].liveInfo.vlive[0].replayUri | ||
| 100 | } | 107 | } |
| 101 | 108 | ||
| 102 | - console.log(TAG, 'getLiveDetails:', JSON.stringify((this.liveDetailsBean))) | 109 | + // console.log(TAG, 'getLiveDetails:', JSON.stringify((this.liveDetailsBean))) |
| 103 | } | 110 | } |
| 104 | }, | 111 | }, |
| 105 | () => { | 112 | () => { |
| @@ -36,6 +36,7 @@ export struct DetailPlayVLivePage { | @@ -36,6 +36,7 @@ export struct DetailPlayVLivePage { | ||
| 36 | aboutToAppear(): void { | 36 | aboutToAppear(): void { |
| 37 | this.openFullScreen() | 37 | this.openFullScreen() |
| 38 | this.getLiveRoomData() | 38 | this.getLiveRoomData() |
| 39 | + | ||
| 39 | } | 40 | } |
| 40 | 41 | ||
| 41 | aboutToDisappear(): void { | 42 | aboutToDisappear(): void { |
| @@ -21,6 +21,7 @@ export struct PlayerComponent { | @@ -21,6 +21,7 @@ export struct PlayerComponent { | ||
| 21 | @State playUrl: string = '' | 21 | @State playUrl: string = '' |
| 22 | @State isCanplay: boolean = false | 22 | @State isCanplay: boolean = false |
| 23 | 23 | ||
| 24 | + | ||
| 24 | pageShowChange() { | 25 | pageShowChange() { |
| 25 | this.playerController?.play() | 26 | this.playerController?.play() |
| 26 | } | 27 | } |
| @@ -30,15 +31,10 @@ export struct PlayerComponent { | @@ -30,15 +31,10 @@ export struct PlayerComponent { | ||
| 30 | } | 31 | } |
| 31 | 32 | ||
| 32 | aboutToAppear(): void { | 33 | aboutToAppear(): void { |
| 33 | - console.log(TAG, 'aboutToAppear') | ||
| 34 | - this.playerController.onCanplay = () => { | ||
| 35 | - console.log('可以播放了') | ||
| 36 | - this.playerController?.play() | ||
| 37 | - this.isCanplay = true | ||
| 38 | - } | ||
| 39 | } | 34 | } |
| 40 | 35 | ||
| 41 | async aboutToDisappear(): Promise<void> { | 36 | async aboutToDisappear(): Promise<void> { |
| 37 | + | ||
| 42 | await this.playerController?.pause() | 38 | await this.playerController?.pause() |
| 43 | await this.playerController?.stop() | 39 | await this.playerController?.stop() |
| 44 | await this.playerController?.release() | 40 | await this.playerController?.release() |
| @@ -63,7 +59,6 @@ export struct PlayerComponent { | @@ -63,7 +59,6 @@ export struct PlayerComponent { | ||
| 63 | 59 | ||
| 64 | this.liveStreamType = liveStreamType | 60 | this.liveStreamType = liveStreamType |
| 65 | this.playUrl = playUrl | 61 | this.playUrl = playUrl |
| 66 | - | ||
| 67 | } | 62 | } |
| 68 | } | 63 | } |
| 69 | 64 | ||
| @@ -75,6 +70,7 @@ export struct PlayerComponent { | @@ -75,6 +70,7 @@ export struct PlayerComponent { | ||
| 75 | WDPlayerRenderVLiveView({ | 70 | WDPlayerRenderVLiveView({ |
| 76 | playerController: this.playerController, | 71 | playerController: this.playerController, |
| 77 | onLoad: () => { | 72 | onLoad: () => { |
| 73 | + this.isCanplay = true | ||
| 78 | this.playerController?.firstPlay(this.playUrl); | 74 | this.playerController?.firstPlay(this.playUrl); |
| 79 | } | 75 | } |
| 80 | }) | 76 | }) |
| @@ -82,12 +78,14 @@ export struct PlayerComponent { | @@ -82,12 +78,14 @@ export struct PlayerComponent { | ||
| 82 | AliPlayerRenderView({ | 78 | AliPlayerRenderView({ |
| 83 | playerController: this.playerController, | 79 | playerController: this.playerController, |
| 84 | onLoad: () => { | 80 | onLoad: () => { |
| 81 | + this.isCanplay = true | ||
| 85 | this.playerController?.firstPlay(this.playUrl); | 82 | this.playerController?.firstPlay(this.playUrl); |
| 86 | } | 83 | } |
| 87 | }).margin({ top: 195 }).height(211) | 84 | }).margin({ top: 195 }).height(211) |
| 88 | } | 85 | } |
| 89 | 86 | ||
| 90 | PictureLoading().visibility(this.isCanplay ? Visibility.None : Visibility.Visible) | 87 | PictureLoading().visibility(this.isCanplay ? Visibility.None : Visibility.Visible) |
| 88 | + | ||
| 91 | } | 89 | } |
| 92 | .height('100%') | 90 | .height('100%') |
| 93 | .width('100%') | 91 | .width('100%') |
| @@ -98,8 +96,11 @@ export struct PlayerComponent { | @@ -98,8 +96,11 @@ export struct PlayerComponent { | ||
| 98 | this.isShowControl = !this.isShowControl | 96 | this.isShowControl = !this.isShowControl |
| 99 | } | 97 | } |
| 100 | }) | 98 | }) |
| 99 | + | ||
| 101 | } | 100 | } |
| 102 | .height('100%') | 101 | .height('100%') |
| 103 | .width('100%') | 102 | .width('100%') |
| 104 | } | 103 | } |
| 104 | + | ||
| 105 | + | ||
| 105 | } | 106 | } |
| @@ -137,7 +137,6 @@ export class WDAliPlayerController { | @@ -137,7 +137,6 @@ export class WDAliPlayerController { | ||
| 137 | onStateChanged: (status: number) => { | 137 | onStateChanged: (status: number) => { |
| 138 | this.avPlayerStatus = status | 138 | this.avPlayerStatus = status |
| 139 | Logger.debug(TAG, "status update:" + `${this.getStatusStringWith(status)}`) | 139 | Logger.debug(TAG, "status update:" + `${this.getStatusStringWith(status)}`) |
| 140 | - | ||
| 141 | switch (status) { | 140 | switch (status) { |
| 142 | case initalized: { | 141 | case initalized: { |
| 143 | //this.avPlayer?.prepare(); | 142 | //this.avPlayer?.prepare(); |
-
Please register or login to post a comment