我正在应用中使用Brightcove Exoplayer来流式传输视频。但是,我注意到它不能完全自行处理网络中断(先断开再连接)。
在以下情况下将无法继续播放:
是否有任何Brightcove认可/解释的方式来处理这些用例?
我的代码:
public class BrightCoveActivity extends BrightcovePlayer {
private static final String AUTH_TOKEN = "<The Auth Token>";
private static final String TAG = BrightCoveActivity.class.getSimpleName();
private BrightcoveExoPlayerVideoView brightcoveExoPlayerVideoView;
private EventEmitter eventEmmiter;
private Context mContext;
private MediaController mMediaController;
@Override
protected void onCreate(Bundle savedInstanceState) {
Log.d(TAG, "onCreate");
setContentView(R.layout.activity_bright_cove);
brightcoveExoPlayerVideoView = (BrightcoveExoPlayerVideoView) findViewById(R.id.brightcove_video_view);
super.onCreate(savedInstanceState);
mContext = this;
final Catalog catalog = new Catalog(AUTH_TOKEN);
fullScreen();
mMediaController = new MediaController(this);
brightcoveExoPlayerVideoView.setMediaController(mMediaController);
eventEmmiter = brightcoveExoPlayerVideoView.getEventEmitter();
prepareEventEmmiter(); // puts all event listeners in place.
catalog.findVideoByID(VIDEO_ID, new VideoListener() {
@Override
public void onError(String error) {
throw new RuntimeException(error);
}
@Override
public void onVideo(Video video) {
brightcoveExoPlayerVideoView.add(video);
brightcoveExoPlayerVideoView.start();
}
});
}
/*
More code not related to playback
*/
}
处理这种情况的更好方法是,监听应用程序内部的网络变化,并从目录中获取视频。执行此操作时,您将需要处理各种事情(如果有广告管理,则在事件进行中保持当前位置,并在完成目录提取后重用相同的位置,等等。)