zhenghy
Committed by yangchenggong1_wd

播放器修改

... ... @@ -26,7 +26,6 @@ export class HttpUrlUtils {
* 启动接口(底导接口)
*/
static readonly BOTTOM_NAV_PATH: string = "/api/rmrb-bff-display-zh/display/zh/c/bottomNavGroup";
/**
* 展现pageInfo接口
*/
... ... @@ -42,24 +41,24 @@ export class HttpUrlUtils {
/**
* 批查接口,查询互动相关数据,如收藏数、评论数等
*/
static readonly INTERACT_DATA_PATH: string = "/api/rmrb-contact/contact/zh/c/content/interactData";
static readonly INTERACT_DATA_PATH: string = "/api/rmrb-contact/contact/zh/c/v2/content/interactData";
// 多图(图集)详情页
/**
* 批量查询内容当前用户点赞、收藏状态
*/
static readonly INTERACT_DATA_STATUS: string = "/api/rmrb-interact/interact/zh/c/batchLikeAndCollect/status";
/**
* 沉浸式視頻批量查詢20條數據
*/
static readonly RECOMMEND_VIDEOLIST: string = "/api/rmrb-bff-display-zh/recommend/zh/c/videoList";
/**
* 浏览历史新增、删除接口
*/
static readonly INTERACT_BROWS_OPERATE: string = "/api/rmrb-interact/interact/zh/c/brows/operate";
/**
* 电子报信息
*/
static readonly E_NEWSPAPER_INFO_PATH: string = "/api/rmrb-bff-display-zh/display/zh/c/paperApi/paperTime";
/**
* 电子报列表
*/
... ... @@ -77,7 +76,7 @@ export class HttpUrlUtils {
*/
static readonly APPOINTMENT_QueryUserDetail_PATH: string = "/api/rmrb-user-center/user/zh/c/queryUserDetail";
/**
/**
/**
* 个人中心 关注列表详情
*/
static readonly FOLLOW_LIST_DETAIL_DATA_PATH: string = "/api/rmrb-creator-user/c/creatorDirectory/getContactMasterDetaiPage";
... ... @@ -101,22 +100,18 @@ export class HttpUrlUtils {
* 我的收藏
*/
static readonly APPOINTMENT_MyCollectionList_PATH: string = "/api/rmrb-interact/content/zh/c/interact";
/**
* 个人中心 我的评论列表
*/
static readonly MINE_COMMENT_LIST_DATA_PATH: string = "/api/rmrb-comment/comment/zh/c/myCommentList";
/**
* 个人中心 APP获取用户等级
*/
static readonly MINE_USER_LEVEL_DATA_PATH: string = "/api/rmrb-user-point/auth/level/zh/c/queryUserLevel";
/**
* 个人中心 APP获取其他用户等级
*/
static readonly OTHER_USER_LEVEL_DATA_PATH: string = "/api/rmrb-user-point/auth/level/zh/c/batchUser";
/**
* 个人中心 (号主/普通用户)我的基本信息
*/
... ... @@ -157,13 +152,11 @@ export class HttpUrlUtils {
* pageSize=20&pageNum=1&topicId=10000009445
* */
static readonly MORNING_EVENING_PAGE_INFO_PATH: string = "/api/rmrb-bff-display-zh/display/zh/c/pageInfo";
static readonly MORNING_EVENING_COMP_INFO_PATH: string = "/api/rmrb-bff-display-zh/display/zh/c/compInfo";
private static hostUrl: string = HttpUrlUtils.HOST_PRODUCT;
private static userId=''
private static userType=''
private static token=''
private static userId = ''
private static userType = ''
private static token = ''
static getCommonHeaders(): HashMap<string, string> {
let headers: HashMap<string, string> = new HashMap<string, string>()
... ... @@ -330,7 +323,7 @@ export class HttpUrlUtils {
return HttpUrlUtils.userId
}
HttpUrlUtils.userId = SPHelper.default.getSync(SpConstants.USER_ID,"") as string
return HttpUrlUtils.userId;
return HttpUrlUtils.userId;
}
public static getUserType() {
... ... @@ -372,7 +365,7 @@ export class HttpUrlUtils {
return url;
}
static getAppLoginUrl() :string{
static getAppLoginUrl(): string {
let url = HttpUrlUtils.getHost() + "/api/rmrb-user-center/auth/zh/c/appLogin";
return url;
}
... ... @@ -511,16 +504,15 @@ export class HttpUrlUtils {
// return headers;
// }
public static setUserId(userId:string){
HttpUrlUtils.userId=userId;
public static setUserId(userId: string) {
HttpUrlUtils.userId = userId;
}
public static setUserType(userType:string){
HttpUrlUtils.userType=userType;
public static setUserType(userType: string) {
HttpUrlUtils.userType = userType;
}
public static setUserToken(token:string){
HttpUrlUtils.token=token;
public static setUserToken(token: string) {
HttpUrlUtils.token = token;
}
}
\ No newline at end of file
... ...
... ... @@ -69,9 +69,9 @@ export function registerRouter() {
Action2Page.register("JUMP_INNER_NEW_PAGE", (action) => {
if (action.params?.pageID == "E_NEWSPAPER") {
return WDRouterPage.eNewspaper
} else if (action.params?.pageID == "MorningEveningPaper"){
} else if (action.params?.pageID == "MorningEveningPaper") {
return WDRouterPage.morningEveningPaperPage
} else if (action.params?.pageID == "IMAGE_TEXT_DETAIL"){
} else if (action.params?.pageID == "IMAGE_TEXT_DETAIL") {
return WDRouterPage.imageTextDetailPage
}
return undefined
... ...
... ... @@ -27,6 +27,7 @@ export class WDRouterPage {
// 图文详情页
static imageTextDetailPage = new WDRouterPage("phone", "ets/pages/ImageAndTextDetailPage");
// 短视频详情页
static detailVideoListPage = new WDRouterPage("wdDetailPlayShortVideo", "ets/pages/DetailVideoListPage");
static detailPlayShortVideoPage = new WDRouterPage("wdDetailPlayShortVideo", "ets/pages/DetailPlayShortVideoPage");
// 点播详情页
static detailPlayVodPage = new WDRouterPage("wdDetailPlayVod", "ets/pages/DetailPlayVodPage");
... ... @@ -37,7 +38,6 @@ export class WDRouterPage {
// 音乐详情页
static audioDetail = new WDRouterPage("phone", "ets/pages/detail/AudioDetail");
static loginPage = new WDRouterPage("wdLogin", "ets/pages/login/LoginPage");
static forgetPasswordPage = new WDRouterPage("wdLogin", "ets/pages/login/ForgetPasswordPage");
//我的 预约
static appointmentListPage = new WDRouterPage("wdComponent", "ets/components/page/AppointmentListPage");
... ... @@ -64,10 +64,8 @@ export class WDRouterPage {
static settingPage = new WDRouterPage("wdComponent", "ets/components/page/SettingPage");
// 设置密码页、设置手机号页等等 (需要传参)
static settingPasswordPage = new WDRouterPage("wdLogin", "ets/pages/login/SettingPasswordPage");
//其他普通用户 主页
static otherNormalUserHomePagePage = new WDRouterPage("wdComponent", "ets/pages/OtherNormalUserHomePage");
static guidePage = new WDRouterPage("wdLogin", "ets/pages/guide/GuidePages");
//隐私政策页面
... ...
... ... @@ -13,6 +13,12 @@ export interface ContentDetailRequestParams {
relType: string
}
export interface recommentVideoListParame {
pageSize: number;
refreshCnt: number;
}
export class ContentDetailRequest {
static getContentDetailDataMock(context: Context): Promise<ResponseDTO<ContentDetailDTO[]>> {
Logger.info(TAG, `getContentDetailDataMock start`);
... ... @@ -26,10 +32,10 @@ export class ContentDetailRequest {
/**
* 新闻内容详情【get】接口
*/
static readonly CONTENT_DETAIL_PATH: string = "/api/rmrb-bff-display-zh/content/zh/c/content/detail";
// static readonly CONTENT_DETAIL_PATH: string = "/api/rmrb-bff-display-zh/content/zh/c/content/detail";
static getContentDetailUrl(contentId: string, relId: string, relType: string) {
let url = HttpUrlUtils.getHost() + ContentDetailRequest.CONTENT_DETAIL_PATH
let url = HttpUrlUtils.getHost() + HttpUrlUtils.DETAIL_PATH
url = url + "?&contentId=" + contentId
+ "&relId=" + relId
+ "&relType=" + relType;
... ... @@ -44,4 +50,46 @@ export class ContentDetailRequest {
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.get<ResponseDTO<ContentDetailDTO[]>>(url, headers)
}
/**
*
* @returns
*/
static getContentInteract() {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_DATA_PATH
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.get(url, headers)
}
/**
*
* @returns
*/
static postBatchLikeAndCollectStatus() {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_DATA_STATUS
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.post(url, headers)
}
/**
*
* @returns
*/
static postBatchAttentionStatus() {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.FOLLOW_LIST_STATUS_DATA_PATH
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.post(url, headers)
}
/**
* 沉浸式視頻查詢近20条数据
* @returns
*/
static postRecommendVideoList(params: recommentVideoListParame): Promise<ResponseDTO<ContentDetailDTO[]>> {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.RECOMMEND_VIDEOLIST
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.post0(url, params, headers)
}
}
\ No newline at end of file
... ...
import router from '@ohos.router';
import mediaquery from '@ohos.mediaquery';
import window from '@ohos.window';
import { Action, RmhInfoDTO, UserInfoDTO } from 'wdBean';
import { Action, ContentDetailDTO, RmhInfoDTO, UserInfoDTO } from 'wdBean';
import { Logger, SPHelper, WindowModel } from 'wdKit';
import { PlayerConstants, WDPlayerController, WDPlayerRenderView } from 'wdPlayer';
import { devicePLSensorManager } from 'wdDetailPlayApi';
... ... @@ -15,12 +15,15 @@ const TAG = 'DetailPlayShortVideoPage';
/**
* 详情&短视频播放页面
*/
@Entry
@Component
export struct DetailPlayShortVideoPage {
private contentId?: string = undefined
private relId?: string = undefined
private relType?: string = undefined
private contentDetailData: ContentDetailDTO | undefined = undefined
@Prop @Watch('currentIndexChange') currentIndex: number = 0
private index: number = 0
private playerController: WDPlayerController = new WDPlayerController();
@Watch("urlChanged") @State url?: string = undefined
@Watch('changeContinue') @Provide nextContId?: string = '';
... ... @@ -55,7 +58,21 @@ export struct DetailPlayShortVideoPage {
this.userInfo = this.playVM.userInfo
}
currentIndexChange() {
console.log('currentIndexChange====', this.currentIndex)
if (this.currentIndex != this.index) {
this.playerController.pause()
} else {
console.log('currentIndexChange====1', this.playerController)
this.playerController.switchPlayOrPause()
}
}
aboutToAppear() {
console.log('开始设置setContentDetailData', JSON.stringify(this.contentDetailData))
this.playVM.setContentDetailData(this.contentDetailData)
let action: Action = router.getParams() as Action
Logger.info(TAG, "action", JSON.stringify(action))
if (action) {
... ... @@ -79,12 +96,23 @@ export struct DetailPlayShortVideoPage {
}
WindowModel.shared.setMainWindowFullScreen(this.isFullScreen)
})
console.error('111,', this.index, this.currentIndex)
if (this.index == 0 && this.currentIndex === this.index) {
setTimeout(() => {
this.playerController.play()
}, 2000)
}
}
onPageShow() {
WindowModel.shared.setPreferredOrientation(window.Orientation.AUTO_ROTATION_RESTRICTED);
}
aboutToDisappear(): void {
this.playerController?.pause();
}
onPageHide() {
WindowModel.shared.setPreferredOrientation(window.Orientation.PORTRAIT);
devicePLSensorManager.devicePLSensorOff();
... ... @@ -100,12 +128,16 @@ export struct DetailPlayShortVideoPage {
onLoad: async () => {
console.log('onload==', this.contentId, this.relId, this.relType)
// this.playVM.playWithContentId(this.contentId ?? "846899373")
this.playVM.playWithIds(this.contentId ?? "846899373",
this.relId ?? "500000301942", this.relType ?? "1")
this.playVM.playWithIds(this.contentId,
this.relId, this.relType)
}
})
.height('100%')
.width('100%')
.onClick(() => {
console.error('WDPlayerRenderView=== onClick')
this.playerController?.switchPlayOrPause();
})
}
@Builder
... ... @@ -130,16 +162,21 @@ export struct DetailPlayShortVideoPage {
playerView: () => {
this.playerViewContainerBuilder()
}, playControlView: () => {
this.playControlViewContainerBuilder()
// this.playControlViewContainerBuilder()
}, detailView: () => {
this.detailContainerBuilder()
}
})
.height('100%')
.width('100%')
.onClick(() => {
console.error('PlayerDetailContainer=== onClick')
this.playerController?.switchPlayOrPause();
})
}
.height('100%')
.width('100%')
.backgroundColor(Color.Black)
}
... ...
import { Action, ContentDetailDTO } from 'wdBean/Index';
import { ContentDetailRequest } from 'wdDetailPlayApi/Index'
import { ResponseDTO } from 'wdNetwork/Index';
import { DetailPlayShortVideoPage } from './DetailPlayShortVideoPage'
import { Test } from './Test'
import router from '@ohos.router';
@Entry
@Component
export struct DetailVideoListPage {
private contentId: string = ''
private relId: string = ''
private relType: string = ''
private swiperController: SwiperController = new SwiperController()
@State data: ContentDetailDTO[] = []
@State testData: string[] = ['111', '222', '333']
@State currentIndex: number = 0
async aboutToAppear(): Promise<void> {
let data: ContentDetailDTO[] = []
let action: Action = router.getParams() as Action
if (action) {
this.contentId = action.params?.contentID || ''
if (action.params && action.params.extra) {
this.relId = action.params.extra.relId || ''
this.relType = action.params.extra.relType || ''
}
await ContentDetailRequest.getContentDetail({
contentId: this.contentId,
relId: this.relId,
relType: this.relType
}).then((resDTO: ResponseDTO<ContentDetailDTO[]>) => {
console.error('resDTO==', JSON.stringify(resDTO.data))
if (resDTO.data) {
data.push(resDTO.data[0])
}
})
}
await ContentDetailRequest.postRecommendVideoList({
pageSize: 10,
refreshCnt: 1
}).then(res => {
if (res.data) {
data = data.concat(res.data)
}
// this.data = res.data || []
console.log('res1===', JSON.stringify(res))
console.log('res==' + this.data)
})
this.data = data
console.error('aboutToAppear===', this.data.length)
}
build() {
Column() {
Swiper(this.swiperController) {
ForEach(this.data, (item: ContentDetailDTO, index: number) => {
Column() {
DetailPlayShortVideoPage({
contentDetailData: item,
currentIndex: this.currentIndex,
index: index
})
}.width('100%')
.height('100%')
}, (item: ContentDetailDTO) => item.newsId + '')
// ForEach(this.testData, (item: string, index: number) => {
// Column() {
// Test({ currentItem: item, currentIndex: this.currentIndex, index: index })
// }
// .width('100%')
// .height('100%')
// }, (item: string) => item)
}
.cachedCount(2)
.indicator(false)
.vertical(true)
.width('100%')
.height('100%')
.onChange((index: number) => {
this.currentIndex = index
console.info('onChange==', index.toString())
})
}.width('100%').height('100%')
}
}
\ No newline at end of file
... ...
@Entry
@Component
export struct Test {
@Prop currentItem: string = '';
@Prop @Watch('currentIndexChange') currentIndex: number = 0;
@Prop index: number = 0;
currentIndexChange() {
console.log('currentIndexChange====', this.currentIndex);
}
build() {
Row() {
Column() {
Text('currentItem: ' + this.currentItem).fontSize(30)
Text('currentIndex: ' + this.currentIndex).fontSize(30)
Text('index: ' + this.index).fontSize(30)
}
}
}
}
\ No newline at end of file
... ...
/**
* 详情view&播放器view的容器布局组件
*/
@Entry
@Component
export struct PlayerDetailContainer {
@BuilderParam playerView: () => void
... ... @@ -102,5 +102,6 @@ export struct PlayerDetailContainer {
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
... ...
... ... @@ -26,25 +26,48 @@ export class PlayViewModel {
canStart?: boolean
message?: string
constructor() {
constructor(contentId: string = '', relId: string = '', relType: string = '') {
// todo:
this.contentId = '30013266075'
this.relId = '500000301942'
this.relType = '1'
this.contentId = contentId // '30013266075'
this.relId = relId // '500000301942'
this.relType = relType // '1'
// this.getGlobalInfo();
}
playWithContentId(contentId: string) {
this.contentId = contentId;
this.getContentDetailData() // 包括播放地址PlayUrl
// this.getContentDetailData() // 包括播放地址PlayUrl
}
playWithIds(contentId: string, relId: string, relType: string) {
this.contentId = contentId;
this.relId = relId;
this.relType = relType;
this.getContentDetailData() // 包括播放地址PlayUrl
// this.getContentDetailData() // 包括播放地址PlayUrl
}
setContentDetailData(data: ContentDetailDTO | undefined) {
if (!data) {
Logger.error(TAG, 'setContentDetailData is empty');
return
}
Logger.info(TAG, JSON.stringify(data))
this.newsTitle = data.newsTitle
this.editorName = data.editorName
this.newsSummary = data.newsSummary
this.userInfo = data.userInfo
this.rmhInfo = data.rmhInfo
if (data.videoInfo?.length > 0) {
this.url = data.videoInfo[0].videoUrl
this.videoLandScape = data.videoInfo[0].videoLandScape
}
if (data.authorList?.length > 0) {
this.newsSourceName = data.authorList[0].authorName
}
this.canStart = true;
this.message = '';
}
getContentDetailData() {
... ...
{
"src": [
"pages/DetailPlayShortVideoPage"
"pages/DetailVideoListPage",
"pages/Test"
]
}
}
\ No newline at end of file
... ...
... ... @@ -72,7 +72,7 @@ export class WDPlayerController {
if (this.startTime) {
this.setSeekTime(this.startTime, SliderChangeMode.Begin);
}
this.avPlayer.play();
// this.avPlayer.play();
this.duration = this.avPlayer.duration;
break;
case AVPlayerStatus.PLAYING:
... ... @@ -162,6 +162,16 @@ export class WDPlayerController {
this.avPlayer.pause();
}
async play() {
if (this.avPlayer == null) {
await this.initPromise;
}
if (this.avPlayer == null) {
return
}
this.avPlayer.play();
}
async stop() {
if (this.avPlayer == null) {
await this.initPromise;
... ...