zhangfengjin

Merge remote-tracking branch 'origin/main'

Showing 39 changed files with 1294 additions and 95 deletions
... ... @@ -6,6 +6,7 @@ import { CardMediaInfo } from '../cardCommon/CardMediaInfo';
import { CardSourceInfo } from '../cardCommon/CardSourceInfo';
import { Notes } from './notes';
import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
// import { persistentStorage, hasClicked } from '../../utils/persistentStorage';
const TAG: string = 'Card2Component';
... ... @@ -24,6 +25,7 @@ export struct Card2Component {
async aboutToAppear(): Promise<void> {
this.loadImg = await onlyWifiLoadImg();
// this.clicked = hasClicked(this.contentDTO.objectId)
}
build() {
... ... @@ -75,6 +77,7 @@ export struct Card2Component {
})
.onClick((event: ClickEvent) => {
this.clicked = true;
// persistentStorage(this.contentDTO.objectId);
ProcessUtils.processPage(this.contentDTO)
})
}
... ...
... ... @@ -5,6 +5,7 @@ import { CardSourceInfo } from '../cardCommon/CardSourceInfo';
import { CardMediaInfo } from '../cardCommon/CardMediaInfo';
import { Notes } from './notes';
import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
// import { persistentStorage, hasClicked } from '../../utils/persistentStorage';
const TAG: string = 'Card6Component-Card13Component';
... ... @@ -19,6 +20,7 @@ export struct Card6Component {
async aboutToAppear(): Promise<void> {
this.loadImg = await onlyWifiLoadImg();
// this.clicked = hasClicked(this.contentDTO.objectId)
}
build() {
... ... @@ -78,6 +80,7 @@ export struct Card6Component {
}
.onClick((event: ClickEvent) => {
this.clicked = true;
// persistentStorage(this.contentDTO.objectId);
ProcessUtils.processPage(this.contentDTO)
})
.padding({
... ...
... ... @@ -68,7 +68,7 @@ export class commentItemModel {
fromUserHeader: string = ''
fromUserId: string = ''
fromUserName: string = ''
fromUserType: WDPublicUserType = 0
fromUserType: WDPublicUserType = 1
id: string = ''
likeNum: string = '0'
mySelf: string = ''
... ...
... ... @@ -3,8 +3,8 @@ import curves from '@ohos.curves';
import { BusinessError } from '@ohos.base';
import display from '@ohos.display';
const collapseString = '...展开全文'
const uncollapseString = '...收起'
const collapseString = '...展开'
const uncollapseString = ' 收起'
const TestLongText = "超过三行超\n过三行超过\n三行超超过三行\n超过三行超过三行超过三\n行超过"
... ... @@ -129,7 +129,9 @@ export struct CommentText {
// Stack({ alignContent: Alignment.BottomEnd }) {
Text(this.longMessage) {
Span(this.expandedStates ? this.longMessage : this.maxLineMesssage)
Span(this.collapseText).onClick(() => {
Span(this.collapseText)
.fontColor("#999999")
.onClick(() => {
if (this.collapseText == collapseString) {
this.collapseText = uncollapseString;
this.expandedStates = true;
... ...
... ... @@ -26,7 +26,7 @@ export struct QualityCommentsComponent {
private scroller: Scroller = new Scroller();
@State tileOpacity: number = 0;
firstPositionY: number = 0;
bottomSafeHeight: string = AppStorage.get<number>('bottomSafeHeight') + 'px';
bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0;
topSafeHeight: number = AppStorage.get<number>('topSafeHeight') as number;
lastWindowColor: string = '#ffffff'
currentWindowColor: string = '#FF4202'
... ... @@ -247,9 +247,9 @@ export struct QualityCommentsComponent {
ListItem() {
if (this.hasMore === false) NoMoreLayout()
}
ListItem() {
}.height(this.bottomSafeHeight)
// ListItem() {
//
// }.height(this.bottomSafeHeight)
}.onReachEnd(()=>{
this.currentPage++
this.getData()
... ... @@ -257,8 +257,7 @@ export struct QualityCommentsComponent {
.margin({ top: 196 })
.height("100%")
.width("100%")
// .edgeEffect(EdgeEffect.None) // 必须设置列表为滑动到边缘无效果
.edgeEffect(EdgeEffect.Spring)
.edgeEffect(EdgeEffect.None) // 必须设置列表为滑动到边缘无效果
.nestedScroll({
scrollForward: NestedScrollMode.PARENT_FIRST,
scrollBackward: NestedScrollMode.SELF_FIRST
... ... @@ -352,7 +351,7 @@ struct QualityCommentItem {
Row() {
Row() {
Image($r('app.media.comment_img_link')).width(16).height(16)
Text(this.item.shareInfo.shareTitle)
Text(this.item.targetTitle)
.fontSize(14)
.fontColor('#666666')
.margin({ left: 6, right: 12 })
... ...
... ... @@ -485,10 +485,13 @@ class CommentViewModel {
jumpToAccountPage(commentItem: commentItemModel) {
let url = HttpUrlUtils.getOtherUserDetailDataUrl()
let item : Record<string, string >= {
"creatorId": commentItem.fromCreatorId || "",
"userType": `${commentItem.fromUserType}`,
"userId": commentItem.fromUserId || "-1",
let item : Record<string, string >= {}
if (commentItem.fromCreatorId) {
item["creatorId"] = commentItem.fromCreatorId
} else {
item["userType"] = `${commentItem.fromUserType}`
item["userId"] = commentItem.fromUserId
}
HttpBizUtil.post<ResponseDTO<MasterDetailRes>>(url, item).then((result) => {
if (!result.data || result.data.mainControl != 1) {
... ...
import { EmitterUtils, EmitterEventId, Logger } from 'wdKit/Index'
import { EmitterUtils, EmitterEventId, Logger, NetworkUtil } from 'wdKit/Index'
import MinePageDatasModel from '../../../model/MinePageDatasModel'
import { FollowListItem } from '../../../viewmodel/FollowListItem'
import { CustomTitleUI } from '../../reusable/CustomTitleUI'
import { EmptyComponent } from '../../view/EmptyComponent'
import { FollowSecondTabsComponent } from './FollowSecondTabsComponent'
const TAG = "FollowFirstTabsComponent"
@Component
... ... @@ -12,8 +13,19 @@ export struct FollowFirstTabsComponent{
@State data:FollowListItem[] = []
fontColor: string = '#999999'
selectedFontColor: string = '#000000'
@State isConnectNetwork : boolean = NetworkUtil.isNetConnected()
aboutToAppear(){
this.getFollowTabList()
EmitterUtils.receiveEvent(EmitterEventId.MY_FOLLOW_EMPTY, (() => {
if(this.controller != null && this.data.length>1 ){
this.jumpFollowNextPage()
}
}))
}
getFollowTabList(){
MinePageDatasModel.getFollowListData(getContext(this)).then((value)=>{
this.data.push(new FollowListItem("我的"))
value.forEach((element)=>{
... ... @@ -26,12 +38,6 @@ export struct FollowFirstTabsComponent{
}).catch((err:Error)=>{
console.log(TAG,JSON.stringify(err))
})
EmitterUtils.receiveEvent(EmitterEventId.MY_FOLLOW_EMPTY, (() => {
if(this.controller != null && this.data.length>1 ){
this.jumpFollowNextPage()
}
}))
}
jumpFollowNextPage(){
... ... @@ -75,6 +81,13 @@ export struct FollowFirstTabsComponent{
//标题栏目
CustomTitleUI({titleName:"关注列表"})
if(!this.isConnectNetwork){
EmptyComponent({ emptyType: 1,emptyHeight:"100%" ,retry: () => {
this.reloadNetWork()
},})
.layoutWeight(1)
.width('100%')
}else{
Tabs({ barPosition: BarPosition.Start, controller: this.controller }) {
ForEach(this.data, (item: FollowListItem, index: number ) => {
TabContent(){
... ... @@ -93,6 +106,15 @@ export struct FollowFirstTabsComponent{
})
.width('100%')
.layoutWeight(1)
}
}.width('100%')
}
reloadNetWork(){
let c = NetworkUtil.isNetConnected()
if(c){
this.getFollowTabList()
this.isConnectNetwork = c
}
}
}
\ No newline at end of file
... ...
import { EmitterEventId, EmitterUtils, LazyDataSource, SPHelper, UserDataLocal } from 'wdKit';
import { EmitterEventId, EmitterUtils, LazyDataSource, NetworkUtil, SPHelper, UserDataLocal } from 'wdKit';
import MinePageDatasModel from '../../../model/MinePageDatasModel';
import SearcherAboutDataModel from '../../../model/SearcherAboutDataModel';
import { CreatorDetailRequestItem } from '../../../viewmodel/CreatorDetailRequestItem';
... ... @@ -70,7 +70,11 @@ export struct FollowListDetailUI {
Column() {
if (this.count === 0) {
if (this.isGetRequest == true) {
if(this.creatorDirectoryId === -1){
if(!NetworkUtil.isNetConnected()){
EmptyComponent({ emptyType: 1,emptyHeight:"100%" })
.layoutWeight(1)
.width('100%')
}else if(this.creatorDirectoryId === -1){
EmptyComponent({ emptyType: 14,emptyHeight:"100%" })
.layoutWeight(1)
.width('100%')
... ...
... ... @@ -3,6 +3,7 @@ import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'
import { WDMessageCenterMessageType } from '../../../model/InteractMessageModel'
import MinePageDatasModel from '../../../model/MinePageDatasModel'
import { MessageItem } from '../../../viewmodel/MessageItem'
import { CustomPullToRefresh } from '../../reusable/CustomPullToRefresh'
import { CustomTitleUI } from '../../reusable/CustomTitleUI'
import { MessageListItemUI } from './MessageListItemUI'
... ... @@ -11,6 +12,7 @@ const TAG = "MessageListUI"
@Component
export struct MessageListUI {
@State msgData: MessageItem[] = []
private scroller: Scroller = new Scroller();
aboutToAppear() {
this.msgData = MinePageDatasModel.getMessageData()
... ... @@ -138,7 +140,27 @@ export struct MessageListUI {
//标题栏目
CustomTitleUI({ titleName: "消息" })
List() {
CustomPullToRefresh({
alldata:this.msgData,
scroller:this.scroller,
customList:()=>{
this.ListLayout()
},
onRefresh:(resolve)=>{
if(resolve) resolve('刷新成功')
},
onLoadMore:(resolve)=> {
}
})
}
.backgroundColor($r('app.color.white'))
.height('100%')
.width('100%')
}
@Builder ListLayout(){
List({scroller: this.scroller}) {
ForEach(this.msgData, (item: MessageItem, index: number) => {
ListItem() {
MessageListItemUI({ item: item, index: index })
... ... @@ -169,14 +191,21 @@ export struct MessageListUI {
})
}
}
.backgroundColor($r('app.color.white'))
.height('100%')
.width('100%')
}
sendEnterEvent(type:number){
MinePageDatasModel.sendEnterMessageData(type).then((value) => {
console.log(TAG, "消息已读")
this.msgData.forEach((item) => {
if (item.title == "预约消息" && type === 2) {
if(item.unReadCount > 0){
item.unReadCount = 0
}
}else if(item.title == "互动消息" && type === 1){
if(item.unReadCount > 0){
item.unReadCount = 0
}
}
})
}).catch((err: Error) => {
console.log(TAG, JSON.stringify(err))
})
... ...
... ... @@ -2,6 +2,7 @@ import { LazyDataSource, StringUtils } from 'wdKit/Index';
import { Remark, SubscribeMessageModel,
WDMessageCenterMessageType } from '../../../../model/InteractMessageModel';
import MinePageDatasModel from '../../../../model/MinePageDatasModel';
import { CustomPullToRefresh } from '../../../reusable/CustomPullToRefresh';
import { CustomTitleUI } from '../../../reusable/CustomTitleUI';
import { ListHasNoMoreDataUI } from '../../../reusable/ListHasNoMoreDataUI';
import { EmptyComponent } from '../../../view/EmptyComponent';
... ... @@ -17,6 +18,7 @@ export struct SubscribeMessageComponent{
@State hasMore: boolean = true
curPageNum: number = 1;
@State isGetRequest: boolean = false
private scroller: Scroller = new Scroller();
aboutToAppear() {
this.getNewPageData()
... ... @@ -32,19 +34,44 @@ export struct SubscribeMessageComponent{
.height('100%')
.width('100%')
}
} else {
//刷新控件 TODO
//List
List() {
CustomPullToRefresh({
alldata:this.data,
scroller:this.scroller,
customList:()=>{
this.ListLayout()
},
onRefresh:(resolve)=>{
this.curPageNum = 1;
this.hasMore = true
this.isGetRequest = false
this.data.clear()
if (!this.isLoading) {
this.getNewPageData()
}
if(resolve) resolve('刷新成功')
},
onLoadMore:(resolve)=> {
if (!this.isLoading) {
//加载分页数据
this.getNewPageData()
}
}
})
}
}
.backgroundColor($r('app.color.color_F9F9F9'))
.height('100%')
.width('100%')
}
@Builder ListLayout(){
List({scroller: this.scroller}) {
LazyForEach(this.data, (item: SubscribeMessageModel, index: number) => {
ListItem() {
SubscribeListChildComponent({ item: item })
}.width('100%')
.onClick(() => {
})
})
//没有更多数据 显示提示
if (!this.hasMore) {
ListItem() {
... ... @@ -55,17 +82,6 @@ export struct SubscribeMessageComponent{
.cachedCount(4)
.scrollBar(BarState.Off)
.layoutWeight(1)
.onReachEnd(() => {
if (!this.isLoading) {
//加载分页数据
this.getNewPageData()
}
})
}
}
.backgroundColor($r('app.color.color_F9F9F9'))
.height('100%')
.width('100%')
}
getNewPageData() {
... ...
... ... @@ -67,7 +67,9 @@ export struct PrivacySettingPage {
getArrowCell({ item:item, index:index });
}
}.onClick(() => {
if (index != 0) {
if (item.privacyName == DiyString) {
return
}
if (!item.permission) {
//跳转权限设置
const permissionUtil = new PermissionUtil();
... ... @@ -77,7 +79,6 @@ export struct PrivacySettingPage {
}else{
PermissionUtil.openPermissionsInSystemSettings(this);
}
}
})
})
}
... ...
... ... @@ -129,7 +129,7 @@ struct ReserveMorePage {
Stack() {
Image(item.fullColumnImgUrls[0]?.url)
.width('100%')
.height(196)
.objectFit(ImageFit.Contain)
.borderRadius(4)
this.LiveImage()
... ... @@ -283,7 +283,7 @@ struct ReserveMorePage {
.fontWeight(400)
.fontColor(Color.White)
}
.backgroundColor('#4D000000')
.backgroundColor(Color.Transparent)
.margin({ right: 8, bottom: 8 })
}
... ...
... ... @@ -16,7 +16,7 @@ export struct SearchHistoryComponent{
confirm: () => {
this.onAccept()
},
title: "确认清空历史记录",
title: "确认清空历史记录",
tipShow:false,
leftTextColor:$r('app.color.color_648DF2')
}),
... ... @@ -51,7 +51,7 @@ export struct SearchHistoryComponent{
.height('31lpx')
.width('31lpx')
.interpolation(ImageInterpolation.High)
.objectFit(ImageFit.Cover)
.objectFit(ImageFit.Auto)
.onClick(()=>{
//弹框提示
this.dialogController.open()
... ...
... ... @@ -234,7 +234,9 @@ export struct AccountAndSecurityLayout {
RelativeContainer() {
Text('注销账号')
.fontColor('#FF333333')
.fontSize(18)
.fontSize("35lpx")
.fontWeight(400)
.lineHeight("50lpx")
.textAlign(TextAlign.Center)
.height(44)
.alignRules({
... ... @@ -265,51 +267,52 @@ export struct AccountAndSecurityLayout {
Text('为保证您的账号安全,在您提交的注销申请生效前,需同时满足以下几个条件:')
.fontColor('#FF222222')
.fontSize(16)
.fontWeight(600)
.padding({ top:17,left: 16, right: 16 })
.lineHeight("42lpx")
.fontSize("31lpx")
.padding({ top:17,left: "31lpx", right: "31lpx" })
.width('100%')
Text('1. 账号处于安全状态')
.fontColor('#FF222222')
.fontSize(16)
.fontWeight(600)
.padding({ top: 24, left: 16 })
.padding({ top: 24, left: "62lpx" })
.width('100%')
Text('账号处于正常使用状态,无被盗风险。')
.fontColor('#FF666666')
.fontSize(14)
.fontWeight(400)
.padding({ top: 8, left: 16 })
.padding({ top: 8, left: "62lpx" })
.width('100%')
Text('2. 账号权限解除')
.fontColor('#FF222222')
.fontSize(16)
.fontWeight(600)
.padding({ top: 24, left: 16 })
.padding({ top: 24, left: "62lpx" })
.width('100%')
Text('账号已解除与其他产品的授权登录或绑定关系。')
.fontColor('#FF666666')
.fontSize(14)
.fontWeight(400)
.padding({ top: 8, left: 16 })
.padding({ top: 8, left: "62lpx" })
.width('100%')
Text('3. 账号无任何纠纷,包括举报投诉')
.fontColor('#FF222222')
.fontSize(16)
.fontWeight(600)
.padding({ top: 24, left: 16 })
.padding({ top: 24, left: "62lpx" })
.width('100%')
Text('请注意:注销后7天内不能再次注册人民日报客户端,需要等到账号冷静期结束才能再次登录注册')
.fontColor('#FFED2800')
.fontSize(14)
.fontWeight(400)
.padding({ top: 32, left: 16, right: 16 })
.padding({ top: 32, left: "31lpx", right: "31lpx" })
.width('100%')
}.alignRules({
... ...
// PersistentStorage.persistProp('clickedIds', []);
//
// function persistentStorage(id: string | number, type: 'add' | 'remove' | undefined = 'add') {
// let clickedIds = AppStorage.get<string>('clickedIds')?.split(',') || [];
// let index = clickedIds.indexOf(id.toString())
// if (type === 'add') {
// if (index >= 0) return;
// clickedIds.push(id.toString());
// } else if (type === 'remove') {
// clickedIds.splice(index, 1);
// }
// AppStorage.set('clickedIds', clickedIds.join(','));
// }
//
// function hasClicked(id: string | number) {
// let clickedIds = AppStorage.get<string>('clickedIds')?.split(',') || [];
// let index = clickedIds.indexOf(id.toString())
// if (index >= 0) return true;
// return false;
// }
//
// export { persistentStorage, hasClicked }
\ No newline at end of file
... ...
... ... @@ -54,11 +54,11 @@ export struct DetailPlayShortVideoPage {
/**
* 页面显示重查用户关注、点赞等信息
*/
pageShowChange() {
async pageShowChange() {
if (this.currentIndex === this.index) {
this.queryNewsInfoOfUser()
if (this.switchVideoStatus) {
this.playerController.play()
await this.playerController.play()
this.imageVisible = false
}
}
... ... @@ -68,10 +68,10 @@ export struct DetailPlayShortVideoPage {
* 频道切换视频暂停、播放
* 页面显隐视频暂停、播放
*/
videoStatusChange() {
async videoStatusChange() {
if (this.currentIndex === this.index) {
if (this.switchVideoStatus) {
this.playerController.play()
await this.playerController.play()
this.imageVisible = false
} else {
this.playerController.pause()
... ... @@ -82,7 +82,7 @@ export struct DetailPlayShortVideoPage {
/**
* 监听下标变化手动创建或销毁视频
*/
currentIndexChange() {
async currentIndexChange() {
if (this.currentIndex != this.index) {
this.playerController.pause()
if (this.index <= this.currentIndex - 2 && this.playerController.getPlayer()) {
... ... @@ -94,7 +94,7 @@ export struct DetailPlayShortVideoPage {
if (!this.playerController.getPlayer()) {
this.playerController.firstPlay(this.contentDetailData?.videoInfo[0]?.videoUrl || '');
} else {
this.playerController.play()
await this.playerController.play()
this.imageVisible = false
}
}
... ... @@ -153,10 +153,10 @@ export struct DetailPlayShortVideoPage {
this.videoLandScape = this.contentDetailData.videoInfo[0]?.videoLandScape
this.ratio = this.contentDetailData.videoInfo[0].resolutionWidth /
this.contentDetailData.videoInfo[0].resolutionHeight
this.playerController.onCanplay = () => {
this.playerController.onCanplay = async () => {
this.ratio = this.playerController.videoWidth / this.playerController.videoHeight
if ((this.index == 0 || this.currentIndex === this.index) && this.switchVideoStatus) {
this.playerController.play()
await this.playerController.play()
this.imageVisible = false
}
}
... ... @@ -186,7 +186,7 @@ export struct DetailPlayShortVideoPage {
Stack({ alignContent: Alignment.Top }) {
Column() {
Stack() {
// this.playerCoverBuilder()
this.playerViewBuilder()
PlayerBottomView({
... ... @@ -243,16 +243,14 @@ export struct DetailPlayShortVideoPage {
*/
@Builder
playerCoverBuilder() {
// 问题:画面会闪一下
Image(this.contentDetailData?.firstFrameImageUri)
.width('100%')
.padding({
bottom: this.videoLandScape === 1 ? 115 : 0,
})// .align(this.videoLandScape === 0 ? Alignment.Top : Alignment.Center)
.fitOriginalSize(true)
.autoResize(true)
.position({ x: 0, y: this.videoLandScape === 0 ? 0 : '50%' })
.markAnchor({ y: this.videoLandScape === 0 ? 0 : '50%' })
// .visibility(this.imageVisible ? Visibility.Visible : Visibility.None)
.height(this.windowWidth / this.ratio + 'px')
.opacity(this.imageVisible ? 1 : 0)
.animation({
duration: 500, curve: Curve.EaseInOut
})
}
@Builder
... ... @@ -269,6 +267,8 @@ export struct DetailPlayShortVideoPage {
.width('100%')
.height(this.windowWidth / this.ratio + 'px')
this.playerCoverBuilder()
// .height(this.displayDirection === DisplayDirection.VIDEO_HORIZONTAL ? '100%' :
// this.videoLandScape === 1 ? 210 : 'auto')// .height(this.videoLandScape === 1 ? 210 : '100%')
// .width(this.videoLandScape === 1 ?
... ...
... ... @@ -16,7 +16,7 @@ export struct PictureLoading {
build() {
Row() {
Image(this.imagePath)
.alt($r('app.media.picture_loading'))
.alt($r('app.media.datail_imageLoading_w'))
.width(this.imageWidth)
.aspectRatio(this.ratio)
.objectFit(ImageFit.Fill)
... ...
... ... @@ -254,7 +254,8 @@ export struct VideoChannelDetail {
})
} else {
PictureLoading().visibility(this.isMouted ? Visibility.None : Visibility.Visible)
PictureLoading()
.visibility(this.isMouted ? Visibility.None : Visibility.Visible)
Swiper(this.swiperController) {
ForEach(this.data, (item: ContentDetailDTO, index: number) => {
Column() {
... ...
... ... @@ -11,3 +11,7 @@ export { PlayerConstants } from "./src/main/ets/constants/PlayerConstants"
export { SpeedBean } from "./src/main/ets/bean/SpeedBean"
export { DateFormatUtil } from "./src/main/ets/utils/DateFormatUtil"
export { WDAliPlayerController } from "./src/main/ets/controller/WDAliPlayerController"
export { WDListPlayerData, WDAliListPlayerController } from "./src/main/ets/controller/WDAliListPlayerController"
\ No newline at end of file
... ...
... ... @@ -7,6 +7,7 @@
"main": "Index.ets",
"version": "1.0.0",
"dependencies": {
"wdKit": "file:../../commons/wdKit"
"wdKit": "file:../../commons/wdKit",
"premierlibrary": "file:./libs/premierlibrary.har"
}
}
... ...
... ... @@ -5,6 +5,8 @@ export class PlayerConstants {
static readonly STATUS_START: number = 1;
static readonly STATUS_PAUSE: number = 2;
static readonly STATUS_STOP: number = 3;
static readonly STATUS_ERROR: number = 4;
static readonly STATUS_COMPLETION: number = 5;
static readonly OPERATE_STATE: Array<string> = ['prepared','playing', 'paused', 'completed'];
... ...
import { AliPlayerFactory, AliPlayer, InfoBean, UrlSource, ErrorInfo, InfoCode } from 'premierlibrary';
import {
idle,
initalized,
prepared,
started,
paused,
stopped,
completion,
error} from 'premierlibrary/src/main/ets/com/aliyun/player/IPlayer';
import { AliListPlayer } from 'premierlibrary/src/main/ets/com/aliyun/player/AliListPlayer'
import { initGlobalPlayerSettings, setupPlayerConfig } from '../utils/GlobalSetting';
import prompt from '@ohos.promptAction';
import { Logger } from '../utils/Logger';
import { PlayerConstants, AVPlayerStatus, Events } from '../constants/PlayerConstants';
export interface WDListPlayerData {
uid: string
url: string
surfaceId?: string
}
/*
* 此播放器为阿里播放器鸿蒙版本封装,可播放单个视频、列表多个视频
* 列表上下滑场景用:WDAliListPlayerController
*
* 阿里文档链接:https://help.aliyun.com/zh/apsara-video-sdk/developer-reference/integrated-hongmeng-harmonyos-next-framework-player-sdk
*/
@Observed
export class WDAliListPlayerController {
private initPromise: Promise<void>;
private avPlayer?: AliListPlayer;
// 内部播放器状态
private avPlayerStatus: number = idle
private duration: number = 0;
private status: number = PlayerConstants.STATUS_IDLE;
private loop: boolean = false;
private url: string = '';
private surfaceId: string = '';
private playSpeed: number = 1;
private seekTime: number = 0;
private positionY: number = 0;
private startTime: number = 0
public errorCode?: number
public errorMesage?: string
public onVideoSizeChange?: (width: number, height: number) => void;
public onBufferUpdate?: (buffered: number, duration: number) => void;
public onTimeUpdate?: (position: number, duration: number) => void;
public onVolumeUpdate?: (volume: number) => void;
// 播放完成,决定是否继续播放回调
public continue?: () => void;
// 准备完成,决定是否播放回调。如果不实现,则自动播放
public onCanplay?: () => void;
public onStatusChange?: (status: number) => void;
public onFirstFrameDisplay?: () => void
//// ------------ 以下为列表播放器属性
private playSources: WDListPlayerData[] = []
private currentPlayRecord?: WDListPlayerData
constructor() {
Logger.info("初始化")
initGlobalPlayerSettings()
this.initPromise = this.createAVPlayer();
}
/**
* 创建 videoPlayer对象
*/
private createAVPlayer(): Promise<void> {
return new Promise((resolve, reject) => {
Logger.debug("开始创建")
let traceId = ''
this.avPlayer = AliPlayerFactory.createAliListPlayer(getContext(), traceId)
if (this.avPlayer) {
Logger.debug("创建完成1")
setupPlayerConfig(this.avPlayer!)
this.bindState();
resolve();
} else {
Logger.error("创建完成0")
Logger.error('[WDPlayerController] createAvPlayer fail!');
reject();
}
});
}
public destory() {
Logger.debug("播放器销毁")
this.avPlayer?.stop()
this.avPlayer?.release()
this.playSources = []
this.currentPlayRecord = undefined
}
/**
* AliPlayer 绑定事件.
*/
private bindState() {
this.avPlayer?.setOnPreparedListener({
// 当调用play()方法后,会调用
onPrepared: () => {
this.duration = this.avPlayer?.getDuration();
Logger.debug("已准备好", `${this.duration}`)
}
}
);
this.avPlayer?.setOnRenderingStartListener({
onRenderingStart: () => {
Logger.debug("首帧开始显示")
if (this.onFirstFrameDisplay) {
this.onFirstFrameDisplay()
}
}
});
this.avPlayer?.setOnCompletionListener({
onCompletion: () => {
Logger.debug("播放完成")
}
});
this.avPlayer?.setOnInfoListener({
onInfo: (bean: InfoBean) => {
if (bean.getCode() === InfoCode.CurrentPosition) {
let position : number = bean.getExtraValue()
Logger.debug(`播放进度条:${position}/ ${this.duration}`)
this.initProgress(position);
} else if (bean.getCode() === InfoCode.BufferedPosition) {
let buffer : number = bean.getExtraValue()
if (this.onBufferUpdate) {
this.onBufferUpdate(buffer, this.duration)
}
} else if (bean.getCode() === InfoCode.SwitchToSoftwareVideoDecoder) {
Logger.debug(`DOWNGRADE TO SOFTWARE DECODE`)
// this.mSwitchedToSoftListener?.onSwitched();
}
}
});
this.avPlayer?.setOnStateChangedListener({
onStateChanged: (status: number) => {
this.avPlayerStatus = status
Logger.debug("status update:" + `${this.getStatusStringWith(status)}`)
switch (status) {
case initalized: {
//this.avPlayer?.prepare();
} break
case prepared: {
if (this.startTime) {
this.setSeekTime(this.startTime, SliderChangeMode.Begin);
}
this.duration = this.avPlayer?.getDuration();
if (this.onVideoSizeChange) {
this.onVideoSizeChange(this.avPlayer?.getVideoWidth(), this.avPlayer?.getVideoHeight());
}
if (this.onCanplay) {
this.onCanplay()
} else {
this.play()
}
} break
case started: {
this.setBright();
this.status = PlayerConstants.STATUS_START;
this.watchStatus();
} break
case paused: {
this.status = PlayerConstants.STATUS_PAUSE;
this.watchStatus();
} break
case stopped: {
this.status = PlayerConstants.STATUS_STOP;
this.watchStatus();
} break
case completion: {
this.status = PlayerConstants.STATUS_COMPLETION;
this.watchStatus();
if (this.continue) {
this.continue();
} else {
//TODO:
//this.duration = 0;
//this.url = this.avPlayer.url || '';
//this.avPlayer.reset();
}
} break
case error: {
// 这里拿不到错误信息
// this.status = PlayerConstants.STATUS_ERROR;
// this.watchStatus();
}
}
}
});
this.avPlayer?.setOnErrorListener({
onError:(errorInfo) => {
Logger.error("播放错误", JSON.stringify(errorInfo))
this.errorCode = errorInfo.getCode()
this.errorMesage = errorInfo.getMsg()
this.status = PlayerConstants.STATUS_ERROR;
this.watchStatus();
}
});
this.avPlayer?.setOnLoadingStatusListener({
onLoadingBegin: () => {
// Logger.error("开始加载。。。")
},
onLoadingProgress: (percent: number, netSpeed: number) => {
// this.loadingProgress = percent;
// this.loadingSpeed = netSpeed;
},
onLoadingEnd: () => {
// Logger.error("结束加载")
// this.showLoadingScene = false;
// this.loadingProgress = 0;
// this.loadingSpeed = 0;
}
});
this.avPlayer?.setOnSeekCompleteListener({
onSeekComplete: () => {
this.initProgress(this.avPlayer?.getCurrentPosition());
}
})
}
private getStatusStringWith(status: number) : string {
switch (status) {
case idle: return 'idle'
case initalized: return 'initalized'
case prepared: return 'prepared'
case started: return 'started'
case paused: return 'paused'
case stopped: return 'stopped'
case completion: return 'completion'
case error: return 'error'
}
return 'unknow'
}
public setXComponentController(controller: XComponentController) {
this.setSurfaceId(controller.getXComponentSurfaceId())
}
public setSurfaceId(surfaceId: string) {
this.surfaceId = surfaceId
}
public async addSources(sources: WDListPlayerData[]) {
if (this.avPlayer == null) {
Logger.info("等待播放器初始化")
await this.initPromise;
}
if (this.avPlayer == null) {
return
}
/// 追加数据源
this.playSources.splice(this.playSources.length, 0, ...sources)
sources.map(data => {
this.avPlayer?.addUrl(data.url, data.uid)
})
}
public moveTo(uid: string, surfaceId: string) {
let uidDatas = this.playSources.filter(data => data.uid === uid)
if (uidDatas.length == 0) {
Logger.info("请先addSources()添加数据源url" + uid)
return
}
this.currentPlayRecord = uidDatas[0]
this.avPlayer?.setSurfaceId(surfaceId)
// this.setAliPlayerURL(this.currentPlayRecord.url)
let result = this.avPlayer?.moveTo(uid)
Logger.info("moveTo" + uid + ` result:${result}`)
this.avPlayer?.prepare()
}
private setAliPlayerURL(url: string) {
let urlSource : UrlSource = new UrlSource()
urlSource.setUri(url)
this.avPlayer?.setUrlDataSource(urlSource)
}
private release() {
if (this.avPlayer == null) {
return
}
this.avPlayer.release()
this.avPlayer = undefined
}
public pause() {
Logger.debug("暂停", this.url)
this.avPlayer?.pause();
}
public play() {
Logger.debug("播放", this.url)
this.avPlayer?.start();
}
public stop() {
Logger.debug("停止", this.url)
this.avPlayer?.stop();
}
public setLoop(loop: boolean) {
this.loop = loop;
this.avPlayer?.setLoop(loop);
}
public setMute(mute: boolean) {
this.avPlayer?.setMute(mute)
}
public setSpeed(playSpeed: number) {
this.playSpeed = playSpeed;
this.avPlayer?.setSpeed(this.playSpeed);
}
public switchPlayOrPause() {
if (this.avPlayerStatus == started) {
this.avPlayer?.pause();
} else if (this.avPlayerStatus == completion) {
this.avPlayer?.seekTo(0, 0)
this.avPlayer?.start()
} else {
this.avPlayer?.start();
}
}
public setSeekTime(value: number, mode: SliderChangeMode) {
// if (this.avPlayer == null) {
// await this.initPromise;
// }
// if (this.avPlayer == null) {
// return
// }
// if (mode == SliderChangeMode.Begin) {
// this.seekTime = value * 1000;
// this.avPlayer?.seek(this.seekTime, media.SeekMode.SEEK_PREV_SYNC);
// }
if (mode === SliderChangeMode.Moving) {
// this.progressThis.progressVal = value;
// this.progressThis.currentTime = DateFormatUtil.secondToTime(Math.floor(value * this.duration /
// 100 / 1000));
}
if (mode === SliderChangeMode.End) {
this.seekTime = Math.floor(value * this.duration / 100);
this.avPlayer?.seekTo(this.seekTime, 0);
}
}
public setBright() {
// globalThis.windowClass.setWindowBrightness(this.playerThis.bright)
}
public getStatus() {
return this.status;
}
public getPlayer() {
return this.avPlayer != undefined
}
initProgress(time: number) {
if (this.onTimeUpdate) {
this.onTimeUpdate(time, this.duration);
}
}
resetProgress() {
this.seekTime = 0;
this.duration = 0;
}
onVolumeActionStart(event: GestureEvent) {
this.positionY = event.offsetY;
}
onBrightActionStart(event: GestureEvent) {
this.positionY = event.offsetY;
}
volume: number = 1
onVolumeActionUpdate(event: GestureEvent) {
if (!this.avPlayer) {
return
}
if (this.avPlayerStatus != prepared &&
this.avPlayerStatus != started &&
this.avPlayerStatus != paused &&
this.avPlayerStatus != completion) {
return;
}
let changeVolume = (event.offsetY - this.positionY) / 300;
let currentVolume = this.volume - changeVolume;
if (currentVolume > 1) {
currentVolume = 1;
}
if (currentVolume <= 0) {
currentVolume = 0;
}
this.volume = currentVolume;
this.avPlayer?.setVolume(this.volume);
this.positionY = event.offsetY;
if (this.onVolumeUpdate) {
this.onVolumeUpdate(this.volume);
}
console.log("volume : " + this.volume)
}
onBrightActionUpdate(event: GestureEvent) {
// if (!this.playerThis.volumeShow) {
// this.playerThis.brightShow = true;
// let changeBright = (this.positionY - event.offsetY) / globalThis.screenHeight;
// let currentBright = this.playerThis.bright + changeBright;
// let brightMinFlag = currentBright <= 0;
// let brightMaxFlag = currentBright > 1;
// this.playerThis.bright = brightMinFlag ? 0 :
// (brightMaxFlag ? 1 : currentBright);
// this.setBright();
// this.positionY = event.offsetY;
// }
}
onActionEnd() {
setTimeout(() => {
this.positionY = 0;
}, 200);
}
watchStatus() {
console.log('watchStatus', this.status)
if (this.onStatusChange) {
this.onStatusChange(this.status)
}
// if (this.status === PlayConstants.STATUS_START) {
// globalThis.windowClass.setWindowKeepScreenOn(true);
// } else {
// globalThis.windowClass.setWindowKeepScreenOn(false);
// }
}
playError(msg?: string) {
prompt.showToast({
duration: 3000,
message: msg ? msg : "请检查地址输入正确且网络正常"
});
}
setStartTime(time?: number) {
this.startTime = time ?? 0;
}
}
\ No newline at end of file
... ...
import { AliPlayerFactory, AliPlayer, InfoBean, UrlSource, ErrorInfo, InfoCode } from 'premierlibrary';
import {
idle,
initalized,
prepared,
started,
paused,
stopped,
completion,
error} from 'premierlibrary/src/main/ets/com/aliyun/player/IPlayer';
import { initGlobalPlayerSettings, setupPlayerConfig } from '../utils/GlobalSetting';
import prompt from '@ohos.promptAction';
import { Logger } from '../utils/Logger';
import { PlayerConstants, AVPlayerStatus, Events } from '../constants/PlayerConstants';
/*
* 此播放器为阿里播放器鸿蒙版本封装,可播放单个视频、或直播
* 列表上下滑场景用:WDListPlayerController
*
* 阿里文档链接:https://help.aliyun.com/zh/apsara-video-sdk/developer-reference/integrated-hongmeng-harmonyos-next-framework-player-sdk
*/
@Observed
export class WDAliPlayerController {
private initPromise: Promise<void>;
private avPlayer?: AliPlayer;
// 内部播放器状态
private avPlayerStatus: number = idle
private duration: number = 0;
private status: number = PlayerConstants.STATUS_IDLE;
private loop: boolean = false;
private url: string = '';
private surfaceId: string = '';
private playSpeed: number = 1;
private seekTime: number = 0;
private positionY: number = 0;
private startTime: number = 0
public errorCode?: number
public errorMesage?: string
public onVideoSizeChange?: (width: number, height: number) => void;
public onBufferUpdate?: (buffered: number, duration: number) => void;
public onTimeUpdate?: (position: number, duration: number) => void;
public onVolumeUpdate?: (volume: number) => void;
// 播放完成,决定是否继续播放回调
public continue?: () => void;
// 准备完成,决定是否播放回调。如果不实现,则自动播放
public onCanplay?: () => void;
public onStatusChange?: (status: number) => void;
public onFirstFrameDisplay?: () => void
constructor() {
Logger.info("初始化")
initGlobalPlayerSettings()
this.initPromise = this.createAVPlayer();
}
/**
* 创建 videoPlayer对象
*/
private createAVPlayer(): Promise<void> {
return new Promise((resolve, reject) => {
Logger.debug("开始创建")
let traceId = ''
this.avPlayer = AliPlayerFactory.createAliPlayer(getContext(), traceId)
if (this.avPlayer) {
Logger.debug("创建完成1")
setupPlayerConfig(this.avPlayer!)
this.bindState();
resolve();
} else {
Logger.error("创建完成0")
Logger.error('[WDPlayerController] createAvPlayer fail!');
reject();
}
});
}
public destory() {
Logger.debug("播放器销毁")
this.avPlayer?.stop()
this.avPlayer?.release()
}
/**
* AliPlayer 绑定事件.
*/
private bindState() {
this.avPlayer?.setOnPreparedListener({
// 当调用play()方法后,会调用
onPrepared: () => {
this.duration = this.avPlayer?.getDuration();
Logger.debug("已准备好", `${this.duration}`)
}
}
);
this.avPlayer?.setOnRenderingStartListener({
onRenderingStart: () => {
Logger.debug("首帧开始显示")
if (this.onFirstFrameDisplay) {
this.onFirstFrameDisplay()
}
}
});
this.avPlayer?.setOnCompletionListener({
onCompletion: () => {
Logger.debug("播放完成")
}
});
this.avPlayer?.setOnInfoListener({
onInfo: (bean: InfoBean) => {
if (bean.getCode() === InfoCode.CurrentPosition) {
let position : number = bean.getExtraValue()
Logger.debug(`播放进度条:${position}/ ${this.duration}`)
this.initProgress(position);
} else if (bean.getCode() === InfoCode.BufferedPosition) {
let buffer : number = bean.getExtraValue()
if (this.onBufferUpdate) {
this.onBufferUpdate(buffer, this.duration)
}
} else if (bean.getCode() === InfoCode.SwitchToSoftwareVideoDecoder) {
Logger.debug(`DOWNGRADE TO SOFTWARE DECODE`)
// this.mSwitchedToSoftListener?.onSwitched();
}
}
});
this.avPlayer?.setOnStateChangedListener({
onStateChanged: (status: number) => {
this.avPlayerStatus = status
Logger.debug("status update:" + `${this.getStatusStringWith(status)}`)
switch (status) {
case initalized: {
//this.avPlayer?.prepare();
} break
case prepared: {
if (this.startTime) {
this.setSeekTime(this.startTime, SliderChangeMode.Begin);
}
this.duration = this.avPlayer?.getDuration();
if (this.onVideoSizeChange) {
this.onVideoSizeChange(this.avPlayer?.getVideoWidth(), this.avPlayer?.getVideoHeight());
}
if (this.onCanplay) {
this.onCanplay()
} else {
this.play()
}
} break
case started: {
this.setBright();
this.status = PlayerConstants.STATUS_START;
this.watchStatus();
} break
case paused: {
this.status = PlayerConstants.STATUS_PAUSE;
this.watchStatus();
} break
case stopped: {
this.status = PlayerConstants.STATUS_STOP;
this.watchStatus();
} break
case completion: {
this.status = PlayerConstants.STATUS_COMPLETION;
this.watchStatus();
if (this.continue) {
this.continue();
} else {
//TODO:
//this.duration = 0;
//this.url = this.avPlayer.url || '';
//this.avPlayer.reset();
}
} break
case error: {
// 这里拿不到错误信息
// this.status = PlayerConstants.STATUS_ERROR;
// this.watchStatus();
}
}
}
});
this.avPlayer?.setOnErrorListener({
onError:(errorInfo) => {
Logger.error("播放错误", JSON.stringify(errorInfo))
this.errorCode = errorInfo.getCode()
this.errorMesage = errorInfo.getMsg()
this.status = PlayerConstants.STATUS_ERROR;
this.watchStatus();
}
});
this.avPlayer?.setOnLoadingStatusListener({
onLoadingBegin: () => {
// Logger.error("开始加载。。。")
},
onLoadingProgress: (percent: number, netSpeed: number) => {
// this.loadingProgress = percent;
// this.loadingSpeed = netSpeed;
},
onLoadingEnd: () => {
// Logger.error("结束加载")
// this.showLoadingScene = false;
// this.loadingProgress = 0;
// this.loadingSpeed = 0;
}
});
this.avPlayer?.setOnSeekCompleteListener({
onSeekComplete: () => {
this.initProgress(this.avPlayer?.getCurrentPosition());
}
})
}
private setAliPlayerURL(url: string) {
let urlSource : UrlSource = new UrlSource()
urlSource.setUri(url)
this.avPlayer?.setUrlDataSource(urlSource)
}
private getStatusStringWith(status: number) : string {
switch (status) {
case idle: return 'idle'
case initalized: return 'initalized'
case prepared: return 'prepared'
case started: return 'started'
case paused: return 'paused'
case stopped: return 'stopped'
case completion: return 'completion'
case error: return 'error'
}
return 'unknow'
}
setXComponentController(controller: XComponentController) {
this.setSurfaceId(controller.getXComponentSurfaceId())
}
setSurfaceId(surfaceId: string) {
this.surfaceId = surfaceId
}
async firstPlay(url: string) {
this.url = url;
if (this.avPlayer == null) {
Logger.info("等待播放器初始化")
await this.initPromise;
} else {
if (this.avPlayerStatus != idle) {
this.destory()
this.initPromise = this.createAVPlayer();
await this.initPromise;
}
}
if (this.avPlayer == null) {
return
}
this.duration = 0
this.errorCode = undefined
this.errorMesage = undefined
this.avPlayerStatus = idle
this.status = PlayerConstants.STATUS_IDLE
this.avPlayer?.setAutoPlay(false)
Logger.debug("开始播放", this.url)
this.setAliPlayerURL(this.url);
Logger.info("设置SurfaceId" + this.surfaceId)
this.avPlayer?.setSurfaceId(this.surfaceId)
this.avPlayer?.prepare()
}
release() {
if (this.avPlayer == null) {
return
}
this.avPlayer.release()
this.avPlayer = undefined
}
pause() {
Logger.debug("暂停", this.url)
this.avPlayer?.pause();
}
play() {
Logger.debug("播放", this.url)
this.avPlayer?.start();
}
stop() {
Logger.debug("停止", this.url)
this.avPlayer?.stop();
}
setLoop(loop: boolean) {
this.loop = loop;
this.avPlayer?.setLoop(loop);
}
setMute(mute: boolean) {
this.avPlayer?.setMute(mute)
}
setSpeed(playSpeed: number) {
this.playSpeed = playSpeed;
this.avPlayer?.setSpeed(this.playSpeed);
}
switchPlayOrPause() {
if (this.avPlayerStatus == started) {
this.avPlayer?.pause();
} else if (this.avPlayerStatus == completion) {
this.avPlayer?.seekTo(0, 0)
this.avPlayer?.start()
} else {
this.avPlayer?.start();
}
}
setSeekTime(value: number, mode: SliderChangeMode) {
// if (this.avPlayer == null) {
// await this.initPromise;
// }
// if (this.avPlayer == null) {
// return
// }
// if (mode == SliderChangeMode.Begin) {
// this.seekTime = value * 1000;
// this.avPlayer?.seek(this.seekTime, media.SeekMode.SEEK_PREV_SYNC);
// }
if (mode === SliderChangeMode.Moving) {
// this.progressThis.progressVal = value;
// this.progressThis.currentTime = DateFormatUtil.secondToTime(Math.floor(value * this.duration /
// 100 / 1000));
}
if (mode === SliderChangeMode.End) {
this.seekTime = Math.floor(value * this.duration / 100);
this.avPlayer?.seekTo(this.seekTime, 0);
}
}
setBright() {
// globalThis.windowClass.setWindowBrightness(this.playerThis.bright)
}
getStatus() {
return this.status;
}
getPlayer() {
return this.avPlayer != undefined
}
initProgress(time: number) {
if (this.onTimeUpdate) {
this.onTimeUpdate(time, this.duration);
}
}
resetProgress() {
this.seekTime = 0;
this.duration = 0;
}
onVolumeActionStart(event: GestureEvent) {
this.positionY = event.offsetY;
}
onBrightActionStart(event: GestureEvent) {
this.positionY = event.offsetY;
}
volume: number = 1
onVolumeActionUpdate(event: GestureEvent) {
if (!this.avPlayer) {
return
}
if (this.avPlayerStatus != prepared &&
this.avPlayerStatus != started &&
this.avPlayerStatus != paused &&
this.avPlayerStatus != completion) {
return;
}
let changeVolume = (event.offsetY - this.positionY) / 300;
let currentVolume = this.volume - changeVolume;
if (currentVolume > 1) {
currentVolume = 1;
}
if (currentVolume <= 0) {
currentVolume = 0;
}
this.volume = currentVolume;
this.avPlayer?.setVolume(this.volume);
this.positionY = event.offsetY;
if (this.onVolumeUpdate) {
this.onVolumeUpdate(this.volume);
}
console.log("volume : " + this.volume)
}
onBrightActionUpdate(event: GestureEvent) {
// if (!this.playerThis.volumeShow) {
// this.playerThis.brightShow = true;
// let changeBright = (this.positionY - event.offsetY) / globalThis.screenHeight;
// let currentBright = this.playerThis.bright + changeBright;
// let brightMinFlag = currentBright <= 0;
// let brightMaxFlag = currentBright > 1;
// this.playerThis.bright = brightMinFlag ? 0 :
// (brightMaxFlag ? 1 : currentBright);
// this.setBright();
// this.positionY = event.offsetY;
// }
}
onActionEnd() {
setTimeout(() => {
this.positionY = 0;
}, 200);
}
watchStatus() {
console.log('watchStatus', this.status)
if (this.onStatusChange) {
this.onStatusChange(this.status)
}
// if (this.status === PlayConstants.STATUS_START) {
// globalThis.windowClass.setWindowKeepScreenOn(true);
// } else {
// globalThis.windowClass.setWindowKeepScreenOn(false);
// }
}
playError(msg?: string) {
prompt.showToast({
duration: 3000,
message: msg ? msg : "请检查地址输入正确且网络正常"
});
}
setStartTime(time?: number) {
this.startTime = time ?? 0;
}
}
\ No newline at end of file
... ...
... ... @@ -144,6 +144,10 @@ export class WDPlayerController {
this.xComponentController = controller
}
setSurfaceId(surfaceId: string) {
this.surfaceId = surfaceId
}
async firstPlay(url: string) {
this.url = url;
if (this.avPlayer == null) {
... ...
... ... @@ -2,6 +2,7 @@ import componentUtils from '@ohos.arkui.componentUtils';
import { WDPlayerController } from '../controller/WDPlayerController'
import { WindowModel } from 'wdKit';
import { Logger } from '../utils/Logger';
import { enableAliPlayer } from '../utils/GlobalSetting';
class Size {
width: Length = "100%";
... ... @@ -74,8 +75,9 @@ export struct WDPlayerRenderLiveView {
Row() {
// 设置为“surface“类型时XComponent组件可以和其他组件一起进行布局和渲染。
XComponent({
id: 'xComponentId',
type: 'surface',
id: enableAliPlayer ? this.insId : 'xComponentId',
type: XComponentType.SURFACE,
libraryname: enableAliPlayer ? "premierlibrary" : undefined,
controller: this.xComponentController
})
.onLoad(async (event) => {
... ... @@ -87,7 +89,11 @@ export struct WDPlayerRenderLiveView {
surfaceWidth: 1920,
surfaceHeight: 720
});
if (enableAliPlayer) {
this.playerController?.setSurfaceId(this.insId)
} else {
this.playerController?.setXComponentController(this.xComponentController)
}
if (this.onLoad) {
this.onLoad(event)
}
... ...
... ... @@ -2,6 +2,7 @@ import componentUtils from '@ohos.arkui.componentUtils';
import { WDPlayerController } from '../controller/WDPlayerController'
import { WindowModel } from 'wdKit';
import { Logger } from '../utils/Logger';
import { enableAliPlayer } from '../utils/GlobalSetting';
class Size {
width: Length = "100%";
... ... @@ -73,8 +74,9 @@ export struct WDPlayerRenderVLiveView {
Row() {
// 设置为“surface“类型时XComponent组件可以和其他组件一起进行布局和渲染。
XComponent({
id: 'xComponentId',
type: 'surface',
id: enableAliPlayer ? this.insId : 'xComponentId',
type: XComponentType.SURFACE,
libraryname: enableAliPlayer ? "premierlibrary" : undefined,
controller: this.xComponentController
})
.onLoad(async (event) => {
... ... @@ -84,7 +86,11 @@ export struct WDPlayerRenderVLiveView {
surfaceWidth: 1920,
surfaceHeight: 1080
});
if (enableAliPlayer) {
this.playerController?.setSurfaceId(this.insId)
} else {
this.playerController?.setXComponentController(this.xComponentController)
}
if (this.onLoad) {
this.onLoad(event)
}
... ...
... ... @@ -2,6 +2,7 @@ import componentUtils from '@ohos.arkui.componentUtils';
import { WDPlayerController } from '../controller/WDPlayerController'
import { WindowModel } from 'wdKit';
import { Logger } from '../utils/Logger';
import { enableAliPlayer } from '../utils/GlobalSetting';
class Size {
width: Length = "100%";
... ... @@ -77,6 +78,7 @@ export struct WDPlayerRenderView {
XComponent({
id: this.insId,
type: XComponentType.SURFACE,
libraryname: enableAliPlayer ? "premierlibrary" : undefined,
controller: this.xComponentController
})
.onLoad(async (event) => {
... ... @@ -85,7 +87,11 @@ export struct WDPlayerRenderView {
surfaceWidth: 1920,
surfaceHeight: 1080
});
if (enableAliPlayer) {
this.playerController?.setSurfaceId(this.insId)
} else {
this.playerController?.setXComponentController(this.xComponentController)
}
if (this.onLoad) {
this.onLoad(event)
}
... ...
import { AliPlayerGlobalSettings, AliPlayer } from 'premierlibrary';
import fs from '@ohos.file.fs';
import common from '@ohos.app.ability.common';
import { error } from 'premierlibrary/src/main/ets/com/aliyun/player/IPlayer';
import { BusinessError } from '@kit.BasicServicesKit';
let currentContext = getContext() as common.UIAbilityContext
export function initGlobalPlayerSettings(context?: common.UIAbilityContext) {
AliPlayerGlobalSettings.setUseHttp2(true);
let filesDir = (context != undefined ? context : currentContext).filesDir;
let cachePath = filesDir + "/player-cache"
fs.stat(cachePath).catch((error: BusinessError) => {
if (error.code = 13900002) {
fs.mkdirSync(cachePath)
}
})
AliPlayerGlobalSettings.enableLocalCache(true,1 * 1024, cachePath)
AliPlayerGlobalSettings.setCacheFileClearConfig(3 * 24 * 6, 1024, 300)
}
export function setupPlayerConfig(player: AliPlayer) {
let config = player.getConfig()
if (config) {
config.mMaxDelayTime = 500
config.mMaxBufferDuration = 50000
config.mHighBufferDuration = 3000
config.mStartBufferDuration = 50
player.setConfig(config)
}
}
/*
* 开启前注意:
* 1、配置好包名对应的license文件
* 2、页面组件播放器控制器使用WDAliPlayerController
* 3、WDAliListPlayerController 暂时由于SDK问题,不能使用
* 4、
* */
export const enableAliPlayer = false
\ No newline at end of file
... ...
... ... @@ -9,6 +9,22 @@
"2in1"
],
"deliveryWithInstall": true,
"pages": "$profile:main_pages"
"pages": "$profile:main_pages",
"metadata": [
{
"name": "com.aliyun.alivc_license.licensekey",
"value": "IoKwpV6clXePXoR4rf67e402d71b34952ac19b24d13ecf8c5"
},
{
"name": "com.aliyun.alivc_license.licensefile",
"value": "AliVideoCert-com_peopledailychina_hosactivity-20240514172039.crt"
},
{
"name": "com.aliyun.alivc_license.service_env",
// "value": "PreRelease"
"value": "Release"
}
]
}
}
\ No newline at end of file
... ...
... ... @@ -2,6 +2,7 @@ import { PageComponent } from 'wdComponent/Index';
import { HashMap } from '@kit.ArkTS';
import { router } from '@kit.ArkUI';
import { AssignChannelParam } from 'wdRouter/src/main/ets/utils/HomeChannelUtils';
import { CustomTitleUI } from 'wdComponent/src/main/ets/components/reusable/CustomTitleUI';
const TAG = 'ColumnPage';
... ... @@ -15,21 +16,26 @@ export struct ColumnPage {
@State param: AssignChannelParam = router.getParams() as AssignChannelParam
pageId: string = "";
channelId: string = "";
pageName: string = ''
aboutToAppear() {
this.pageId = this.param.pageId
this.channelId = this.param.channelId
this.pageName = this.param.pageName
}
build() {
Column() {
CustomTitleUI({ titleName: this.pageName })
PageComponent({
currentTopNavSelectedIndex: $currentTopNavSelectedIndex,
navIndex: this.currentTopNavSelectedIndex,
pageId: this.pageId,
channelId: this.channelId,
});
}
}.height('100%')
.width('100%')
.backgroundColor($r('app.color.white'))
}
}
... ...
... ... @@ -75,7 +75,7 @@ export struct UpgradeTipDialog {
Row().width("100%").height(1).backgroundColor("#50E6E6E6")
Button() {
Text("立即升级").fontColor(Color.White)
Text("立即更新").fontColor(Color.White)
}.borderRadius(4)
.buttonStyle(ButtonStyleMode.NORMAL)
... ...
... ... @@ -41,7 +41,7 @@
"requestPermissions": [
{
"name": "ohos.permission.CAMERA",
"reason": "$string:EntryAbility_desc",
"reason": "$string:permission_camera_tip",
"usedScene": {
"abilities": [
"FormAbility"
... ... @@ -51,7 +51,7 @@
},
{
"name": "ohos.permission.READ_MEDIA",
"reason": "$string:EntryAbility_desc",
"reason": "$string:permission_photo_tip",
"usedScene": {
"abilities": [
"FormAbility"
... ... @@ -61,7 +61,7 @@
},
{
"name": "ohos.permission.WRITE_MEDIA",
"reason": "$string:EntryAbility_desc",
"reason": "$string:permission_photo_tip",
"usedScene": {
"abilities": [
"FormAbility"
... ... @@ -71,7 +71,7 @@
},
{
"name": "ohos.permission.APPROXIMATELY_LOCATION",
"reason": "$string:EntryAbility_desc",
"reason": "$string:permission_location_tip",
"usedScene": {
"abilities": [
"FormAbility"
... ... @@ -81,7 +81,7 @@
},
{
"name": "ohos.permission.MICROPHONE",
"reason": "$string:EntryAbility_desc",
"reason": "$string:permission_microphone_tip",
"usedScene": {
"abilities": [
"FormAbility"
... ...
... ... @@ -13,6 +13,22 @@
"value": "$string:app_name"
},
{
"name": "permission_photo_tip",
"value": "开启之后即可用于保存新闻图片到相册、发视频、设置封面、设置头像、缓存图片和视频来展示内容等功能"
},
{
"name": "permission_camera_tip",
"value": "开启之后即可用于拍摄视频、拍摄头像、扫一扫功能"
},
{
"name": "permission_location_tip",
"value": "开启之后可为你推荐你可能感兴趣的内容及附近的相关信息,以提升浏览体验。不授权该权限不影响APP正常使用。"
},
{
"name": "permission_microphone_tip",
"value": "开启之后即可用于收录声音进行拍摄视频、语音搜索、语音评论功能,"
},
{
"name": "dialog_text_title",
"value": "个人隐私保护指引"
},
... ...
-----BEGIN ALI VIDEO CERT-----
LmlsQS5jaUwAAWRjY2FhYTU1OTAxNzE0NDg2OWJlOGJkNzczZTc5ZjAzM2YwMDhiO
WY5ODUwNTc5MGY4NDEyOTRiMzNjMmZiYjg1NGUxZThlNjAwNzRmNTgxZTU0MDY2Mj
RiMGFiM2JkNWVmOTE3ZDE0MDJlNDQ0ZDUwNmExMTc5ZjFlYjYyODQ2MDRiYzdiYjA
zOTI2ZjYyOTE1OWVjYjY0ZDk1ZDhhN2Q5ZWZlOTRjOTdkMTA0Yzc1MWU5OGEwNGY3
OTdkOTdiYTAzMWEyMDFlMzc2Mjg0NGI1MTEyYWRkZDQzNTgyZDA2NTJkYTk0MDk1Y
TIxYjY2NWJm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