Toggle navigation
Toggle navigation
This project
Loading...
Sign in
developOne
/
harmonyPool
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
陈剑华
2024-06-11 17:34:51 +0800
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
5364528bbde01ac64bdec635306b17df8dbbceed
5364528b
2 parents
21732160
a2439327
Merge remote-tracking branch 'origin/main'
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
86 additions
and
12 deletions
sight_harmony/features/wdDetailPlayShortVideo/src/main/ets/pages/DetailPlayShortVideoPage.ets
sight_harmony/features/wdDetailPlayShortVideo/src/main/ets/pages/DetailVideoListPage.ets
sight_harmony/features/wdDetailPlayShortVideo/src/main/ets/pages/VideoChannelDetail.ets
sight_harmony/features/wdDetailPlayShortVideo/src/main/ets/view/PlayerBottomView.ets
sight_harmony/features/wdDetailPlayShortVideo/src/main/ets/view/PlayerProgressView.ets
sight_harmony/features/wdPlayer/src/main/ets/controller/WDPlayerController.ets
sight_harmony/features/wdDetailPlayShortVideo/src/main/ets/pages/DetailPlayShortVideoPage.ets
View file @
5364528
...
...
@@ -17,6 +17,7 @@ import { componentUtils, window } from '@kit.ArkUI';
import { PlayerFullScreenView } from '../view/PlayerFullScreenView';
import { OperRowListView, publishCommentModel } from 'wdComponent/Index';
import { ParamType, TrackConstants } from 'wdTracking/Index';
import { onlyWifiLoadVideo } from 'wdComponent/src/main/ets/utils/lazyloadImg';
const TAG = 'DetailPlayShortVideoPage';
...
...
@@ -55,6 +56,8 @@ export struct DetailPlayShortVideoPage {
@State playerHeight: number | string = px2vp(this.windowHeight)
pageParam: ParamType = {}
PageName: string = ''
@State toastText: ResourceStr = "正在使用非WI-FI网络,播放将产生流量费用"
@Consume onlyWifiLoadVideo: boolean
/**
* 页面显示重查用户关注、点赞等信息
...
...
@@ -62,7 +65,7 @@ export struct DetailPlayShortVideoPage {
async pageShowChange() {
if (this.currentIndex === this.index) {
this.queryNewsInfoOfUser()
if (this.switchVideoStatus && this.isPlay) {
if (this.switchVideoStatus && this.isPlay
&& this.onlyWifiLoadVideo
) {
await this.playerController.play()
this.imageVisible = false
}
...
...
@@ -75,7 +78,7 @@ export struct DetailPlayShortVideoPage {
*/
async videoStatusChange() {
if (this.currentIndex === this.index) {
if (this.switchVideoStatus && this.isPlay) {
if (this.switchVideoStatus && this.isPlay
&& this.onlyWifiLoadVideo
) {
await this.playerController.play()
this.imageVisible = false
} else {
...
...
@@ -99,9 +102,18 @@ export struct DetailPlayShortVideoPage {
if (!this.playerController.getPlayer()) {
this.playerController.firstPlay(this.contentDetailData?.videoInfo[0]?.videoUrl || '', this.PageName,
this.PageName, this.pageParam);
this.playerController.onCanplay = async () => {
this.ratio = this.playerController.videoWidth / this.playerController.videoHeight
await this.playerController.play()
this.imageVisible = false
}
} else {
await this.playerController.play()
this.imageVisible = false
if (!this.onlyWifiLoadVideo) {
await this.playerController.pause()
} else {
await this.playerController.play()
this.imageVisible = false
}
}
}
}
...
...
@@ -156,15 +168,22 @@ export struct DetailPlayShortVideoPage {
}
aboutToAppear() {
async aboutToAppear() {
if(await onlyWifiLoadVideo()){
this.onlyWifiLoadVideo = true
}
this.videoLandScape = this.contentDetailData.videoInfo[0]?.videoLandScape
this.ratio = (this.contentDetailData.videoInfo[0]?.resolutionWidth || 16) /
(this.contentDetailData.videoInfo[0]?.resolutionHeight || 9)
this.playerController.onCanplay = async () => {
this.ratio = this.playerController.videoWidth / this.playerController.videoHeight
if ((this.index == 0 || this.currentIndex === this.index) && this.switchVideoStatus) {
await this.playerController.play()
this.imageVisible = false
if (!this.onlyWifiLoadVideo) {
await this.playerController.pause()
} else {
await this.playerController.play()
this.imageVisible = false
}
}
}
this.playerController.onTimeUpdate = (position, duration) => {
...
...
@@ -261,6 +280,10 @@ export struct DetailPlayShortVideoPage {
playerController: this.playerController
})
if (!this.onlyWifiLoadVideo) {
this.buildContent()
}
}
.width('100%')
.layoutWeight(1)
...
...
@@ -303,6 +326,51 @@ export struct DetailPlayShortVideoPage {
}
@Builder
buildContent() {
Row() {
Column(){
Column(){
Text(this.toastText)
.fontFamily('PingFang SC-Regular')
.fontWeight(FontWeight.Regular)
.fontColor('#FFFFFF')
.fontSize(14)
.lineHeight(20)
.textAlign(TextAlign.Center)
}
Column() {
Text("使用流量播放")
.fontFamily('PingFang SC-Regular')
.fontWeight(FontWeight.Regular)
.fontColor(Color.White)
.fontSize(12)
}
.border({ width: 1, color: '#4DFFFFFF', radius: 4 })
.height(28)
.width(88)
.alignItems(HorizontalAlign.Center)
.justifyContent(FlexAlign.Center)
.margin({
top: 16
})
.onClick(() => {
this.onlyWifiLoadVideo = true
this.playerController?.play()
this.imageVisible = false
})
}
.width('100%')
.height(64)
}
.width('100%')
.height('100%')
.alignItems(VerticalAlign.Center)
.justifyContent(FlexAlign.Center)
.backgroundColor('#222222')
.opacity(0.7)
}
/**
* 视频首帧图,用于快速显示
* 竖屏封面顶部仍然有点偏移,待处理
...
...
sight_harmony/features/wdDetailPlayShortVideo/src/main/ets/pages/DetailVideoListPage.ets
View file @
5364528
...
...
@@ -39,6 +39,7 @@ export struct DetailVideoListPage {
@State interactDataList: InteractDataDTO[] = []
pageShowTime:number = 0;
pageHideTime:number = 0;
@Provide onlyWifiLoadVideo: boolean = false
async aboutToAppear(): Promise<void> {
// 注册监听网络连接
...
...
sight_harmony/features/wdDetailPlayShortVideo/src/main/ets/pages/VideoChannelDetail.ets
View file @
5364528
...
...
@@ -9,12 +9,11 @@ import {
contentListParams,
getRecCompInfoParams
} from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest';
import { Logger, WindowModel } from 'wdKit/Index';
import { Logger, WindowModel
, DateTimeUtils
} from 'wdKit/Index';
import { PictureLoading } from './PictureLoading';
import { DisplayDirection } from 'wdConstant/Index';
import { window } from '@kit.ArkUI';
import { EmptyComponent, WDViewDefaultType } from 'wdComponent/Index';
import { DateTimeUtils } from 'wdKit/Index';
import { TrackConstants, TrackingPageBrowse } from 'wdTracking/Index';
interface loadMoreData {
...
...
@@ -65,6 +64,7 @@ export struct VideoChannelDetail {
@State isRequesting: boolean = false
pageShowTime: number = 0;
pageHideTime: number = 0;
@Provide onlyWifiLoadVideo: boolean = false
autoRefreshChange() {
if (this.topNavIndex === 0 && !this.isRequesting) {
...
...
sight_harmony/features/wdDetailPlayShortVideo/src/main/ets/view/PlayerBottomView.ets
View file @
5364528
...
...
@@ -13,6 +13,7 @@ export struct PlayerBottomView {
@Consume isDragging?: boolean
@Consume contentDetailData: ContentDetailDTO
@Consume displayDirection: DisplayDirection
@Consume onlyWifiLoadVideo: boolean
aboutToAppear(): void {
...
...
sight_harmony/features/wdDetailPlayShortVideo/src/main/ets/view/PlayerProgressView.ets
View file @
5364528
...
...
@@ -14,6 +14,7 @@ export struct PlayerProgressView {
@State loadingTop: number = 10
@State loadingWidth: number | string = 1
@State showLoading: boolean = false
@Consume onlyWifiLoadVideo: boolean
aboutToAppear() {
if (this.playerController) {
this.playerController.onStatusChange = (status: number) => {
...
...
@@ -26,7 +27,9 @@ export struct PlayerProgressView {
this.playerController.onLoaded = (loaded: number) => {
if(loaded == 1) {
this.loadingWidth = '95%'
this.showLoading = true
if (this.onlyWifiLoadVideo) {
this.showLoading = true
}
} else {
this.loadingWidth = 1
this.showLoading = false
...
...
sight_harmony/features/wdPlayer/src/main/ets/controller/WDPlayerController.ets
View file @
5364528
...
...
@@ -14,7 +14,7 @@ interface obj {
@Observed
export class WDPlayerController {
private initPromise: Promise<void>;
private avPlayer?: media.AVPlayer;
private avPlayer?: media.AVPlayer
| null
;
private duration: number = 0;
private status: number = PlayerConstants.STATUS_IDLE;
private loop: boolean = true;
...
...
@@ -196,6 +196,7 @@ export class WDPlayerController {
}
if (this.avPlayer == null) {
console.log("等待")
this.initPromise = this.createAVPlayer();
await this.initPromise;
} else {
if (this.avPlayer.state != AVPlayerStatus.IDLE) {
...
...
@@ -225,7 +226,7 @@ export class WDPlayerController {
return
}
this.avPlayer.release()
this.avPlayer =
undefined
this.avPlayer =
null
}
...
...
Please
register
or
login
to post a comment