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 @@ -12,8 +12,8 @@ import { AliListPlayer } from 'premierlibrary/src/main/ets/com/aliyun/player/Ali
12 12
13 import { initGlobalPlayerSettings, setupPlayerConfig } from '../utils/GlobalSetting'; 13 import { initGlobalPlayerSettings, setupPlayerConfig } from '../utils/GlobalSetting';
14 import prompt from '@ohos.promptAction'; 14 import prompt from '@ohos.promptAction';
15 -import { Logger } from '../utils/Logger';  
16 import { PlayerConstants, AVPlayerStatus, Events } from '../constants/PlayerConstants'; 15 import { PlayerConstants, AVPlayerStatus, Events } from '../constants/PlayerConstants';
  16 +import { Logger } from 'wdKit/Index';
17 17
18 export interface WDListPlayerData { 18 export interface WDListPlayerData {
19 uid: string 19 uid: string
@@ -21,6 +21,8 @@ export interface WDListPlayerData { @@ -21,6 +21,8 @@ export interface WDListPlayerData {
21 surfaceId?: string 21 surfaceId?: string
22 } 22 }
23 23
  24 +const TAG = "WDAliListPlayerController"
  25 +
24 /* 26 /*
25 27
26 * 此播放器为阿里播放器鸿蒙版本封装,可播放单个视频、列表多个视频 28 * 此播放器为阿里播放器鸿蒙版本封装,可播放单个视频、列表多个视频
@@ -66,7 +68,7 @@ export class WDAliListPlayerController { @@ -66,7 +68,7 @@ export class WDAliListPlayerController {
66 private currentPlayRecord?: WDListPlayerData 68 private currentPlayRecord?: WDListPlayerData
67 69
68 constructor() { 70 constructor() {
69 - Logger.info("初始化") 71 + Logger.info(TAG, "初始化")
70 initGlobalPlayerSettings() 72 initGlobalPlayerSettings()
71 this.initPromise = this.createAVPlayer(); 73 this.initPromise = this.createAVPlayer();
72 } 74 }
@@ -76,24 +78,24 @@ export class WDAliListPlayerController { @@ -76,24 +78,24 @@ export class WDAliListPlayerController {
76 */ 78 */
77 private createAVPlayer(): Promise<void> { 79 private createAVPlayer(): Promise<void> {
78 return new Promise((resolve, reject) => { 80 return new Promise((resolve, reject) => {
79 - Logger.debug("开始创建") 81 + Logger.debug(TAG, "开始创建")
80 let traceId = '' 82 let traceId = ''
81 this.avPlayer = AliPlayerFactory.createAliListPlayer(getContext(), traceId) 83 this.avPlayer = AliPlayerFactory.createAliListPlayer(getContext(), traceId)
82 if (this.avPlayer) { 84 if (this.avPlayer) {
83 - Logger.debug("创建完成1") 85 + Logger.debug(TAG, "创建完成1")
84 setupPlayerConfig(this.avPlayer!) 86 setupPlayerConfig(this.avPlayer!)
85 this.bindState(); 87 this.bindState();
86 resolve(); 88 resolve();
87 } else { 89 } else {
88 - Logger.error("创建完成0")  
89 - Logger.error('[WDPlayerController] createAvPlayer fail!'); 90 + Logger.error(TAG, "创建完成0")
  91 + Logger.error(TAG, '[WDPlayerController] createAvPlayer fail!');
90 reject(); 92 reject();
91 } 93 }
92 }); 94 });
93 } 95 }
94 96
95 public destory() { 97 public destory() {
96 - Logger.debug("播放器销毁") 98 + Logger.debug(TAG, "播放器销毁")
97 this.avPlayer?.stop() 99 this.avPlayer?.stop()
98 this.avPlayer?.release() 100 this.avPlayer?.release()
99 this.playSources = [] 101 this.playSources = []
@@ -108,13 +110,13 @@ export class WDAliListPlayerController { @@ -108,13 +110,13 @@ export class WDAliListPlayerController {
108 // 当调用play()方法后,会调用 110 // 当调用play()方法后,会调用
109 onPrepared: () => { 111 onPrepared: () => {
110 this.duration = this.avPlayer?.getDuration(); 112 this.duration = this.avPlayer?.getDuration();
111 - Logger.debug("已准备好", `${this.duration}`) 113 + Logger.debug(TAG, "已准备好", `${this.duration}`)
112 } 114 }
113 } 115 }
114 ); 116 );
115 this.avPlayer?.setOnRenderingStartListener({ 117 this.avPlayer?.setOnRenderingStartListener({
116 onRenderingStart: () => { 118 onRenderingStart: () => {
117 - Logger.debug("首帧开始显示") 119 + Logger.debug(TAG, "首帧开始显示")
118 if (this.onFirstFrameDisplay) { 120 if (this.onFirstFrameDisplay) {
119 this.onFirstFrameDisplay() 121 this.onFirstFrameDisplay()
120 } 122 }
@@ -122,7 +124,7 @@ export class WDAliListPlayerController { @@ -122,7 +124,7 @@ export class WDAliListPlayerController {
122 }); 124 });
123 this.avPlayer?.setOnCompletionListener({ 125 this.avPlayer?.setOnCompletionListener({
124 onCompletion: () => { 126 onCompletion: () => {
125 - Logger.debug("播放完成") 127 + Logger.debug(TAG, "播放完成")
126 } 128 }
127 }); 129 });
128 this.avPlayer?.setOnInfoListener({ 130 this.avPlayer?.setOnInfoListener({
@@ -130,7 +132,7 @@ export class WDAliListPlayerController { @@ -130,7 +132,7 @@ export class WDAliListPlayerController {
130 132
131 if (bean.getCode() === InfoCode.CurrentPosition) { 133 if (bean.getCode() === InfoCode.CurrentPosition) {
132 let position : number = bean.getExtraValue() 134 let position : number = bean.getExtraValue()
133 - Logger.debug(`播放进度条:${position}/ ${this.duration}`) 135 + Logger.debug(TAG, `播放进度条:${position}/ ${this.duration}`)
134 this.initProgress(position); 136 this.initProgress(position);
135 137
136 } else if (bean.getCode() === InfoCode.BufferedPosition) { 138 } else if (bean.getCode() === InfoCode.BufferedPosition) {
@@ -140,7 +142,7 @@ export class WDAliListPlayerController { @@ -140,7 +142,7 @@ export class WDAliListPlayerController {
140 } 142 }
141 143
142 } else if (bean.getCode() === InfoCode.SwitchToSoftwareVideoDecoder) { 144 } else if (bean.getCode() === InfoCode.SwitchToSoftwareVideoDecoder) {
143 - Logger.debug(`DOWNGRADE TO SOFTWARE DECODE`) 145 + Logger.debug(TAG, `DOWNGRADE TO SOFTWARE DECODE`)
144 // this.mSwitchedToSoftListener?.onSwitched(); 146 // this.mSwitchedToSoftListener?.onSwitched();
145 } 147 }
146 } 148 }
@@ -148,7 +150,7 @@ export class WDAliListPlayerController { @@ -148,7 +150,7 @@ export class WDAliListPlayerController {
148 this.avPlayer?.setOnStateChangedListener({ 150 this.avPlayer?.setOnStateChangedListener({
149 onStateChanged: (status: number) => { 151 onStateChanged: (status: number) => {
150 this.avPlayerStatus = status 152 this.avPlayerStatus = status
151 - Logger.debug("status update:" + `${this.getStatusStringWith(status)}`) 153 + Logger.debug(TAG, "status update:" + `${this.getStatusStringWith(status)}`)
152 154
153 switch (status) { 155 switch (status) {
154 case initalized: { 156 case initalized: {
@@ -203,7 +205,7 @@ export class WDAliListPlayerController { @@ -203,7 +205,7 @@ export class WDAliListPlayerController {
203 }); 205 });
204 this.avPlayer?.setOnErrorListener({ 206 this.avPlayer?.setOnErrorListener({
205 onError:(errorInfo) => { 207 onError:(errorInfo) => {
206 - Logger.error("播放错误", JSON.stringify(errorInfo)) 208 + Logger.error(TAG, "播放错误", JSON.stringify(errorInfo))
207 this.errorCode = errorInfo.getCode() 209 this.errorCode = errorInfo.getCode()
208 this.errorMesage = errorInfo.getMsg() 210 this.errorMesage = errorInfo.getMsg()
209 this.status = PlayerConstants.STATUS_ERROR; 211 this.status = PlayerConstants.STATUS_ERROR;
@@ -212,14 +214,14 @@ export class WDAliListPlayerController { @@ -212,14 +214,14 @@ export class WDAliListPlayerController {
212 }); 214 });
213 this.avPlayer?.setOnLoadingStatusListener({ 215 this.avPlayer?.setOnLoadingStatusListener({
214 onLoadingBegin: () => { 216 onLoadingBegin: () => {
215 - // Logger.error("开始加载。。。") 217 + // Logger.error(TAG, "开始加载。。。")
216 }, 218 },
217 onLoadingProgress: (percent: number, netSpeed: number) => { 219 onLoadingProgress: (percent: number, netSpeed: number) => {
218 // this.loadingProgress = percent; 220 // this.loadingProgress = percent;
219 // this.loadingSpeed = netSpeed; 221 // this.loadingSpeed = netSpeed;
220 }, 222 },
221 onLoadingEnd: () => { 223 onLoadingEnd: () => {
222 - // Logger.error("结束加载") 224 + // Logger.error(TAG, "结束加载")
223 // this.showLoadingScene = false; 225 // this.showLoadingScene = false;
224 // this.loadingProgress = 0; 226 // this.loadingProgress = 0;
225 // this.loadingSpeed = 0; 227 // this.loadingSpeed = 0;
@@ -256,7 +258,7 @@ export class WDAliListPlayerController { @@ -256,7 +258,7 @@ export class WDAliListPlayerController {
256 258
257 public async addSources(sources: WDListPlayerData[]) { 259 public async addSources(sources: WDListPlayerData[]) {
258 if (this.avPlayer == null) { 260 if (this.avPlayer == null) {
259 - Logger.info("等待播放器初始化") 261 + Logger.info(TAG, "等待播放器初始化")
260 await this.initPromise; 262 await this.initPromise;
261 } 263 }
262 if (this.avPlayer == null) { 264 if (this.avPlayer == null) {
@@ -273,7 +275,7 @@ export class WDAliListPlayerController { @@ -273,7 +275,7 @@ export class WDAliListPlayerController {
273 public moveTo(uid: string, surfaceId: string) { 275 public moveTo(uid: string, surfaceId: string) {
274 let uidDatas = this.playSources.filter(data => data.uid === uid) 276 let uidDatas = this.playSources.filter(data => data.uid === uid)
275 if (uidDatas.length == 0) { 277 if (uidDatas.length == 0) {
276 - Logger.info("请先addSources()添加数据源url" + uid) 278 + Logger.info(TAG, "请先addSources()添加数据源url" + uid)
277 return 279 return
278 } 280 }
279 this.currentPlayRecord = uidDatas[0] 281 this.currentPlayRecord = uidDatas[0]
@@ -282,7 +284,7 @@ export class WDAliListPlayerController { @@ -282,7 +284,7 @@ export class WDAliListPlayerController {
282 // this.setAliPlayerURL(this.currentPlayRecord.url) 284 // this.setAliPlayerURL(this.currentPlayRecord.url)
283 285
284 let result = this.avPlayer?.moveTo(uid) 286 let result = this.avPlayer?.moveTo(uid)
285 - Logger.info("moveTo" + uid + ` result:${result}`) 287 + Logger.info(TAG, "moveTo " + uid + ` result:${result}`)
286 this.avPlayer?.prepare() 288 this.avPlayer?.prepare()
287 } 289 }
288 290
@@ -301,17 +303,17 @@ export class WDAliListPlayerController { @@ -301,17 +303,17 @@ export class WDAliListPlayerController {
301 } 303 }
302 304
303 public pause() { 305 public pause() {
304 - Logger.debug("暂停", this.url) 306 + Logger.debug(TAG, "暂停", this.url)
305 this.avPlayer?.pause(); 307 this.avPlayer?.pause();
306 } 308 }
307 309
308 public play() { 310 public play() {
309 - Logger.debug("播放", this.url) 311 + Logger.debug(TAG, "播放", this.url)
310 this.avPlayer?.start(); 312 this.avPlayer?.start();
311 } 313 }
312 314
313 public stop() { 315 public stop() {
314 - Logger.debug("停止", this.url) 316 + Logger.debug(TAG, "停止", this.url)
315 this.avPlayer?.stop(); 317 this.avPlayer?.stop();
316 } 318 }
317 319
@@ -419,7 +421,7 @@ export class WDAliListPlayerController { @@ -419,7 +421,7 @@ export class WDAliListPlayerController {
419 if (this.onVolumeUpdate) { 421 if (this.onVolumeUpdate) {
420 this.onVolumeUpdate(this.volume); 422 this.onVolumeUpdate(this.volume);
421 } 423 }
422 - console.log("volume : " + this.volume) 424 + Logger.debug(TAG, "volume : " + this.volume)
423 } 425 }
424 426
425 onBrightActionUpdate(event: GestureEvent) { 427 onBrightActionUpdate(event: GestureEvent) {
@@ -443,7 +445,7 @@ export class WDAliListPlayerController { @@ -443,7 +445,7 @@ export class WDAliListPlayerController {
443 } 445 }
444 446
445 watchStatus() { 447 watchStatus() {
446 - console.log('watchStatus', this.status) 448 + Logger.debug(TAG, 'watchStatus ' + this.status)
447 if (this.onStatusChange) { 449 if (this.onStatusChange) {
448 this.onStatusChange(this.status) 450 this.onStatusChange(this.status)
449 } 451 }