zhenghy

fix: 修改视频播放器

... ... @@ -49,6 +49,10 @@ export { NewspaperTimeItemBean } from './src/main/ets/bean/newspaper/NewspaperTi
export { ContentDetailDTO } from './src/main/ets/bean/detail/ContentDetailDTO';
export { RmhInfoDTO } from './src/main/ets/bean/detail/RmhInfoDTO';
export { UserInfoDTO } from './src/main/ets/bean/detail/UserInfoDTO';
export { AuthorListDTO } from './src/main/ets/bean/detail/AuthorListDTO';
export { FullColumnImgUrlDTO } from './src/main/ets/bean/detail/FullColumnImgUrlDTO';
... ...
... ... @@ -3,6 +3,8 @@ import { FullColumnImgUrlDTO } from './FullColumnImgUrlDTO';
import { ReLInfoDTO } from './ReLInfoDTO';
import { ShareInfoDTO } from './ShareInfoDTO';
import { VideoInfoDTO } from './VideoInfoDTO';
import { RmhInfoDTO } from './RmhInfoDTO'
import { UserInfoDTO } from './UserInfoDTO'
/**
* 接口定义:
... ... @@ -40,8 +42,8 @@ export interface ContentDetailDTO {
videoInfo: VideoInfoDTO[];
liveInfo?: any;
voteInfo?: any;
rmhInfo?: any;
userInfo?: any;
rmhInfo?: RmhInfoDTO;
userInfo?: UserInfoDTO;
openLikes: number;
openComment: number;
likesStyle: number;
... ...
export interface RmhInfoDTO {
authIcon: string;
authTitle: string;
authTitle2: string;
banControl: number;
cnAttention: number;
cnMainControl: number;
cnShareControl: number;
cnlsComment: number;
cnlsLike: number;
posterShareControl: number;
rmhDesc: string;
rmhHeadUrl: string;
rmhId: string;
rmhName: string;
userId: string;
userType: string;
}
... ...
export interface UserInfoDTO {
userHeadUrl:string
}
... ...
import router from '@ohos.router';
import mediaquery from '@ohos.mediaquery';
import window from '@ohos.window';
import { Action } from 'wdBean';
import { Action, RmhInfoDTO, UserInfoDTO } from 'wdBean';
import { Logger, SPHelper, WindowModel } from 'wdKit';
import { PlayerConstants, WDPlayerController, WDPlayerRenderView } from 'wdPlayer';
import { devicePLSensorManager } from 'wdDetailPlayApi';
... ... @@ -30,27 +30,34 @@ export struct DetailPlayShortVideoPage {
@Provide canStart?: boolean = false;
@Provide status: number = PlayerConstants.STATUS_START;
@Provide userId: string = '';
@Provide newsSourceName?: string = undefined
@Provide title?: string = undefined
@Provide message?: string = undefined
@Provide newsSummary?: string = undefined
@Provide newsSourceName?: string = ''
@Provide newsTitle?: string = ''
@Provide editorName?: string = ''
@Provide rmhInfo?: RmhInfoDTO = undefined
@Provide userInfo?: UserInfoDTO = undefined
@Provide message?: string = ''
@Provide newsSummary?: string = ''
@Provide progressVal: number = 0;
@Provide videoLandScape?: number = 1; // 视频朝向, 横屏视频:1;竖屏视频:2
playVMChanged(name: string) {
this.url = this.playVM.url
this.newsSourceName = this.playVM.newsSourceName
this.title = this.playVM.title
this.newsTitle = this.playVM.newsTitle
this.editorName = this.playVM.editorName
this.newsSummary = this.playVM.newsSummary
this.videoLandScape = this.playVM.videoLandScape ?? 1
this.curContId = this.playVM.contentId
this.nextContId = this.playVM.nextContId
this.canStart = this.playVM.canStart;
this.message = this.playVM.message
this.rmhInfo = this.playVM.rmhInfo
this.userInfo = this.playVM.userInfo
}
aboutToAppear() {
let action: Action = router.getParams() as Action
Logger.info(TAG, "action", JSON.stringify(action))
if (action) {
this.contentId = action.params?.contentID
if (action.params && action.params.extra) {
... ... @@ -86,11 +93,12 @@ export struct DetailPlayShortVideoPage {
}
@Builder
playerViewContainer() {
playerViewContainerBuilder() {
// 播放窗口
WDPlayerRenderView({
playerController: this.playerController,
onLoad: async () => {
console.log('onload==')
// this.playVM.playWithContentId(this.contentId ?? "846899373")
this.playVM.playWithIds(this.contentId ?? "846899373",
this.relId ?? "500000301942", this.relType ?? "1")
... ... @@ -101,7 +109,7 @@ export struct DetailPlayShortVideoPage {
}
@Builder
playControlViewContainer() {
playControlViewContainerBuilder() {
// 播放窗口控制bar
PlayControlViewContainer({
playerController: this.playerController
... ... @@ -109,7 +117,7 @@ export struct DetailPlayShortVideoPage {
}
@Builder
detailContainer() {
detailContainerBuilder() {
// DetailTabBarPageComponent({ pageId: this.pageId }).backgroundColor(Color.Black)
DetailContainer({
playerController: this.playerController
... ... @@ -118,13 +126,15 @@ export struct DetailPlayShortVideoPage {
build() {
Row() {
PlayerDetailContainer({ playerView: () => {
this.playerViewContainer()
}, playControlView: () => {
this.playControlViewContainer()
}, detailView: () => {
this.detailContainer()
} })
PlayerDetailContainer({
playerView: () => {
this.playerViewContainerBuilder()
}, playControlView: () => {
this.playControlViewContainerBuilder()
}, detailView: () => {
this.detailContainerBuilder()
}
})
.height('100%')
.width('100%')
}
... ...
import { RmhInfoDTO, UserInfoDTO } from 'wdBean/Index';
import { ToastUtils } from 'wdKit';
export interface OperationItem {
... ... @@ -12,13 +13,14 @@ const FULL_PARENT: string = '100%';
const TAG = 'OperationListView';
@Entry
@Component
export struct OperationListView {
@Consume rmhInfo?: RmhInfoDTO
@Consume userInfo?: UserInfoDTO
@State operationList: OperationItem[] = [
{
icon: $r('app.media.ic_like_uncheck'),
text: "赞",
text: "赞",
num: 6622
},
{
... ... @@ -62,6 +64,7 @@ export struct OperationListView {
// })
Column() {
this.buildUserComp()
ForEach(this.operationList, (item: OperationItem, index: number) => {
this.buildOperationItem(item, index)
}, (item: OperationItem, index: number) => JSON.stringify(item))
... ... @@ -69,6 +72,17 @@ export struct OperationListView {
.width(48)
}
@Builder
buildUserComp() {
Column() {
Image(this.rmhInfo?.rmhHeadUrl || this.userInfo?.userHeadUrl)
.width(48)
.borderRadius(24)
.aspectRatio(1)
// .margin(18)
}
}
/**
* 组件项
*
... ... @@ -97,7 +111,7 @@ export struct OperationListView {
.hoverEffect(HoverEffect.Scale)
.onClick((event: ClickEvent) => {
console.info(TAG, `buildOperationItem onClick event index: ${index}`);
ToastUtils.showToast('体验版,本功能暂未开发', 1000);
// ToastUtils.showToast('体验版,本功能暂未开发', 1000);
})
}
}
\ No newline at end of file
... ...
... ... @@ -103,12 +103,17 @@ export struct PlayControlViewContainer {
.height('100%')
.width('100%')
.zIndex(1)
.gesture(TapGesture({ count: 2 })
.gesture(TapGesture({ count: 1 })
.onAction((event: GestureEvent) => {
let curStatus = (this.status === PlayerConstants.STATUS_START);
this.status = curStatus ? PlayerConstants.STATUS_PAUSE : PlayerConstants.STATUS_START;
this.playerController?.switchPlayOrPause();
}))
.gesture(TapGesture({ count: 2 })
.onAction((event: GestureEvent) => {
// TODO 双击点赞|收藏
}))
Row() {
Image($r('app.media.ic_volume'))
... ...
... ... @@ -8,7 +8,7 @@ import { devicePLSensorManager } from 'wdDetailPlayApi';
@Component
export struct PlayerTitle {
private playerController?: WDPlayerController;
@Consume title?: string
@Consume newsTitle?: string
@Consume isFullScreen: boolean;
@State @Watch('watchSpeed') playSpeed: number = 1;
... ... @@ -46,7 +46,7 @@ export struct PlayerTitle {
router.back();
}
})
Text(this.title)
Text(this.newsTitle)
.fontColor(Color.White)
.fontSize('14fp')
.maxLines(2)
... ...
... ... @@ -5,12 +5,14 @@ import { WindowModel } from 'wdKit';
import { WDPlayerController } from 'wdPlayer';
import { devicePLSensorManager } from 'wdDetailPlayApi';
import { OperationListView } from './OperationListView';
import { RmhInfoDTO, UserInfoDTO } from 'wdBean/Index';
@Component
export struct PlayerTitleComment {
private playerController?: WDPlayerController;
@Consume newsSourceName?: string
@Consume title?: string
@Consume newsTitle?: string
@Consume editorName?: string
@Consume newsSummary?: string;
@State @Watch('watchSpeed') playSpeed: number = 1;
@Consume isFullScreen: boolean;
... ... @@ -57,15 +59,15 @@ export struct PlayerTitleComment {
Row() {
Column() {
if (this.newsSourceName) {
Text("@" + this.newsSourceName)
if (this.newsSourceName || this.editorName) {
Text("@" + (this.newsSourceName || this.editorName))
.fontColor(Color.White)
.fontSize(15)
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
}
if (this.newsSummary) {
Text(this.newsSummary)
if (this.newsTitle || this.newsSummary) {
Text(this.newsTitle || this.newsSummary)
.fontColor(Color.White)
.fontSize(15)
.maxLines(3)
... ... @@ -80,6 +82,7 @@ export struct PlayerTitleComment {
}
.layoutWeight(1)
.alignItems(HorizontalAlign.Start)
.margin({ left: 16 })
OperationListView()
.width(48)
... ... @@ -135,6 +138,8 @@ export struct PlayerTitleComment {
.fontSize(14)
.maxLines(1)
.layoutWeight(1)
.backgroundColor('#ccc')
.borderRadius(2)
}.alignItems(VerticalAlign.Center)
}
.width('100%')
... ...
... ... @@ -2,7 +2,7 @@ import { BusinessError } from '@ohos.base'
import { Logger, ToastUtils } from 'wdKit'
import { ResponseDTO } from 'wdNetwork'
import { ContentDetailRequest } from 'wdDetailPlayApi'
import { ContentDetailDTO } from 'wdBean'
import { ContentDetailDTO, RmhInfoDTO, UserInfoDTO } from 'wdBean'
const TAG = 'PlayViewModel';
... ... @@ -12,8 +12,11 @@ export class PlayViewModel {
relId: string
relType: string
newsSourceName?: string
title?: string
newsTitle?: string
editorName?: string
newsSummary?: string
rmhInfo?: RmhInfoDTO
userInfo?: UserInfoDTO
url?: string
// 视频朝向,
// 横屏视频:1(进入竖屏,立即展示半屏播放窗口,当切换横屏时,再展示全部播放窗口;后续可再转换到竖屏):
... ... @@ -59,14 +62,21 @@ export class PlayViewModel {
Logger.error(TAG, `getContentDetailData then body is empty`);
return
}
let contentDetailDTO: ContentDetailDTO = resDTO.data[0]
this.newsSourceName = contentDetailDTO.newsSourceName
this.title = contentDetailDTO.newsTitle
Logger.info(TAG, JSON.stringify(contentDetailDTO))
this.newsTitle = contentDetailDTO.newsTitle
this.editorName = contentDetailDTO.editorName
this.newsSummary = contentDetailDTO.newsSummary
this.userInfo = contentDetailDTO.userInfo
this.rmhInfo = contentDetailDTO.rmhInfo
if (contentDetailDTO.videoInfo?.length > 0) {
this.url = contentDetailDTO.videoInfo[0].videoUrl
this.videoLandScape = contentDetailDTO.videoInfo[0].videoLandScape
}
if (contentDetailDTO.authorList?.length > 0) {
this.newsSourceName = contentDetailDTO.authorList[0].authorName
}
this.canStart = true;
this.message = '';
}).catch((err: BusinessError) => {
... ...
@Entry
@Component
struct Test {
@State message: string = 'Hello World';
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
... ...
import componentUtils from '@ohos.arkui.componentUtils';
import { WDPlayerController } from '../controller/WDPlayerController'
import { WindowModel } from 'wdKit';
import { Logger } from '../utils/Logger';
class Size {
width: Length = "100%";
... ... @@ -13,6 +14,7 @@ class Size {
}
let insIndex: number = 0;
const TAG = 'WDPlayerRenderView'
class MGPlayRenderViewIns {
static intCount: number = 0;
... ... @@ -24,7 +26,7 @@ class MGPlayRenderViewIns {
}
static del() {
console.log("add-- -1")
console.log("del-- -1")
MGPlayRenderViewIns.intCount--;
if (MGPlayRenderViewIns.intCount <= 0) {
WindowModel.shared.setWindowKeepScreenOn(false);
... ... @@ -35,7 +37,6 @@ class MGPlayRenderViewIns {
/**
* 播放窗口组件
*/
@Entry
@Component
export struct WDPlayerRenderView {
private playerController?: WDPlayerController;
... ... @@ -49,14 +50,15 @@ export struct WDPlayerRenderView {
aboutToAppear() {
MGPlayRenderViewIns.add();
console.log('playerController', this.playerController)
insIndex++;
if (!this.playerController) {
return
}
this.playerController.onVideoSizeChange = (width: number, height: number) => {
// console.log(`WDPlayerRenderView onVideoSizeChange width:${width} videoTop:${height}`)
Logger.info(TAG, ` onVideoSizeChange width:${width} videoTop:${height}`)
this.videoWidth = width;
this.videoHeight = height;
this.updateLayout()
... ... @@ -64,6 +66,7 @@ export struct WDPlayerRenderView {
}
aboutToDisappear() {
Logger.info(TAG, `aboutToDisappear`)
MGPlayRenderViewIns.del();
}
... ... @@ -76,6 +79,7 @@ export struct WDPlayerRenderView {
controller: this.xComponentController
})
.onLoad(async (event) => {
Logger.info(TAG, 'onLoad')
this.xComponentController.setXComponentSurfaceSize({
surfaceWidth: 1920,
surfaceHeight: 1080
... ...
{
"src": [
"pages/WDPlayerRenderView"
"pages/Test"
]
}
}
\ No newline at end of file
... ...