添加以下日志,以便您知道片段会发生什么
playerManager.addEventListener(cast.framework.events.EventType.PLAYER_LOAD_COMPLETE, () => {
log('[mediacast:events:PLAYER_LOAD_COMPLETE');
console.log(playerManager.getStats());
console.log(playerManager.getMediaInformation());
});
playerManager.addEventListener(cast.framework.events.EventType.BITRATE_CHANGED, (event) => {
log('[mediacast:events:BITRATE_CHANGED - ' + event.totalBitrate);
stats.bitrate = event.totalBitrate;
console.log(playerManager.getStats());
});
playerManager.addEventListener(cast.framework.events.EventType.PLAYING, (event) => {
log('[mediacast:events:PLAYING - ', JSON.stringify(event));
});
playerManager.addEventListener(cast.framework.events.EventType.PAUSE, (event) => {
log('[mediacast:events:PAUSE - ', JSON.stringify(event));
});
playerManager.addEventListener(cast.framework.events.EventType.SEEKING, (event) => {
log('[mediacast:events:SEEKING - ', JSON.stringify(event));
});
playerManager.addEventListener(cast.framework.events.EventType.BUFFERING, (event) => {
log('[mediacast:events:BUFFERING - ', JSON.stringify(event));
});
playerManager.addEventListener(cast.framework.events.EventType.TIME_UPDATE, (event) => {
// log('[mediacast:events:TIME_UPDATE - ', JSON.stringify(event));
stats.currentMediaTime = event.currentMediaTime;
});
playerManager.addEventListener(cast.framework.events.EventType.MEDIA_STATUS, (event) => {
log('[mediacast:events:MEDIA_STATUS - ', JSON.stringify(event));
stats.state = event.mediaStatus.playerState;
});
并且不要忘记设置debug
为记录器级别
cast.framework.CastReceiverContext.getInstance().setLoggerLevel(cast.framework.LoggerLevel.DEBUG);