在我正在做的SessionManagerListener的onSessionStarted()回调中,
final RemoteMediaClient rmc = getRmc();
rmc.addListener(mRemoteStatusUpdateListener);
//Video url
MediaInfo.Builder bulider = new MediaInfo.Builder(url);
MediaMetadata md = new MediaMetadata(MediaMetadata.MEDIA_TYPE_TV_SHOW);
//Title for notification
String title = (episodeName + " " + seriesName).trim();
md.putString(MediaMetadata.KEY_TITLE, title.isEmpty() ? getString(R.string.app_name) : title);
//Images for notification
String imagePath = getThumbnailImage();
if (imagePath != null) {
md.addImage(new WebImage(Uri.parse(imagePath)));
md.addImage(new WebImage(Uri.parse(imagePath)));
}
//Adding licence
JSONObject j = new JSONObject();
try {
j.put("widevine_key", mStreamCustomFromServer);
j.put("playready_key", mStreamCustomFromServer);
j.put(Constants.PlayListConst.EPISODE_NAME, episodeName);
j.put(Constants.PlayListConst.SERIES_NAME, seriesName);
} catch (JSONException e) {
e.printStackTrace();
}
MediaInfo.Builder mi =
bulider.setStreamType(MediaInfo.STREAM_TYPE_BUFFERED)
.setContentType("video/mp4")
.setMetadata(md)
.setCustomData(j);
//We send a custom message to cast server to clear the player state (custom message sending part is not put here) and then load media as follows
rmc.load(mi, true, seekTo).setResultCallback(new ResultCallbacks<RemoteMediaClient.MediaChannelResult>() {
@Override
public void onSuccess(@NonNull RemoteMediaClient.MediaChannelResult mediaChannelResult) {
//Handling success
}
@Override
public void onFailure(@NonNull Status status) {
//Handling failure
}
});
rmc.load(mi,true,seekTo)没有为某些视频提供回调。此后没有进度更新回调。但视频将在Chromecast中播放。 在myplayer.js文件的onLoad()方法中,我正在做,
myPlayer.CastPlayer.prototype.onLoad_ = function(event) {
var info=new cast.receiver.MediaManager.LoadInfo((event.data),event.senderId);
var initialSeek = info.message.currentTime;
var stream = {
startTime: initialSeek,
url: info.message.media.contentId,
protData: {
'com.widevine.alpha': {
laURL: 'http://widevine.licensekeyserver.com/',
cdmData: info.message.media.customData.widevine_key,
},
'com.microsoft.playready': {
laURL: 'http://sldrm.licensekeyserver.com/core/rightsmanager.asmx',
cdmData: info.message.media.customData.playready_key,
}
}
};
// Initialize player.
videoKeyOs = new MediaPlayer();
videoKeyOs.init(videoHtml);
videoKeyOs.setAutoPlay(info.message.autoplay);
videoKeyOs.setConfig({
'// Debug.level': 'The level for output debug messages (0=none, 1=error, 2=warn, 3=info, 4=debug)',
'Debug.level': 1
});
}
getRmc()方法,
private RemoteMediaClient getRmc() {
CastSession cs = getCurrentSession();
if (cs != null) {
return cs.getRemoteMediaClient();
}
return null;
}
getCurrentSession()方法,
private CastSession getCurrentSession() {
SessionManager sm;
if (mCastContext != null && ((sm = mCastContext.getSessionManager()) != null)) {
return sm.getCurrentCastSession();
}
return null;
}
如果我将加载方法添加超时,
rmc.load(mi, true, seekTo).setResultCallback(new ResultCallbacks<RemoteMediaClient.MediaChannelResult>() {
@Override
public void onSuccess(@NonNull RemoteMediaClient.MediaChannelResult mediaChannelResult) {
//Handling success
}
@Override
public void onFailure(@NonNull Status status) {
//Handling failure
}
}, 10000, TimeUnit.MILLISECONDS);
然后调用onFailure,状态= [Status {statusCode = TIMEOUT,resolution = null}]
我想知道为什么某些视频失败了。有人请帮我找到解决方案。 在此先感谢:)