xugenyuan

ref |> 列表播放器增加日志

Signed-off-by: xugenyuan <xugenyuan@wondertek.com.cn>
... ... @@ -12,8 +12,8 @@ import { AliListPlayer } from 'premierlibrary/src/main/ets/com/aliyun/player/Ali
import { initGlobalPlayerSettings, setupPlayerConfig } from '../utils/GlobalSetting';
import prompt from '@ohos.promptAction';
import { Logger } from '../utils/Logger';
import { PlayerConstants, AVPlayerStatus, Events } from '../constants/PlayerConstants';
import { Logger } from 'wdKit/Index';
export interface WDListPlayerData {
uid: string
... ... @@ -21,6 +21,8 @@ export interface WDListPlayerData {
surfaceId?: string
}
const TAG = "WDAliListPlayerController"
/*
* 此播放器为阿里播放器鸿蒙版本封装,可播放单个视频、列表多个视频
... ... @@ -66,7 +68,7 @@ export class WDAliListPlayerController {
private currentPlayRecord?: WDListPlayerData
constructor() {
Logger.info("初始化")
Logger.info(TAG, "初始化")
initGlobalPlayerSettings()
this.initPromise = this.createAVPlayer();
}
... ... @@ -76,24 +78,24 @@ export class WDAliListPlayerController {
*/
private createAVPlayer(): Promise<void> {
return new Promise((resolve, reject) => {
Logger.debug("开始创建")
Logger.debug(TAG, "开始创建")
let traceId = ''
this.avPlayer = AliPlayerFactory.createAliListPlayer(getContext(), traceId)
if (this.avPlayer) {
Logger.debug("创建完成1")
Logger.debug(TAG, "创建完成1")
setupPlayerConfig(this.avPlayer!)
this.bindState();
resolve();
} else {
Logger.error("创建完成0")
Logger.error('[WDPlayerController] createAvPlayer fail!');
Logger.error(TAG, "创建完成0")
Logger.error(TAG, '[WDPlayerController] createAvPlayer fail!');
reject();
}
});
}
public destory() {
Logger.debug("播放器销毁")
Logger.debug(TAG, "播放器销毁")
this.avPlayer?.stop()
this.avPlayer?.release()
this.playSources = []
... ... @@ -108,13 +110,13 @@ export class WDAliListPlayerController {
// 当调用play()方法后,会调用
onPrepared: () => {
this.duration = this.avPlayer?.getDuration();
Logger.debug("已准备好", `${this.duration}`)
Logger.debug(TAG, "已准备好", `${this.duration}`)
}
}
);
this.avPlayer?.setOnRenderingStartListener({
onRenderingStart: () => {
Logger.debug("首帧开始显示")
Logger.debug(TAG, "首帧开始显示")
if (this.onFirstFrameDisplay) {
this.onFirstFrameDisplay()
}
... ... @@ -122,7 +124,7 @@ export class WDAliListPlayerController {
});
this.avPlayer?.setOnCompletionListener({
onCompletion: () => {
Logger.debug("播放完成")
Logger.debug(TAG, "播放完成")
}
});
this.avPlayer?.setOnInfoListener({
... ... @@ -130,7 +132,7 @@ export class WDAliListPlayerController {
if (bean.getCode() === InfoCode.CurrentPosition) {
let position : number = bean.getExtraValue()
Logger.debug(`播放进度条:${position}/ ${this.duration}`)
Logger.debug(TAG, `播放进度条:${position}/ ${this.duration}`)
this.initProgress(position);
} else if (bean.getCode() === InfoCode.BufferedPosition) {
... ... @@ -140,7 +142,7 @@ export class WDAliListPlayerController {
}
} else if (bean.getCode() === InfoCode.SwitchToSoftwareVideoDecoder) {
Logger.debug(`DOWNGRADE TO SOFTWARE DECODE`)
Logger.debug(TAG, `DOWNGRADE TO SOFTWARE DECODE`)
// this.mSwitchedToSoftListener?.onSwitched();
}
}
... ... @@ -148,7 +150,7 @@ export class WDAliListPlayerController {
this.avPlayer?.setOnStateChangedListener({
onStateChanged: (status: number) => {
this.avPlayerStatus = status
Logger.debug("status update:" + `${this.getStatusStringWith(status)}`)
Logger.debug(TAG, "status update:" + `${this.getStatusStringWith(status)}`)
switch (status) {
case initalized: {
... ... @@ -203,7 +205,7 @@ export class WDAliListPlayerController {
});
this.avPlayer?.setOnErrorListener({
onError:(errorInfo) => {
Logger.error("播放错误", JSON.stringify(errorInfo))
Logger.error(TAG, "播放错误", JSON.stringify(errorInfo))
this.errorCode = errorInfo.getCode()
this.errorMesage = errorInfo.getMsg()
this.status = PlayerConstants.STATUS_ERROR;
... ... @@ -212,14 +214,14 @@ export class WDAliListPlayerController {
});
this.avPlayer?.setOnLoadingStatusListener({
onLoadingBegin: () => {
// Logger.error("开始加载。。。")
// Logger.error(TAG, "开始加载。。。")
},
onLoadingProgress: (percent: number, netSpeed: number) => {
// this.loadingProgress = percent;
// this.loadingSpeed = netSpeed;
},
onLoadingEnd: () => {
// Logger.error("结束加载")
// Logger.error(TAG, "结束加载")
// this.showLoadingScene = false;
// this.loadingProgress = 0;
// this.loadingSpeed = 0;
... ... @@ -256,7 +258,7 @@ export class WDAliListPlayerController {
public async addSources(sources: WDListPlayerData[]) {
if (this.avPlayer == null) {
Logger.info("等待播放器初始化")
Logger.info(TAG, "等待播放器初始化")
await this.initPromise;
}
if (this.avPlayer == null) {
... ... @@ -273,7 +275,7 @@ export class WDAliListPlayerController {
public moveTo(uid: string, surfaceId: string) {
let uidDatas = this.playSources.filter(data => data.uid === uid)
if (uidDatas.length == 0) {
Logger.info("请先addSources()添加数据源url" + uid)
Logger.info(TAG, "请先addSources()添加数据源url" + uid)
return
}
this.currentPlayRecord = uidDatas[0]
... ... @@ -282,7 +284,7 @@ export class WDAliListPlayerController {
// this.setAliPlayerURL(this.currentPlayRecord.url)
let result = this.avPlayer?.moveTo(uid)
Logger.info("moveTo" + uid + ` result:${result}`)
Logger.info(TAG, "moveTo " + uid + ` result:${result}`)
this.avPlayer?.prepare()
}
... ... @@ -301,17 +303,17 @@ export class WDAliListPlayerController {
}
public pause() {
Logger.debug("暂停", this.url)
Logger.debug(TAG, "暂停", this.url)
this.avPlayer?.pause();
}
public play() {
Logger.debug("播放", this.url)
Logger.debug(TAG, "播放", this.url)
this.avPlayer?.start();
}
public stop() {
Logger.debug("停止", this.url)
Logger.debug(TAG, "停止", this.url)
this.avPlayer?.stop();
}
... ... @@ -419,7 +421,7 @@ export class WDAliListPlayerController {
if (this.onVolumeUpdate) {
this.onVolumeUpdate(this.volume);
}
console.log("volume : " + this.volume)
Logger.debug(TAG, "volume : " + this.volume)
}
onBrightActionUpdate(event: GestureEvent) {
... ... @@ -443,7 +445,7 @@ export class WDAliListPlayerController {
}
watchStatus() {
console.log('watchStatus', this.status)
Logger.debug(TAG, 'watchStatus ' + this.status)
if (this.onStatusChange) {
this.onStatusChange(this.status)
}
... ...