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
zhenghy
2024-04-02 21:14:54 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
eea8ef93d6af052ca686a1a7d3b81f0dff186443
eea8ef93
1 parent
03c1b7b2
播放器创建与销毁
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
158 additions
and
61 deletions
sight_harmony/commons/wdNetwork/src/main/ets/http/HttpUrlUtils.ets
sight_harmony/features/wdDetailPlayApi/src/main/ets/request/ContentDetailRequest.ets
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/Test.ets
sight_harmony/features/wdDetailPlayShortVideo/src/main/ets/view/OperationListView.ets
sight_harmony/features/wdDetailPlayShortVideo/src/main/resources/base/profile/main_pages.json
sight_harmony/features/wdPlayer/src/main/ets/controller/WDPlayerController.ets
sight_harmony/commons/wdNetwork/src/main/ets/http/HttpUrlUtils.ets
View file @
eea8ef9
...
...
@@ -56,6 +56,10 @@ export class HttpUrlUtils {
*/
static readonly INTERACT_EXECUTECOLLECTRECORD: string = "/api/rmrb-interact/interact/zh/c/collect/executeCollcetRecord";
/**
* 关注号主
*/
static readonly INTERACT_ACCENTION_OPERATION: string = "/api/rmrb-interact/interact/zh/c/attention/operation";
/**
* 用户等级/积分-APP根据业务场景动态增减成长值(APP)
*/
static readonly USERPOINT_OPERATE: string = "/api/rmrb-user-point/auth/pointLevel/zh/operate";
...
...
@@ -144,12 +148,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";
/**
* 点赞操作
*/
...
...
@@ -169,11 +171,12 @@ 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_
PRODUC
T;
private static _hostUrl: string = HttpUrlUtils.HOST_
UA
T;
public static set hostUrl(value: string) {
HttpUrlUtils._hostUrl = value;
}
private static userId = ''
private static userType = ''
private static token = ''
...
...
@@ -189,8 +192,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())
...
...
@@ -271,19 +274,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 '';
...
...
@@ -347,18 +350,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;
}
...
...
sight_harmony/features/wdDetailPlayApi/src/main/ets/request/ContentDetailRequest.ets
View file @
eea8ef9
...
...
@@ -116,6 +116,16 @@ export interface postInteractBrowsOperateParams {
contentList: postInteractBrowsOperateParamsContent[]
}
export interface postInteractAccentionOperateParams {
attentionUserType: string;
attentionUserId: string;
attentionCreatorId: string;
// userType: number;
// userId: string;
status: number;
}
export class ContentDetailRequest {
static getContentDetailDataMock(context: Context): Promise<ResponseDTO<ContentDetailDTO[]>> {
Logger.info(TAG, `getContentDetailDataMock start`);
...
...
@@ -191,7 +201,7 @@ export class ContentDetailRequest {
}
/**
*用户点赞、取消点赞
*
用户点赞、取消点赞
* @param params
* @returns
*/
...
...
@@ -202,7 +212,7 @@ export class ContentDetailRequest {
}
/**
*用户收藏、取消收藏
*
用户收藏、取消收藏
* @param params
* @returns
*/
...
...
@@ -240,4 +250,13 @@ export class ContentDetailRequest {
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.post0(url, params, headers)
}
/**
* 关注号主
*/
static postInteractAccentionOperate(params: postInteractAccentionOperateParams): Promise<ResponseDTO> {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_ACCENTION_OPERATION
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.post0(url, params, headers)
}
}
\ No newline at end of file
...
...
sight_harmony/features/wdDetailPlayShortVideo/src/main/ets/pages/DetailPlayShortVideoPage.ets
View file @
eea8ef9
...
...
@@ -37,16 +37,19 @@ export struct DetailPlayShortVideoPage {
if (this.currentIndex != this.index) {
this.playerController.pause()
// if (this.index < this.currentIndex - 5 && this.playerController.getPlayer()) {
// this.playerController.release()
// }
if (this.index < this.currentIndex - 5 && this.playerController.getPlayer()) {
this.playerController.release()
}
} else {
this.queryNewsInfoOfUser()
console.log('currentIndex==== ', this.currentIndex)
if (!this.playerController.getPlayer()) {
console.error('state91111111===', this.contentDetailData?.videoInfo[0]?.videoUrl || '')
this.playerController.firstPlay(this.contentDetailData?.videoInfo[0]?.videoUrl || '');
console.error('state91111111===', this.playerController?.getPlayer()?.state)
} else {
console.error('state9===', this.playerController?.getPlayer()?.state)
this.playerController.play()
}
...
...
@@ -103,7 +106,7 @@ export struct DetailPlayShortVideoPage {
}
aboutToAppear() {
console.log('开始设置setContentDetailData', JSON.stringify(this.contentDetailData))
//
console.log('开始设置setContentDetailData', JSON.stringify(this.contentDetailData))
this.videoLandScape = this.contentDetailData?.videoInfo[0]?.videoLandScape
this.queryNewsInfoOfUser()
this.playerController.onCanplay = () => {
...
...
@@ -136,7 +139,8 @@ export struct DetailPlayShortVideoPage {
}
aboutToDisappear(): void {
this.playerController?.pause();
console.log('aboutToDisappear', this.index)
this.playerController?.release();
// this.playerController.onCanplay = ()={}
}
...
...
@@ -153,7 +157,7 @@ export struct DetailPlayShortVideoPage {
WDPlayerRenderView({
playerController: this.playerController,
onLoad: async () => {
console.log('onload==',
)
// console.log('onload==', this.index
)
// if (this.index === 0) {
this.playerController.firstPlay(this.contentDetailData?.videoInfo[0]?.videoUrl);
// }
...
...
sight_harmony/features/wdDetailPlayShortVideo/src/main/ets/pages/DetailVideoListPage.ets
View file @
eea8ef9
...
...
@@ -91,11 +91,8 @@ export struct DetailVideoListPage {
if (res.data) {
this.data = this.data.concat(res.data)
}
console.log('queryVideoList===', JSON.stringify(this.data))
// console.log('queryVideoList===', JSON.stringify(this.data))
})
}
build() {
...
...
sight_harmony/features/wdDetailPlayShortVideo/src/main/ets/pages/Test.ets
View file @
eea8ef9
@
Entry
@
Preview
@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)
}
RelativeContainer() {
Image($r('app.media.ic_like_uncheck'))
.width('100%')
.borderRadius(24)
.aspectRatio(1)
.border({ width: 1, color: Color.White, style: BorderStyle.Solid })
.alignRules({
top: { anchor: "__container__", align: VerticalAlign.Top },
left: { anchor: "__container__", align: HorizontalAlign.Start }
})
.id("row1")
Image($r('app.media.ic_add'))
.width(24)
.borderRadius(12)
.alignRules({
left: { anchor: "__container__", align: HorizontalAlign.Center },
bottom: { anchor: "__container__", align: VerticalAlign.Bottom },
})
.margin({ left: -12 })
.id("row2")
}.height('auto')
}
.height(58)
.width(48)
.backgroundColor(Color.Black)
}
}
\ No newline at end of file
...
...
sight_harmony/features/wdDetailPlayShortVideo/src/main/ets/view/OperationListView.ets
View file @
eea8ef9
...
...
@@ -5,7 +5,8 @@ import {
ContentDetailRequest,
contentListParams,
postExecuteCollectRecordParams,
postExecuteLikeParams
postExecuteLikeParams,
postInteractAccentionOperateParams
} from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest';
import { ToastUtils } from 'wdKit';
import { HttpUrlUtils } from 'wdNetwork/Index';
...
...
@@ -30,6 +31,7 @@ export struct OperationListView {
@Consume interactData: InteractDataDTO
@Consume contentDetailData: ContentDetailDTO
@Consume newsStatusOfUser: batchLikeAndCollectResult
@Consume followStatus: string
@State operationList: OperationItem[] = [
{
icon: $r('app.media.ic_like_uncheck'),
...
...
@@ -128,30 +130,73 @@ export struct OperationListView {
})
}
build() {
Column() {
this.buildUserComp()
ForEach(this.operationList, (item: OperationItem, index: number) => {
this.buildOperationItem(item, index)
}, (item: OperationItem, index: number) => JSON.stringify(item))
getImgUrl() {
return this.contentDetailData?.rmhInfo?.rmhHeadUrl || this.contentDetailData?.userInfo?.userHeadUrl
}
.width(48)
/**
* 关注号主
*/
handleAccention() {
// 未登录,跳转登录
if (!HttpUrlUtils.getUserId()) {
WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
return
}
getImgUrl() {
return this.contentDetailData?.rmhInfo?.rmhHeadUrl || this.contentDetailData?.userInfo?.userHeadUrl
const params2: postInteractAccentionOperateParams = {
attentionUserType: this.contentDetailData?.rmhInfo?.userType || '', //被关注用户类型(1 普通用户 2 视频号 3 矩阵号)
attentionUserId: this.contentDetailData?.rmhInfo?.userId || '', // 被关注用户号主id
attentionCreatorId: this.contentDetailData?.rmhInfo?.rmhId || '', // 被关注用户号主id
// userType: 1,
// userId: '1',
status: 1,
}
ContentDetailRequest.postInteractAccentionOperate(params2).then(res => {
console.log('关注号主==', JSON.stringify(res.data))
if (this.followStatus == '1') {
this.followStatus = '0'
} else {
this.followStatus = '1'
}
})
}
@Builder
buildUserComp() {
Column() {
if (this.getImgUrl()) {
RelativeContainer() {
Image(this.getImgUrl())
.width('100%')
.borderRadius(24)
.aspectRatio(1)
.border({ width: 1, color: Color.White, style: BorderStyle.Solid })
.alignRules({
top: { anchor: "__container__", align: VerticalAlign.Top },
left: { anchor: "__container__", align: HorizontalAlign.Start }
})
.id("row1")
.onClick(() => {
// 号主页
})
if (this.followStatus == '0') {
Image($r('app.media.ic_add'))
.width(24)
.borderRadius(12)
.alignRules({
left: { anchor: "__container__", align: HorizontalAlign.Center },
bottom: { anchor: "__container__", align: VerticalAlign.Bottom },
})
.margin({ left: -12 })
.id("row2")
.onClick(() => {
// 关注
this.handleAccention()
})
}
}.height(60)
}
}.margin({ bottom: 30 })
}
...
...
@@ -160,7 +205,7 @@ export struct OperationListView {
buildOperationItem(item: OperationItem, index: number) {
Column() {
if (item.text === '赞') {
Image(this.newsStatusOfUser?.likeStatus == '
0' ? item.icon : item.icon_check
)
Image(this.newsStatusOfUser?.likeStatus == '
1' ? item.icon_check : item.icon
)
.width(32)
.aspectRatio(1)
.onClick(() => {
...
...
@@ -175,7 +220,7 @@ export struct OperationListView {
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
} else if (item.text === '收藏') {
Image(this.newsStatusOfUser?.collectStatus ==
0 ? item.icon : item.icon_check
)
Image(this.newsStatusOfUser?.collectStatus ==
1 ? item.icon_check : item.icon
)
.width(32)
.aspectRatio(1)
.onClick(() => {
...
...
@@ -193,6 +238,9 @@ export struct OperationListView {
Image(item.icon)
.width(32)
.aspectRatio(1)
.onClick((event: ClickEvent) => {
ToastUtils.showToast('评论为公共方法,待开发', 1000);
})
Text(this.interactData?.commentNum ? (this.interactData.commentNum + '') : item.text)
.width('100%')// .margin({ top: 4, left: 6, right: 6 })// .backgroundColor(Color.Brown)
.fontWeight(500)
...
...
@@ -205,6 +253,9 @@ export struct OperationListView {
Image(item.icon)
.width(32)
.aspectRatio(1)
.onClick((event: ClickEvent) => {
ToastUtils.showToast('分享为公共方法,待开发', 1000);
})
Text(item.text)
.width('100%')// .margin({ top: 4, left: 6, right: 6 })// .backgroundColor(Color.Brown)
.fontWeight(500)
...
...
@@ -216,15 +267,20 @@ export struct OperationListView {
}
}
.width(32
)
// .width(48
)
.margin({ bottom: 20 })
// .backgroundColor(Color.Black)
.alignItems(HorizontalAlign.Center)
.hoverEffect(HoverEffect.Scale)
// .onClick((event: ClickEvent) => {
// console.info(TAG, `buildOperationItem onClick event index: ${index}`);
// // ToastUtils.showToast('体验版,本功能暂未开发', 1000);
// })
}
build() {
Column() {
this.buildUserComp()
ForEach(this.operationList, (item: OperationItem, index: number) => {
this.buildOperationItem(item, index)
}, (item: OperationItem, index: number) => JSON.stringify(item))
}
.width(48)
}
}
\ No newline at end of file
...
...
sight_harmony/features/wdDetailPlayShortVideo/src/main/resources/base/profile/main_pages.json
View file @
eea8ef9
{
"src"
:
[
"pages/DetailVideoListPage"
,
"pages/Test"
"pages/DetailVideoListPage"
]
}
\ No newline at end of file
...
...
sight_harmony/features/wdPlayer/src/main/ets/controller/WDPlayerController.ets
View file @
eea8ef9
...
...
@@ -2,6 +2,7 @@ import media from '@ohos.multimedia.media';
import prompt from '@ohos.promptAction';
import { Logger } from '../utils/Logger';
import { PlayerConstants, AVPlayerStatus, Events } from '../constants/PlayerConstants';
import { BusinessError } from '@ohos.base';
@Observed
export class WDPlayerController {
...
...
@@ -44,7 +45,10 @@ export class WDPlayerController {
Logger.error('[PlayVideoModel] createAvPlayer fail!');
reject();
}
}).catch((error: BusinessError) => {
console.error(`AVPlayer catchCallback, error message:${error.message}`);
});
;
});
}
...
...
Please
register
or
login
to post a comment