zhenghy

视频详情页修改

... ... @@ -41,13 +41,29 @@ export class HttpUrlUtils {
/**
* 批查接口,查询互动相关数据,如收藏数、评论数等
*/
static readonly INTERACT_DATA_PATH: string = "/api/rmrb-contact/contact/zh/c/v2/content/interactData";
static readonly INTERACT_DATA_PATH: string = "/api/rmrb-contact/contact/zh/c/content/interactData";
// 多图(图集)详情页
/**
* 批量查询内容当前用户点赞、收藏状态
*/
static readonly INTERACT_DATA_STATUS: string = "/api/rmrb-interact/interact/zh/c/batchLikeAndCollect/status";
/**
* 点赞、取消点赞
*/
static readonly INTERACT_EXECUTELIKE: string = "/api/rmrb-interact/interact/zh/c/like/executeLike";
/**
* 收藏、取消收藏
*/
static readonly INTERACT_EXECUTECOLLECTRECORD: string = "/api/rmrb-interact/interact/zh/c/collect/executeCollcetRecord";
/**
* 用户等级/积分-APP根据业务场景动态增减成长值(APP)
*/
static readonly USERPOINT_OPERATE: string = "/api/rmrb-user-point/auth/pointLevel/zh/operate";
/**
* 评论发布
*/
static readonly COMMENT_PUBLISH: string = "/api/rmrb-comment/comment/zh/c/publish";
/**
* 沉浸式視頻批量查詢20條數據
*/
static readonly RECOMMEND_VIDEOLIST: string = "/api/rmrb-bff-display-zh/recommend/zh/c/videoList";
... ... @@ -128,12 +144,10 @@ export class HttpUrlUtils {
* 个人中心 我的关注列表
*/
static readonly OTHER_USER_FOLLOW_LIST_DATA_PATH: string = "/api/rmrb-interact/interact/zh/c/userAttention/list";
/**
* 预约操作
*/
static readonly APPOINTMENT_OPERATION_STATUS_PATH: string = "/api/live-center-message/zh/c/live/subscribe";
/**
* 点赞操作
*/
... ... @@ -153,7 +167,7 @@ export class HttpUrlUtils {
* */
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 hostUrl: string = HttpUrlUtils.HOST_UAT;
private static userId = ''
private static userType = ''
private static token = ''
... ... @@ -169,8 +183,8 @@ export class HttpUrlUtils {
headers.set('timestamp', HttpUrlUtils.getTimestamp())
headers.set('RMRB-X-TOKEN', HttpUrlUtils.getXToken())
headers.set('device_id', HttpUrlUtils.getDeviceId())
if(HttpUrlUtils.getXToken()!=''){
headers.set('cookie', 'RMRB-X-TOKEN='+HttpUrlUtils.getXToken())
if (HttpUrlUtils.getXToken() != '') {
headers.set('cookie', 'RMRB-X-TOKEN=' + HttpUrlUtils.getXToken())
}
headers.set('build_version', HttpUrlUtils.getVersion())
headers.set('adcode', HttpUrlUtils.getAdCode())
... ... @@ -251,19 +265,19 @@ export class HttpUrlUtils {
}
private static getXToken() {
if(StringUtils.isNotEmpty(HttpUrlUtils.token)){
if (StringUtils.isNotEmpty(HttpUrlUtils.token)) {
return HttpUrlUtils.token
}
HttpUrlUtils.token = SPHelper.default.getSync(SpConstants.USER_JWT_TOKEN,"") as string
if(StringUtils.isNotEmpty(HttpUrlUtils.token)) {
HttpUrlUtils.token = SPHelper.default.getSync(SpConstants.USER_JWT_TOKEN, "") as string
if (StringUtils.isNotEmpty(HttpUrlUtils.token)) {
return HttpUrlUtils.token
}
return 'eyJhbGciOiJIUzI1NiIsImtpZCI6ImQ4WkI2QkhxSEZrdjJ2U25BNlRwZEdKRjBHcjItVzBvS2FaYzdLOUUycmcifQ.eyJpc3MiOiJwZW9wbGVzLWRhaWx5LWZvdXJhIiwic3ViIjoicGVvcGxlcy1kYWlseS1mb3VyYSIsImV4cCI6MTcwMzY0OTYwNiwidXNlcklkIjo0NTk3NzYyOTc0NzQ5NDksInVzZXJWZXJzaW9uIjoiNDU5Nzc2Mjk3NDc0OTQ5XzIiLCJ1c2VyTmFtZSI6IkJ1bGlraWtpMTgxIiwidXNlclR5cGUiOjIsImNyZWF0b3JJZCI6NDI2NTM5MH0.jhQ9kylcm3FxWf0-lBMZuLkdtIQ6XpFnAi0AFZJNwfc';
}
static getRefreshToken() {
let refreshToken = SPHelper.default.getSync(SpConstants.USER_REFRESH_TOKEN,"")
if(StringUtils.isNotEmpty(refreshToken)) {
let refreshToken = SPHelper.default.getSync(SpConstants.USER_REFRESH_TOKEN, "")
if (StringUtils.isNotEmpty(refreshToken)) {
return refreshToken as string;
}
return '';
... ... @@ -327,18 +341,18 @@ export class HttpUrlUtils {
public static getUserId() {
// TODO 对接登录
if(StringUtils.isNotEmpty(HttpUrlUtils.userId)){
if (StringUtils.isNotEmpty(HttpUrlUtils.userId)) {
return HttpUrlUtils.userId
}
HttpUrlUtils.userId = SPHelper.default.getSync(SpConstants.USER_ID,"") as string
HttpUrlUtils.userId = SPHelper.default.getSync(SpConstants.USER_ID, "") as string
return HttpUrlUtils.userId;
}
public static getUserType() {
if(StringUtils.isNotEmpty(HttpUrlUtils.userType)){
if (StringUtils.isNotEmpty(HttpUrlUtils.userType)) {
return HttpUrlUtils.userType
}
HttpUrlUtils.userType = SPHelper.default.getSync(SpConstants.USER_Type,"") as string
HttpUrlUtils.userType = SPHelper.default.getSync(SpConstants.USER_Type, "") as string
return HttpUrlUtils.userType;
}
... ...
... ... @@ -13,7 +13,7 @@ export interface ContentDetailRequestParams {
relType: string
}
export interface recommentVideoListParame {
export interface recommentVideoListParams {
pageSize: number;
refreshCnt: number;
}
... ... @@ -27,6 +27,94 @@ export interface contentListParams {
contentList: contentListItem[];
}
export interface IStatusContentList {
contentId: string;
// relType: string;
contentType: string;
// contentRelId: string;
}
export interface batchLikeAndCollectParams {
// userType: number;
// userId: string;
contentList: IStatusContentList[]
}
export interface batchLikeAndCollectResult {
collectStatus: number;
contentType: string;
likeStatus: string;
relType: string;
contentId: string;
contentRelId: string;
}
export interface postBatchAttentionStatusParamsItem {
creatorId: string;
}
export interface postBatchAttentionStatusParams {
creatorIds: postBatchAttentionStatusParamsItem[]
}
export interface postBatchAttentionStatusResult {
creatorId: string;
status: string;
userId: string;
}
export interface postExecuteLikeParams {
status: string;
contentId: string;
contentType: string;
relType?: string;
userName?: string;
title?: string;
contentRelId?: string;
userHeaderUrl?: string;
channelId?: string;
}
export interface postExecuteCollectRecordParamsItem {
contentId: string;
contentType: string;
relType?: string;
contentRelId?: string;
}
export interface postExecuteCollectRecordParams {
status: string;
contentList: postExecuteCollectRecordParamsItem[]
}
export interface postPointLevelOperateParams {
operateType: number;
}
export interface postCommentPublishParams {
targetId: string;
keyArticle: string;
commentPics: string;
targetTitle: string;
commentType: string;
targetType: string;
commentContent: string;
parentId: string;
rootCommentId: string;
}
export interface postInteractBrowsOperateParamsContent {
browseTime: string;
contentId: string;
contentType: number;
}
export interface postInteractBrowsOperateParams {
delStatus: number;
contentList: postInteractBrowsOperateParamsContent[]
}
export class ContentDetailRequest {
static getContentDetailDataMock(context: Context): Promise<ResponseDTO<ContentDetailDTO[]>> {
... ... @@ -71,23 +159,23 @@ export class ContentDetailRequest {
}
/**
*
* 批量查询作品查询点赞、收藏状态
* @returns
*/
static postBatchLikeAndCollectStatus() {
static postBatchLikeAndCollectStatus(params: batchLikeAndCollectParams): Promise<ResponseDTO<batchLikeAndCollectResult[]>> {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_DATA_STATUS
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.post(url, headers)
return WDHttp.post0(url, params, headers)
}
/**
*
* 批量查号主是否为用户关注
* @returns
*/
static postBatchAttentionStatus() {
static postBatchAttentionStatus(params: postBatchAttentionStatusParams): Promise<ResponseDTO<postBatchAttentionStatusResult[]>> {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.FOLLOW_LIST_STATUS_DATA_PATH
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.post(url, headers)
return WDHttp.post0(url, params, headers)
}
... ... @@ -96,9 +184,60 @@ export class ContentDetailRequest {
* @returns
*/
static postRecommendVideoList(params: recommentVideoListParame): Promise<ResponseDTO<ContentDetailDTO[]>> {
static postRecommendVideoList(params: recommentVideoListParams): Promise<ResponseDTO<ContentDetailDTO[]>> {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.RECOMMEND_VIDEOLIST
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.post0(url, params, headers)
}
/**
*用户点赞、取消点赞
* @param params
* @returns
*/
static postExecuteLike(params: postExecuteLikeParams): Promise<ResponseDTO> {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_EXECUTELIKE
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.post0(url, params, headers)
}
/**
*用户收藏、取消收藏
* @param params
* @returns
*/
static postExecuteCollectRecord(params: postExecuteCollectRecordParams): Promise<ResponseDTO> {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_EXECUTECOLLECTRECORD
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.post0(url, params, headers)
}
/**
*用户等级/积分-APP根据业务场景动态增减成长值(APP)
* 操作类型:1阅读 2评论 3回复(积分任务同评论) 4分享 5点赞 6关注 7打开客户端 8上传头像 9打开推送开关
*/
static postPointLevelOperate(params: postPointLevelOperateParams): Promise<ResponseDTO> {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.USERPOINT_OPERATE
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.post0(url, params, headers)
}
/**
* 评论发布
*/
static postCommentPublish(params: postCommentPublishParams): Promise<ResponseDTO> {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.COMMENT_PUBLISH
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.post0(url, params, headers)
}
/**
* 浏览历史新增、删除接口
*/
static postInteractBrowsOperate(params: postInteractBrowsOperateParams): Promise<ResponseDTO> {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_BROWS_OPERATE
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, ContentDetailDTO, InteractDataDTO, RmhInfoDTO, UserInfoDTO } from 'wdBean';
import { Logger, SPHelper, WindowModel } from 'wdKit';
import { PlayerConstants, WDPlayerController, WDPlayerRenderView } from 'wdPlayer';
import { devicePLSensorManager } from 'wdDetailPlayApi';
import { ContentDetailDTO, InteractDataDTO } from 'wdBean';
import { WDPlayerController, WDPlayerRenderView } from 'wdPlayer';
import { ContentDetailRequest, devicePLSensorManager } from 'wdDetailPlayApi';
import { PlayControlViewContainer } from '../view/PlayControlViewContainer';
import { PlayerDetailContainer } from '../view/PlayerDetailContainer';
import { PlayViewModel } from '../viewmodel/PlayViewModel';
import { DetailContainer } from '../view/DetailContainer';
import {
batchLikeAndCollectParams,
batchLikeAndCollectResult,
postBatchAttentionStatusParams,
postInteractBrowsOperateParams
} from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest';
import { HttpUrlUtils } from 'wdNetwork/Index';
import { DateTimeUtils } from 'wdKit/Index';
const TAG = 'DetailPlayShortVideoPage';
... ... @@ -18,74 +22,101 @@ const TAG = 'DetailPlayShortVideoPage';
@Component
export struct DetailPlayShortVideoPage {
private contentId?: string = undefined
private relId?: string = undefined
private relType?: string = undefined
private contentDetailData: ContentDetailDTO | undefined = undefined
@Provide interactData: InteractDataDTO | undefined = undefined
@Prop index: number = 0
@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 = '';
@Watch('getPlayHistory') @Provide curContId?: string = undefined;
@Watch("playVMChanged") @Provide playVM: PlayViewModel = new PlayViewModel();
@State playerController: WDPlayerController = new WDPlayerController();
@Provide contentDetailData: ContentDetailDTO | undefined = undefined
@Provide interactData: InteractDataDTO | undefined = undefined
@Provide isFullScreen: boolean = false;
@Provide canStart?: boolean = false;
@Provide status: number = PlayerConstants.STATUS_START;
@Provide userId: string = '';
@Provide newsSourceName?: string = ''
@Provide newsTitle?: string = ''
@Provide editorName?: string = ''
@Provide rmhInfo?: RmhInfoDTO | null = null
@Provide userInfo?: UserInfoDTO | null = null
@Provide message?: string = ''
@Provide newsSummary?: string = ''
@Provide progressVal: number = 0;
@Provide videoLandScape?: number = 1; // 视频朝向, 横屏视频:1;竖屏视频:2
playVMChanged() {
this.url = this.playVM.url
this.newsSourceName = this.playVM.newsSourceName
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
}
@Provide newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态
@Provide followStatus: string = '0' // 关注状态
currentIndexChange() {
console.log('currentIndexChange====', this.currentIndex)
if (this.currentIndex != this.index) {
this.playerController.pause()
// if (this.index < this.currentIndex - 5 && this.playerController.getPlayer()) {
// this.playerController.release()
// }
} else {
console.log('currentIndexChange====1', this.playerController)
this.playerController.switchPlayOrPause()
this.queryNewsInfoOfUser()
console.log('currentIndex==== ', this.currentIndex)
if (!this.playerController.getPlayer()) {
this.playerController.firstPlay(this.contentDetailData?.videoInfo[0]?.videoUrl || '');
} else {
this.playerController.play()
}
}
}
aboutToAppear() {
console.log('开始设置setContentDetailData', JSON.stringify(this.contentDetailData))
/**
* 查询用户点赞、收藏、关注等状态
*/
queryNewsInfoOfUser() {
if (HttpUrlUtils.getUserId()) {
const params: batchLikeAndCollectParams = {
contentList: [
{
contentId: this.contentDetailData?.newsId + '',
contentType: this.contentDetailData?.newsType + '',
}
]
}
// 已登录->查询用户对作品点赞、收藏状态
ContentDetailRequest.postBatchLikeAndCollectStatus(params).then(res => {
console.log('查询点赞、收藏状态==', JSON.stringify(res.data))
if (res.data) {
this.newsStatusOfUser = res.data[0]
}
})
this.playVM.setContentDetailData(this.contentDetailData)
const params1: postBatchAttentionStatusParams = {
creatorIds: [{ creatorId: this.contentDetailData?.rmhInfo?.rmhId ?? '' }]
}
// 已登录->批量查作品是否被号主关注
ContentDetailRequest.postBatchAttentionStatus(params1).then(res => {
console.log('批量查号主是否为用户关注==', JSON.stringify(res.data))
if (res.data) {
this.followStatus = res.data[0]?.status
}
})
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) {
this.relId = action.params.extra.relId
this.relType = action.params.extra.relType
// 记录浏览历史
const params2: postInteractBrowsOperateParams = {
delStatus: 0,
contentList: [{
browseTime: DateTimeUtils.getCurDate(DateTimeUtils.PATTERN_DATE_TIME_HYPHEN),
contentId: this.contentDetailData?.newsId + '',
contentType: this.contentDetailData?.newsType || 0,
}]
}
ContentDetailRequest.postInteractBrowsOperate(params2).then(res => {
console.log('记录浏览历史==', JSON.stringify(res.data))
})
}
}
aboutToAppear() {
console.log('开始设置setContentDetailData', JSON.stringify(this.contentDetailData))
this.videoLandScape = this.contentDetailData?.videoInfo[0]?.videoLandScape
this.queryNewsInfoOfUser()
this.playerController.onCanplay = () => {
if (this.index == 0 || this.currentIndex === this.index) {
this.playerController.play()
}
}
this.playerController.onTimeUpdate = (position, duration) => {
this.progressVal = Math.floor(position * 100 / duration);
}
// 设置播放地址
// this.url = 'https://media.w3.org/2010/05/sintel/trailer.mp4'
let listener = mediaquery.matchMediaSync('(orientation: landscape)');
listener.on("change", (mediaQueryResult) => {
if (mediaQueryResult.matches) {
... ... @@ -95,29 +126,24 @@ export struct DetailPlayShortVideoPage {
this.isFullScreen = false
console.log("横屏 no")
}
WindowModel.shared.setMainWindowFullScreen(this.isFullScreen)
// 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);
// WindowModel.shared.setPreferredOrientation(window.Orientation.AUTO_ROTATION_RESTRICTED);
}
aboutToDisappear(): void {
this.playerController?.pause();
// this.playerController.onCanplay = ()={}
}
onPageHide() {
WindowModel.shared.setPreferredOrientation(window.Orientation.PORTRAIT);
// WindowModel.shared.setPreferredOrientation(window.Orientation.PORTRAIT);
devicePLSensorManager.devicePLSensorOff();
this.status = PlayerConstants.STATUS_PAUSE;
// this.status = PlayerConstants.STATUS_PAUSE;
this.playerController?.pause();
}
... ... @@ -127,10 +153,10 @@ export struct DetailPlayShortVideoPage {
WDPlayerRenderView({
playerController: this.playerController,
onLoad: async () => {
console.log('onload==', this.contentId, this.relId, this.relType)
// this.playVM.playWithContentId(this.contentId ?? "846899373")
this.playVM.playWithIds(this.contentId,
this.relId, this.relType)
console.log('onload==',)
// if (this.index === 0) {
this.playerController.firstPlay(this.contentDetailData?.videoInfo[0]?.videoUrl);
// }
}
})
.height('100%')
... ... @@ -177,49 +203,6 @@ export struct DetailPlayShortVideoPage {
}
.height('100%')
.width('100%')
.backgroundColor(Color.Black)
}
// 续播判断
changeContinue() {
if (this.nextContId) {
this.playerController.continue = () => {
this.playerController?.stop();
this.playVM.playWithContentId(this.nextContId ?? '');
}
return;
}
this.playerController.continue = undefined;
}
urlChanged() {
if (this.url) {
console.log("url:" + this.url);
this.status = PlayerConstants.STATUS_START;
this.playerController.firstPlay(this.url);
}
}
getPlayHistory() {
SPHelper.default.get('playHistory', '').then((str) => {
let result = str.toString();
let time = 0;
if (result != null && result != "") {
let playHistory: Record<string, Record<string, number>> = JSON.parse(result);
let userData: Record<string, number> = {};
if (this.userId) {
userData = playHistory[this.userId] ?? {};
}
if (this.curContId) {
time = userData?.[this.curContId] ?? 0;
}
}
this.playerController?.setStartTime(time);
}).catch((err: Error) => {
// Error: Inner error. Error code 15500000
Logger.error(TAG, 'catch err:' + JSON.stringify(err));
this.playerController?.setStartTime(0);
});
}
}
\ No newline at end of file
... ...
// import router from '@ohos.router';
import mediaquery from '@ohos.mediaquery';
import window from '@ohos.window';
import { ContentDetailDTO, InteractDataDTO, RmhInfoDTO, UserInfoDTO } from 'wdBean';
import { Logger, SPHelper, WindowModel } from 'wdKit';
import { PlayerConstants, WDPlayerController, WDPlayerRenderView } from 'wdPlayer';
import { ContentDetailRequest, devicePLSensorManager } from 'wdDetailPlayApi';
import { PlayControlViewContainer } from '../view/PlayControlViewContainer';
import { PlayerDetailContainer } from '../view/PlayerDetailContainer';
// import { PlayViewModel } from '../viewmodel/PlayViewModel';
import { DetailContainer } from '../view/DetailContainer';
import {
batchLikeAndCollectParams,
batchLikeAndCollectResult,
postBatchAttentionStatusParams
} from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest';
import { HttpUrlUtils } from 'wdNetwork/Index';
const TAG = 'DetailPlayShortVideoPage';
/**
* 详情&短视频播放页面
*/
@Component
export struct DetailPlayShortVideoPage {
// private contentId?: string = undefined
// private relId?: string = undefined
// private relType?: string = undefined
@Provide contentDetailData: ContentDetailDTO | undefined = undefined
@Provide interactData: InteractDataDTO | 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 = '';
// @Watch('getPlayHistory') @Provide curContId?: string = undefined;
// @Watch("playVMChanged") @Provide playVM: PlayViewModel = new PlayViewModel();
@Provide isFullScreen: boolean = false;
// @Provide canStart?: boolean = false;
// @Provide status: number = PlayerConstants.STATUS_START;
// @Provide userId: string = '';
// @Provide newsSourceName?: string = ''
// @Provide newsTitle?: string = ''
// @Provide editorName?: string = ''
// @Provide rmhInfo?: RmhInfoDTO | null = null
// @Provide userInfo?: UserInfoDTO | null = null
// @Provide message?: string = ''
// @Provide newsSummary?: string = ''
@Provide progressVal: number = 0;
@Provide videoLandScape?: number = 1; // 视频朝向, 横屏视频:1;竖屏视频:2
@Provide newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态
@Provide followStatus: string = '0' // 关注状态
// playVMChanged() {
// this.url = this.playVM.url
// this.newsSourceName = this.playVM.newsSourceName
// 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
// console.error('rmhInfo', this.rmhInfo)
// console.error('userInfo', this.userInfo)
// }
currentIndexChange() {
if (this.currentIndex != this.index) {
this.playerController.pause()
if (this.index < this.currentIndex - 5 && this.playerController.getPlayer()) {
this.playerController.release()
}
} else {
console.log('currentIndexChange====1', this.currentIndex)
this.playerController.play()
this.queryNewsInfoOfUser()
}
}
/**
* 查询用户点赞、收藏、关注等状态
*/
queryNewsInfoOfUser() {
if (HttpUrlUtils.getUserId()) {
const params: batchLikeAndCollectParams = {
contentList: [
{
contentId: this.contentDetailData?.newsId + '',
contentType: this.contentDetailData?.newsType + '',
}
]
}
// 已登录->查询用户对作品点赞、收藏状态
ContentDetailRequest.postBatchLikeAndCollectStatus(params).then(res => {
console.log('查询点赞、收藏状态==', JSON.stringify(res.data))
if (res.data) {
this.newsStatusOfUser = res.data[0]
}
})
const params1: postBatchAttentionStatusParams = {
creatorIds: [{ creatorId: this.contentDetailData?.rmhInfo?.rmhId ?? '' }]
}
// 已登录->批量查作品是否被号主关注
ContentDetailRequest.postBatchAttentionStatus(params1).then(res => {
console.log('批量查号主是否为用户关注==', JSON.stringify(res.data))
if (res.data) {
this.followStatus = res.data[0]?.status
}
})
}
}
aboutToAppear() {
console.log('开始设置setContentDetailData', JSON.stringify(this.contentDetailData))
// this.playVM.setContentDetailData(this.contentDetailData)
// this.playVMChanged()
this.queryNewsInfoOfUser()
this.playerController.onCanplay = () => {
if (this.index == 0 || this.currentIndex === this.index) {
this.videoLandScape = this.contentDetailData?.videoInfo[0]?.videoLandScape
this.playerController.firstPlay(this.contentDetailData?.videoInfo[0]?.videoUrl);
this.playerController.play()
}
}
// 设置播放地址
// this.url = 'https://media.w3.org/2010/05/sintel/trailer.mp4'
let listener = mediaquery.matchMediaSync('(orientation: landscape)');
listener.on("change", (mediaQueryResult) => {
if (mediaQueryResult.matches) {
console.log("横屏 yes")
this.isFullScreen = true
} else {
this.isFullScreen = false
console.log("横屏 no")
}
// WindowModel.shared.setMainWindowFullScreen(this.isFullScreen)
})
}
onPageShow() {
// WindowModel.shared.setPreferredOrientation(window.Orientation.AUTO_ROTATION_RESTRICTED);
}
aboutToDisappear(): void {
this.playerController?.pause();
}
onPageHide() {
// WindowModel.shared.setPreferredOrientation(window.Orientation.PORTRAIT);
devicePLSensorManager.devicePLSensorOff();
// this.status = PlayerConstants.STATUS_PAUSE;
this.playerController?.pause();
}
@Builder
playerViewContainerBuilder() {
// 播放窗口
WDPlayerRenderView({
playerController: this.playerController,
onLoad: async () => {
console.log('onload==', this.contentId, this.relId, this.relType)
}
})
.height('100%')
.width('100%')
.onClick(() => {
console.error('WDPlayerRenderView=== onClick')
this.playerController?.switchPlayOrPause();
})
}
@Builder
playControlViewContainerBuilder() {
// 播放窗口控制bar
PlayControlViewContainer({
playerController: this.playerController
})
}
@Builder
detailContainerBuilder() {
// DetailTabBarPageComponent({ pageId: this.pageId }).backgroundColor(Color.Black)
DetailContainer({
playerController: this.playerController
})
}
build() {
Row() {
PlayerDetailContainer({
playerView: () => {
this.playerViewContainerBuilder()
}, playControlView: () => {
// this.playControlViewContainerBuilder()
}, detailView: () => {
this.detailContainerBuilder()
}
})
.height('100%')
.width('100%')
.onClick(() => {
console.error('PlayerDetailContainer=== onClick')
this.playerController?.switchPlayOrPause();
})
}
.height('100%')
.width('100%')
.backgroundColor(Color.Black)
}
// 续播判断
// changeContinue() {
// if (this.nextContId) {
// this.playerController.continue = () => {
// this.playerController?.stop();
// // this.playVM.playWithContentId(this.nextContId ?? '');
// }
// return;
// }
// this.playerController.continue = undefined;
// }
// urlChanged() {
// console.error('urlChanged===')
// if (this.url) {
// this.status = PlayerConstants.STATUS_START;
// this.playerController.firstPlay(this.url);
// }
// }
// getPlayHistory() {
// SPHelper.default.get('playHistory', '').then((str) => {
// let result = str.toString();
// let time = 0;
// if (result != null && result != "") {
// let playHistory: Record<string, Record<string, number>> = JSON.parse(result);
// let userData: Record<string, number> = {};
// if (this.userId) {
// userData = playHistory[this.userId] ?? {};
// }
// if (this.curContId) {
// time = userData?.[this.curContId] ?? 0;
// }
// }
// this.playerController?.setStartTime(time);
// }).catch((err: Error) => {
// // Error: Inner error. Error code 15500000
// Logger.error(TAG, 'catch err:' + JSON.stringify(err));
// this.playerController?.setStartTime(0);
// });
// }
}
\ No newline at end of file
... ...
... ... @@ -21,7 +21,6 @@ export struct DetailVideoListPage {
@State interactDataList: InteractDataDTO[] = []
async aboutToAppear(): Promise<void> {
console.error('=================',)
let data: ContentDetailDTO[] = []
let action: Action = router.getParams() as Action
if (action) {
... ... @@ -37,29 +36,31 @@ export struct DetailVideoListPage {
}).then((resDTO: ResponseDTO<ContentDetailDTO[]>) => {
console.error('resDTO==', JSON.stringify(resDTO.data))
if (resDTO.data) {
data.push(resDTO.data[0])
this.data.push(resDTO.data[0])
}
})
}
await ContentDetailRequest.postRecommendVideoList({
pageSize: 10,
refreshCnt: 1
}).then(res => {
if (res.data) {
data = data.concat(res.data)
}
console.log('res1===', JSON.stringify(res))
console.log('res==' + this.data)
})
await this.queryVideoList()
// await ContentDetailRequest.postRecommendVideoList({
// pageSize: 5,
// refreshCnt: 1
// }).then(res => {
// if (res.data) {
// data = data.concat(res.data)
// }
// console.log('res1===', JSON.stringify(res))
// console.log('res==' + this.data)
// })
if (data.length > 0) {
if (this.data.length > 0) {
const params: contentListParams = {
contentList: []
}
data.map(item => {
this.data.map(item => {
params.contentList.push({
contentId: item.newsId + '',
contentType: item.newsType
... ... @@ -76,12 +77,27 @@ export struct DetailVideoListPage {
}
this.data = data
// this.data = data
console.error('aboutToAppear===', this.data.length)
}
async queryVideoList() {
await ContentDetailRequest.postRecommendVideoList({
pageSize: 5,
refreshCnt: 1
}).then(res => {
if (res.data) {
this.data = this.data.concat(res.data)
}
console.log('queryVideoList===', JSON.stringify(this.data))
})
}
build() {
Column() {
Swiper(this.swiperController) {
... ... @@ -107,7 +123,7 @@ export struct DetailVideoListPage {
// }, (item: string) => item)
}
.cachedCount(0)
.cachedCount(-1)
.indicator(false)
.vertical(true)
.loop(false)
... ... @@ -117,6 +133,10 @@ export struct DetailVideoListPage {
.onChange((index: number) => {
this.currentIndex = index
console.info('onChange==', index.toString())
if (this.currentIndex === this.data.length - 1) {
this.queryVideoList()
}
})
}.width('100%').height('100%')
... ...
import { InteractDataDTO, RmhInfoDTO, UserInfoDTO } from 'wdBean/Index';
import { ContentDetailDTO, InteractDataDTO, RmhInfoDTO, UserInfoDTO } from 'wdBean/Index';
import {
batchLikeAndCollectParams,
batchLikeAndCollectResult,
ContentDetailRequest,
contentListParams,
postExecuteCollectRecordParams,
postExecuteLikeParams
} from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest';
import { ToastUtils } from 'wdKit';
import { HttpUrlUtils } from 'wdNetwork/Index';
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index';
export interface OperationItem {
icon: Resource;
icon_check?: Resource;
// icon_selected: Resource;
text: string | Resource;
... ... @@ -16,17 +27,19 @@ const TAG = 'OperationListView';
@Preview
@Component
export struct OperationListView {
@Consume rmhInfo?: RmhInfoDTO
@Consume userInfo?: UserInfoDTO
@Consume interactData: InteractDataDTO
@Consume contentDetailData: ContentDetailDTO
@Consume newsStatusOfUser: batchLikeAndCollectResult
@State operationList: OperationItem[] = [
{
icon: $r('app.media.ic_like_uncheck'),
icon_check: $r('app.media.ic_like_check'),
text: "赞",
// num: 6622
},
{
icon: $r('app.media.ic_collect_uncheck'),
icon_check: $r('app.media.ic_collect_check'),
text: "收藏",
// num: 662,
},
... ... @@ -44,26 +57,78 @@ export struct OperationListView {
aboutToAppear() {
}
/**
* 点赞、取消点赞
*/
toggleLikeStatus() {
// 未登录,跳转登录
if (!HttpUrlUtils.getUserId()) {
WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
return
}
const params: postExecuteLikeParams = {
status: this.newsStatusOfUser?.likeStatus === '1' ? '0' : '1',
contentId: this.contentDetailData?.newsId + '',
contentType: this.contentDetailData?.newsType + '',
}
ContentDetailRequest.postExecuteLike(params).then(res => {
console.log('toggleLikeStatus==',)
if (this.newsStatusOfUser) {
this.newsStatusOfUser.likeStatus = this.newsStatusOfUser?.likeStatus === '1' ? '0' : '1'
this.queryContentInteractCount()
}
})
}
/**
* 收藏、取消收藏
*/
toggleCollectStatus() {
// 未登录,跳转登录
if (!HttpUrlUtils.getUserId()) {
WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
return
}
const params: postExecuteCollectRecordParams = {
status: this.newsStatusOfUser?.collectStatus === 1 ? '0' : '1',
contentList: [{
contentId: this.contentDetailData?.newsId + '',
contentType: this.contentDetailData?.newsType + '',
}],
}
ContentDetailRequest.postExecuteCollectRecord(params).then(res => {
console.log('toggleLikeStatus==',)
if (this.newsStatusOfUser) {
this.newsStatusOfUser.collectStatus = this.newsStatusOfUser?.collectStatus === 1 ? 0 : 1
this.queryContentInteractCount()
}
})
}
/**
* 查询点赞、收藏数量
*/
queryContentInteractCount() {
const params: contentListParams = {
contentList: [{
contentId: this.contentDetailData?.newsId + '',
contentType: this.contentDetailData?.newsType,
}]
}
ContentDetailRequest.getContentInteract(params).then(res => {
if (res.data && this.interactData) {
this.interactData.likeNum = res.data[0]?.likeNum
this.interactData.collectNum = res.data[0]?.collectNum
this.interactData.commentNum = res.data[0]?.commentNum
}
console.log('获取互动点赞等数据===', JSON.stringify(res))
})
}
build() {
// List({ space: 0, initialIndex: 0 }) {
// ForEach(this.operationList, (item: OperationItem, index: number) => {
// ListItem() {
// this.buildOperationItem(item, index)
// }
// }, (item: OperationItem, index: number) => JSON.stringify(item))
// }
// .width(48)
// .height(250)
// // .margin({ bottom: 100 })
// .backgroundColor(Color.Red)
// // .listDirection(Axis.Vertical) // 默认值:Axis.Vertical
// // .lanes(this.buildLanes()) // 行/列数,一列 // 默认值:1
// .cachedCount(2)
// .scrollBar(BarState.Off)
// .nestedScroll({
// scrollForward: NestedScrollMode.PARENT_FIRST,
// scrollBackward: NestedScrollMode.SELF_FIRST
// })
Column() {
this.buildUserComp()
... ... @@ -74,32 +139,34 @@ export struct OperationListView {
.width(48)
}
getImgUrl() {
return this.contentDetailData?.rmhInfo?.rmhHeadUrl || this.contentDetailData?.userInfo?.userHeadUrl
}
@Builder
buildUserComp() {
Column() {
Image(this.rmhInfo?.rmhHeadUrl || this.userInfo?.userHeadUrl)
if (this.getImgUrl()) {
Image(this.getImgUrl())
.width('100%')
.borderRadius(24)
.aspectRatio(1)
.border({ width: 1, color: Color.White, style: BorderStyle.Solid })
.margin({ bottom: 30 })
}.width(48)
}
}.margin({ bottom: 30 })
}
/**
* 组件项
*
* @param programmeBean item 组件项
*/
@Builder
buildOperationItem(item: OperationItem, index: number) {
Column() {
Image(item.icon)
if (item.text === '赞') {
Image(this.newsStatusOfUser?.likeStatus == '0' ? item.icon : item.icon_check)
.width(32)
.aspectRatio(1)
// .borderRadius(6)
if (item.text === '赞') {
Text(this.interactData.likeNum ? (this.interactData.likeNum + '') : item.text)
.onClick(() => {
this.toggleLikeStatus()
})
Text(this.interactData?.likeNum ? (this.interactData.likeNum + '') : item.text)
.width('100%')// .margin({ top: 4, left: 6, right: 6 })// .backgroundColor(Color.Brown)
.fontWeight(500)
.textAlign(TextAlign.Center)
... ... @@ -108,7 +175,13 @@ export struct OperationListView {
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
} else if (item.text === '收藏') {
Text(this.interactData.collectNum ? (this.interactData.collectNum + '') : item.text)
Image(this.newsStatusOfUser?.collectStatus == 0 ? item.icon : item.icon_check)
.width(32)
.aspectRatio(1)
.onClick(() => {
this.toggleCollectStatus()
})
Text(this.interactData?.collectNum ? (this.interactData.collectNum + '') : item.text)
.width('100%')// .margin({ top: 4, left: 6, right: 6 })// .backgroundColor(Color.Brown)
.fontWeight(500)
.textAlign(TextAlign.Center)
... ... @@ -117,7 +190,10 @@ export struct OperationListView {
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
} else if (item.text === '抢首评') {
Text(this.interactData.commentNum ? (this.interactData.commentNum + '') : item.text)
Image(item.icon)
.width(32)
.aspectRatio(1)
Text(this.interactData?.commentNum ? (this.interactData.commentNum + '') : item.text)
.width('100%')// .margin({ top: 4, left: 6, right: 6 })// .backgroundColor(Color.Brown)
.fontWeight(500)
.textAlign(TextAlign.Center)
... ... @@ -126,6 +202,9 @@ export struct OperationListView {
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
} else {
Image(item.icon)
.width(32)
.aspectRatio(1)
Text(item.text)
.width('100%')// .margin({ top: 4, left: 6, right: 6 })// .backgroundColor(Color.Brown)
.fontWeight(500)
... ... @@ -142,9 +221,10 @@ export struct OperationListView {
// .backgroundColor(Color.Black)
.alignItems(HorizontalAlign.Center)
.hoverEffect(HoverEffect.Scale)
.onClick((event: ClickEvent) => {
console.info(TAG, `buildOperationItem onClick event index: ${index}`);
// ToastUtils.showToast('体验版,本功能暂未开发', 1000);
})
// .onClick((event: ClickEvent) => {
// console.info(TAG, `buildOperationItem onClick event index: ${index}`);
// // ToastUtils.showToast('体验版,本功能暂未开发', 1000);
// })
}
}
\ No newline at end of file
... ...
... ... @@ -5,18 +5,15 @@ import { WindowModel } from 'wdKit';
import { WDPlayerController } from 'wdPlayer';
import { devicePLSensorManager } from 'wdDetailPlayApi';
import { OperationListView } from './OperationListView';
import { RmhInfoDTO, UserInfoDTO } from 'wdBean/Index';
import { ContentDetailDTO, RmhInfoDTO, UserInfoDTO } from 'wdBean/Index';
@Component
export struct PlayerTitleComment {
private playerController?: WDPlayerController;
@Consume newsSourceName?: string
@Consume newsTitle?: string
@Consume editorName?: string
@Consume newsSummary?: string;
@State @Watch('watchSpeed') playSpeed: number = 1;
@Consume isFullScreen: boolean;
@State comment: string = '';
@Consume contentDetailData: ContentDetailDTO | undefined
@Consume isFullScreen: boolean;
@Consume progressVal: number;
@Consume videoLandScape?: number
... ... @@ -27,6 +24,14 @@ export struct PlayerTitleComment {
this.playerController?.setSpeed(this.playSpeed);
}
getName() {
return this.contentDetailData?.newsSourceName || this.contentDetailData?.editorName
}
getTitle() {
return this.contentDetailData?.newsTitle || this.contentDetailData?.newsSummary
}
build() {
Column() {
// Column() {
... ... @@ -59,15 +64,15 @@ export struct PlayerTitleComment {
Row() {
Column() {
if (this.newsSourceName || this.editorName) {
Text("@" + (this.newsSourceName || this.editorName))
if (this.getName()) {
Text("@" + this.getName())
.fontColor(Color.White)
.fontSize(15)
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
}
if (this.newsTitle || this.newsSummary) {
Text(this.newsTitle || this.newsSummary)
if (this.getTitle()) {
Text(this.getTitle())
.fontColor(Color.White)
.fontSize(15)
.maxLines(3)
... ... @@ -134,7 +139,6 @@ export struct PlayerTitleComment {
})
TextInput({ placeholder: '说两句...', text: this.comment })
.placeholderColor(Color.White)
.placeholderFont({ size: 14 })
.fontColor(Color.White)
... ...
... ... @@ -20,6 +20,7 @@ export class WDPlayerController {
public onTimeUpdate?: (position: number, duration: number) => void;
public onVolumeUpdate?: (volume: number) => void;
public continue?: () => void;
public onCanplay?: () => void;
constructor() {
Logger.error("初始化")
... ... @@ -74,6 +75,9 @@ export class WDPlayerController {
}
// this.avPlayer.play();
this.duration = this.avPlayer.duration;
if (this.onCanplay) {
this.onCanplay()
}
break;
case AVPlayerStatus.PLAYING:
this.setBright();
... ... @@ -143,13 +147,15 @@ export class WDPlayerController {
}
async release() {
if (this.avPlayer == null) {
await this.initPromise;
}
// if (this.avPlayer == null) {
// await this.initPromise;
// }
if (this.avPlayer == null) {
return
}
this.avPlayer.release();
this.avPlayer.release()
this.avPlayer = undefined
}
async pause() {
... ... @@ -250,6 +256,10 @@ export class WDPlayerController {
return this.status;
}
getPlayer() {
return this.avPlayer;
}
initProgress(time: number) {
let nowSeconds = Math.floor(time / 1000);
let totalSeconds = Math.floor(this.duration / 1000);
... ...
... ... @@ -74,7 +74,7 @@ export struct WDPlayerRenderView {
Row() {
// 设置为“surface“类型时XComponent组件可以和其他组件一起进行布局和渲染。
XComponent({
id: 'xComponentId112233',
id: 'xComponentId',
type: 'surface',
controller: this.xComponentController
})
... ...