android - 在 android Broghtcove Exoplayer 实现中一个接一个地播放视频

标签 android video brightcove exoplayer

我正在尝试使用 Android 中的 Brightcove Exoplayer 一个接一个地播放视频。我能够在第一个视频结束时捕捉到事件类型“已完成”,然后我正在尝试播放下一个视频。但它停留在第一个视频的末尾。第二个视频没有播放。我收到 NullPointerException。我究竟做错了什么?这是我的代码:

public class MainActivity extends BrightcovePlayer {

    private final String TAG = this.getClass().getSimpleName();

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        setContentView(R.layout.activity_main);
        brightcoveVideoView = (BrightcoveExoPlayerVideoView) findViewById(R.id.brightcove_video_view);
        super.onCreate(savedInstanceState);

        EventEmitter eventEmitter = brightcoveVideoView.getEventEmitter();
        final Catalog catalog = new Catalog(eventEmitter, "accountID", "policy");

        catalog.findVideoByID("videoID1", new VideoListener() {

            @Override
            public void onVideo(Video video) {
                Log.v(TAG, "onVideo: video = " + video);
                brightcoveVideoView.add(video);
                brightcoveVideoView.start();
            }


        });

        eventEmitter.on("completed", new EventListener() {
            @Override
            public void processEvent(Event event) {

               catalog.findVideoByID("videoID2", new VideoListener() {

                    @Override
                    public void onVideo(Video video) {
                        brightcoveVideoView.clear();
                        brightcoveVideoView.stopPlayback();
                        brightcoveVideoView.seekTo(0);
                        Log.v(TAG, "onVideo: video = " + video);
                        brightcoveVideoView.add(video);
                        brightcoveVideoView.start();
                    }


                });
            }
        });


        // Log whether or not instance state in non-null.
        if (savedInstanceState != null) {
            Log.v(TAG, "Restoring saved position");
        } else {
            Log.v(TAG, "No saved state");
        }
    }
}

日志:

09-16 18:49:22.960  32438-32438/com.brightcove.player.samples.exoplayer.basic D/PlayButtonController﹕ Process event: completed.
09-16 18:49:22.960  32438-32438/com.brightcove.player.samples.exoplayer.basic V/AbstractButtonController﹕ Start of sync update: text = ; description = Pause.
09-16 18:49:22.970  32438-32438/com.brightcove.player.samples.exoplayer.basic V/AbstractButtonController﹕ End of sync update: text = ; description = Play.
09-16 18:49:22.970  32438-32438/com.brightcove.player.samples.exoplayer.basic D/MainActivity﹕ didPause { playheadPosition: 0 }
09-16 18:49:22.980  32438-32438/com.brightcove.player.samples.exoplayer.basic D/PlayButtonController﹕ Process event: didPause.
09-16 18:49:22.980  32438-32438/com.brightcove.player.samples.exoplayer.basic V/AbstractButtonController﹕ Start of sync update: text = ; description = Play.
09-16 18:49:22.980  32438-32438/com.brightcove.player.samples.exoplayer.basic V/AbstractButtonController﹕ End of sync update: text = ; description = Play.
09-16 18:49:22.980  32438-32438/com.brightcove.player.samples.exoplayer.basic V/BaseVideoView﹕ onMeasure: width = 1024, height = 550, videoWidth = 1024, videoHeight = 576, widthMode = MeasureSpec.EXACTLY, heightMode = MeasureSpec.EXACTLY
09-16 18:49:22.990    32438-369/com.brightcove.player.samples.exoplayer.basic I/ACodec﹕ [OMX.MARVELL.VIDEO.HW.CODA7542DECODER] Now Flushing
09-16 18:49:22.990    32438-369/com.brightcove.player.samples.exoplayer.basic I/ACodec﹕ [OMX.MARVELL.VIDEO.HW.CODA7542DECODER] Now Executing
09-16 18:49:22.990    32438-372/com.brightcove.player.samples.exoplayer.basic I/ACodec﹕ [OMX.SEC.aac.dec] Now Flushing
09-16 18:49:22.990    32438-372/com.brightcove.player.samples.exoplayer.basic I/ACodec﹕ [OMX.SEC.aac.dec] Now Executing
09-16 18:49:22.990  32438-32438/com.brightcove.player.samples.exoplayer.basic V/BaseVideoView﹕ onLayout: changed = false, left = 0, top = 0, right = 1024, bottom = 550
09-16 18:49:23.000  32438-32438/com.brightcove.player.samples.exoplayer.basic V/ExoPlayerVideoDisplayComponent﹕ onLoadStarted: sourceId: 0, length: -1, type: 1, trigger: 0, bitrate: 1351359, mediaStartTimeMs: 0, mediaEndTimeMs: 10000
09-16 18:49:23.250  32438-32438/com.brightcove.player.samples.exoplayer.basic D/MainActivity﹕ didHideMediaControls { }
09-16 18:49:23.480  32438-32438/com.brightcove.player.samples.exoplayer.basic V/BaseVideoView﹕ onMeasure: width = 1024, height = 550, videoWidth = 1024, videoHeight = 576, widthMode = MeasureSpec.EXACTLY, heightMode = MeasureSpec.EXACTLY
09-16 18:49:23.480  32438-32438/com.brightcove.player.samples.exoplayer.basic V/BaseVideoView﹕ onLayout: changed = false, left = 0, top = 0, right = 1024, bottom = 550
09-16 18:49:26.103    32438-336/com.brightcove.player.samples.exoplayer.basic D/dalvikvm﹕ GC_FOR_ALLOC freed 712K, 35% free 6530K/9900K, paused 28ms, total 28ms
09-16 18:49:26.573    32438-336/com.brightcove.player.samples.exoplayer.basic D/dalvikvm﹕ GC_FOR_ALLOC freed 8K, 34% free 6780K/10160K, paused 28ms, total 28ms
09-16 18:49:26.804  32438-32438/com.brightcove.player.samples.exoplayer.basic V/ExoPlayerVideoDisplayComponent﹕ onLoadCompleted: sourceId: 0, bytesLoaded: 1984152, type: 1, bitrate: 1351359, startTime: 0, endTime: 10000
09-16 18:49:26.804  32438-32438/com.brightcove.player.samples.exoplayer.basic V/ExoPlayerVideoDisplayComponent﹕ onLoadStarted: sourceId: 0, length: -1, type: 1, trigger: 0, bitrate: 1351359, mediaStartTimeMs: 10000, mediaEndTimeMs: 20000
09-16 18:49:27.134    32438-336/com.brightcove.player.samples.exoplayer.basic D/dalvikvm﹕ GC_FOR_ALLOC freed 30K, 33% free 7037K/10420K, paused 22ms, total 22ms
09-16 18:49:27.514    32438-336/com.brightcove.player.samples.exoplayer.basic D/dalvikvm﹕ GC_FOR_ALLOC freed 5K, 32% free 7293K/10680K, paused 20ms, total 20ms
09-16 18:49:27.855    32438-336/com.brightcove.player.samples.exoplayer.basic D/dalvikvm﹕ GC_FOR_ALLOC freed 3K, 31% free 7549K/10940K, paused 29ms, total 29ms
09-16 18:49:28.555  32438-32438/com.brightcove.player.samples.exoplayer.basic V/ExoPlayerVideoDisplayComponent﹕ onLoadCompleted: sourceId: 0, bytesLoaded: 1221624, type: 1, bitrate: 1351359, startTime: 10000, endTime: 20000
09-16 18:49:28.555  32438-32438/com.brightcove.player.samples.exoplayer.basic V/ExoPlayerVideoDisplayComponent﹕ onLoadStarted: sourceId: 0, length: -1, type: 1, trigger: 0, bitrate: 1351359, mediaStartTimeMs: 20000, mediaEndTimeMs: 30000
09-16 18:49:33.590  32438-32438/com.brightcove.player.samples.exoplayer.basic V/ExoPlayerVideoDisplayComponent﹕ onLoadCompleted: sourceId: 0, bytesLoaded: 1779232, type: 1, bitrate: 1351359, startTime: 20000, endTime: 30000
09-16 18:49:42.289  32438-32438/com.brightcove.player.samples.exoplayer.basic D/BrightcoveMediaController﹕ Processing onTouch for view: com.brightcove.player.view.BrightcoveExoPlayerVideoView{41dff550 VFE...C. .F...... 0,0-1024,550 #7f0b0000 app:id/brightcove_video_view}, with event: MotionEvent { action=ACTION_DOWN, id[0]=0, x[0]=452.44183, y[0]=261.5192, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=9956540, downTime=9956540, deviceId=3, source=0x1002 }.
09-16 18:49:42.289  32438-32438/com.brightcove.player.samples.exoplayer.basic D/BrightcoveMediaController﹕ The control bar is hidden, show the media controls...
09-16 18:49:42.289  32438-32438/com.brightcove.player.samples.exoplayer.basic I/BaseVideoView﹕ onTouchEvent
09-16 18:49:42.289  32438-32438/com.brightcove.player.samples.exoplayer.basic D/BrightcoveShowHideController﹕ Showing the media controls.  They will be hidden in 3000 milliseconds using animation style: FADE.
09-16 18:49:42.299  32438-32438/com.brightcove.player.samples.exoplayer.basic D/MainActivity﹕ showMediaControls { }
09-16 18:49:42.299  32438-32438/com.brightcove.player.samples.exoplayer.basic D/BrightcoveShowHideController﹕ Showing the media controls.  They will be hidden in 3000 milliseconds using animation style: FADE.
09-16 18:49:42.299  32438-32438/com.brightcove.player.samples.exoplayer.basic V/BaseVideoView﹕ onMeasure: width = 1024, height = 550, videoWidth = 1024, videoHeight = 576, widthMode = MeasureSpec.EXACTLY, heightMode = MeasureSpec.EXACTLY
09-16 18:49:42.299  32438-32438/com.brightcove.player.samples.exoplayer.basic V/BaseVideoView﹕ onLayout: changed = false, left = 0, top = 0, right = 1024, bottom = 550
09-16 18:49:42.309  32438-32438/com.brightcove.player.samples.exoplayer.basic D/MainActivity﹕ didShowMediaControls { controlsHeight: 64 }
09-16 18:49:42.309  32438-32438/com.brightcove.player.samples.exoplayer.basic D/MainActivity﹕ didShowMediaControls { controlsHeight: 64 }
09-16 18:49:45.302  32438-32438/com.brightcove.player.samples.exoplayer.basic D/MainActivity﹕ didHideMediaControls { }
09-16 18:49:45.512  32438-32438/com.brightcove.player.samples.exoplayer.basic V/BaseVideoView﹕ onMeasure: width = 1024, height = 550, videoWidth = 1024, videoHeight = 576, widthMode = MeasureSpec.EXACTLY, heightMode = MeasureSpec.EXACTLY
09-16 18:49:45.512  32438-32438/com.brightcove.player.samples.exoplayer.basic V/BaseVideoView﹕ onLayout: changed = false, left = 0, top = 0, right = 1024, bottom = 550
09-16 18:49:49.876    32438-332/com.brightcove.player.samples.exoplayer.basic D/HttpService﹕ response: {"description":null,"poster_sources":[{"src":"http://brightcove.vo.llnwd.net/v1/unsecured/media/accountID/201508/3522/accountID_4446404273001_videoID2-vs.jpg?pubId=accountID&videoId=videoID2"}],"tags":[],"cue_points":[],"custom_fields":{},"account_id":"accountID","sources":[{"avg_bitrate":997000,"width":640,"duration":134000,"size":16791137,"stream_name":"mp4:accountID/accountID_4446405618001_videoID2.mp4&1442415600000&782ccdd093adf6c97a4d9bc7d2962a49","codec":"H264","asset_id":"4446405618001","container":"MP4","height":360,"app_name":"rtmp://brightcove.fcod.llnwd.net/a500/e1/uds/rtmp/ondemand"},{"avg_bitrate":997000,"width":640,"src":"http://brightcove.vo.llnwd.net/e1/uds/pd/accountID/accountID_4446405618001_videoID2.mp4?pubId=accountID&videoId=videoID2","size":16791137,"height":360,"duration":134000,"container":"MP4","codec":"H264","asset_id":"4446405618001"},{"avg_bitrate":514000,"width":480,"duration":134000,"size":8664661,"stream_name":"mp4:accountID/accountID_4446405652001_videoID2.mp4&1442415600000&782ccdd093adf6c97a4d9bc7d2962a49","codec":"H264","asset_id":"4446405652001","container":"MP4","height":270,"app_name":"rtmp://brightcove.fcod.llnwd.net/a500/e1/uds/rtmp/ondemand"},{"avg_bitrate":514000,"width":480,"src":"http://brightcove.vo.llnwd.net/e1/uds/pd/accountID/accountID_4446405652001_videoID2.mp4?pubId=accountID&videoId=videoID2","size":8664661,"height":270,"duration":134000,"container":"MP4","codec":"H264","asset_id":"4446405652001"},{"avg_bitrate":1831000,"width":960,"duration":134000,"size":30751569,"stream_name":"mp4:accountID/accountID_4446407440001_videoID2.mp4&1442415600000&782ccdd093adf6c97a4d9bc7d2962a49","codec":"H264","asset_id":"4446407440001","container":"MP4","height":540,"app_name":"rtmp://brightcove.fcod.llnwd.net/a500/e1/uds/rtmp/ondemand"},{"avg_bitrate":1831000,"width":960,"src":"http://brightcove.vo.llnwd.net/e1/uds/pd/accountID/accountID_4446407440001_videoID2.mp4?pubId=accountID&videoId=videoID2","size":30751569,"height":540,"duration":134000,"container":"MP4","codec":"H264","asset_id":"4446407440001"},{"type":"application/x-mpegURL","src":"http://c.brightcove.com/services/mobile/streaming/index/master.m3u8?videoId=videoID2&pubId=accountID","container":"M2TS","codec":"H264"},{"type":"application/x-mpegURL","src":"https://secure.brightcove.com/services/mobile/streaming/index/master.m3u8?videoId=videoID2&pubId=accountID&secure=true","container":"M2TS","codec":"H264"}],"name":"Control And Coordination (Scared - X+Y).mp4","reference_id":null,"long_description":null,"duration":134000,"published_at":"2015-08-27T21:46:17.492Z","text_tracks":[],"updated_at":"2015-08-27T21:46:17.492Z","thumbnail":"http://brightcove.vo.llnwd.net/v1/unsecured/media/accountID/201508/3522/accountID_4446404304001_videoID2-th.jpg?pubId=accountID&videoId=videoID2","poster":"http://brightcove.vo.llnwd.net/v1/unsecured/media/accountID/201508/3522/accountID_4446404273001_videoID2-vs.jpg?pubId=accountID&videoId=videoID2","link":null,"id":"videoID2","ad_keys":null,"thumbnail_sources":[{"src":"http://brightcove.vo.llnwd.net/v1/unsecured/media/accountID/201508/3522/accountID_4446404304001_videoID2-th.jpg?pubId=accountID&videoId=videoID2"}],"created_at":"2015-08-27T07:11:46.648Z"}
09-16 18:49:49.876    32438-332/com.brightcove.player.samples.exoplayer.basic D/HttpService﹕ code: 200
09-16 18:49:49.876    32438-332/com.brightcove.player.samples.exoplayer.basic D/HttpService﹕ message: OK
09-16 18:49:49.896    32438-332/com.brightcove.player.samples.exoplayer.basic D/HttpService﹕ issuing GET request: https://metrics.brightcove.com/tracker?platform=android-native-sdk&device_os_version=4.4.2&range=27..28&device_type=tablet&destination=bcsdk%3A%2F%2FExoPlayer+Sample+App%2Fcom.brightcove.player.samples.exoplayer.basic&device_os=android&time=1442409562964&platform_version=4.4.2&event=video_engagement&domain=videocloud&account=accountID&device_cpu=armeabi-v7a&video_duration=30&video=videoID1, headers: {}
09-16 18:49:49.906  32438-32438/com.brightcove.player.samples.exoplayer.basic D/BaseVideoView﹕ Seeking to 0
09-16 18:49:49.906  32438-32438/com.brightcove.player.samples.exoplayer.basic V/MainActivity﹕ onVideo: video = Video{name: "Control And Coordination (Scared - X+Y).mp4", sourceCollections: 2, cuePoints: 0}
09-16 18:49:49.906  32438-32438/com.brightcove.player.samples.exoplayer.basic D/MainActivity﹕ willChangeVideo { currentVideo: null nextVideo: null index: 0 uuid: 96c2c14b-16b8-41fb-be17-00a3ec5fd907 }
09-16 18:49:49.906  32438-32438/com.brightcove.player.samples.exoplayer.basic D/MainActivity﹕ didChangeList { list: [Video{name: "Control And Coordination (Scared - X+Y).mp4", sourceCollections: 2, cuePoints: 0}] }
09-16 18:49:49.906  32438-32438/com.brightcove.player.samples.exoplayer.basic D/MainActivity﹕ stop { playheadPosition: 0 }
09-16 18:49:49.906  32438-32438/com.brightcove.player.samples.exoplayer.basic V/ExoPlayerVideoDisplayComponent﹕ ExoPlayerOnStopListener:
09-16 18:49:49.906  32438-32438/com.brightcove.player.samples.exoplayer.basic V/ExoPlayerVideoDisplayComponent﹕ destroyPlayer: exoPlayer = com.google.android.exoplayer.ExoPlayerImpl@41f8c768
09-16 18:49:49.906  32438-32438/com.brightcove.player.samples.exoplayer.basic V/ExoPlayerVideoDisplayComponent﹕ stopUpdater: null
09-16 18:49:49.906    32438-369/com.brightcove.player.samples.exoplayer.basic I/ACodec﹕ [OMX.MARVELL.VIDEO.HW.CODA7542DECODER] Now Executing->Idle
09-16 18:49:49.916    32438-369/com.brightcove.player.samples.exoplayer.basic I/ACodec﹕ [OMX.MARVELL.VIDEO.HW.CODA7542DECODER] Now Idle->Loaded
09-16 18:49:49.926    32438-369/com.brightcove.player.samples.exoplayer.basic I/ACodec﹕ [OMX.MARVELL.VIDEO.HW.CODA7542DECODER] Now Loaded
09-16 18:49:49.946    32438-369/com.brightcove.player.samples.exoplayer.basic I/ACodec﹕ [OMX.MARVELL.VIDEO.HW.CODA7542DECODER] Now uninitialized
09-16 18:49:49.956    32438-372/com.brightcove.player.samples.exoplayer.basic I/ACodec﹕ [OMX.SEC.aac.dec] Now Executing->Idle
09-16 18:49:49.966    32438-372/com.brightcove.player.samples.exoplayer.basic I/ACodec﹕ [OMX.SEC.aac.dec] Now Idle->Loaded
09-16 18:49:49.966    32438-372/com.brightcove.player.samples.exoplayer.basic I/ACodec﹕ [OMX.SEC.aac.dec] Now Loaded
09-16 18:49:49.966    32438-372/com.brightcove.player.samples.exoplayer.basic I/ACodec﹕ [OMX.SEC.aac.dec] Now uninitialized
09-16 18:49:49.966  32438-32438/com.brightcove.player.samples.exoplayer.basic D/PlayButtonController﹕ Process event: stop.
09-16 18:49:49.966  32438-32438/com.brightcove.player.samples.exoplayer.basic V/AbstractButtonController﹕ Start of sync update: text = ; description = Play.
09-16 18:49:49.966  32438-32438/com.brightcove.player.samples.exoplayer.basic V/AbstractButtonController﹕ End of sync update: text = ; description = Play.
09-16 18:49:49.966  32438-32438/com.brightcove.player.samples.exoplayer.basic D/MainActivity﹕ seekTo { seekPosition: 0 }
09-16 18:49:49.966  32438-32438/com.brightcove.player.samples.exoplayer.basic V/ExoPlayerVideoDisplayComponent﹕ ExoPlayerOnSeekListener:
09-16 18:49:49.966  32438-32438/com.brightcove.player.samples.exoplayer.basic D/MainActivity﹕ didChangeList { list: [Video{name: "Control And Coordination (Scared - X+Y).mp4", sourceCollections: 2, cuePoints: 0}] }
09-16 18:49:49.966  32438-32438/com.brightcove.player.samples.exoplayer.basic D/MainActivity﹕ willChangeVideo { currentVideo: Video{name: "Control And Coordination (Scared - X+Y).mp4", sourceCollections: 2, cuePoints: 0} nextVideo: Video{name: "Control And Coordination (Scared - X+Y).mp4", sourceCollections: 2, cuePoints: 0} index: 0 uuid: 07a14bbe-6920-404b-a3d6-a74459cde927 }
09-16 18:49:49.976  32438-32438/com.brightcove.player.samples.exoplayer.basic D/MainActivity﹕ setSource { }
09-16 18:49:49.976  32438-32438/com.brightcove.player.samples.exoplayer.basic V/ExoPlayerVideoDisplayComponent﹕ ExoPlayerOnSetSourceListener
09-16 18:49:49.976  32438-32438/com.brightcove.player.samples.exoplayer.basic V/ExoPlayerVideoDisplayComponent﹕ destroyPlayer: exoPlayer = null
09-16 18:49:49.976  32438-32438/com.brightcove.player.samples.exoplayer.basic E/com.brightcove.player.event.EventEmitterImpl@41e01b08﹕ processEvent() threw a throwable.
    java.lang.NullPointerException
            at com.brightcove.player.display.ExoPlayerVideoDisplayComponent.openVideo(ExoPlayerVideoDisplayComponent.java:425)
            at com.brightcove.player.display.ExoPlayerVideoDisplayComponent$ExoPlayerOnSetSourceListener.processEvent(ExoPlayerVideoDisplayComponent.java:533)
            at com.brightcove.player.event.EventEmitterImpl.invokeListenersForEventType(EventEmitterImpl.java:457)
            at com.brightcove.player.event.EventEmitterImpl.invokeListenersForEvent(EventEmitterImpl.java:428)
            at com.brightcove.player.event.EventEmitterImpl.access$300(EventEmitterImpl.java:41)
            at com.brightcove.player.event.EventEmitterImpl$1.handleMessage(EventEmitterImpl.java:73)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:146)
            at android.app.ActivityThread.main(ActivityThread.java:5598)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
            at dalvik.system.NativeStart.main(Native Method)
09-16 18:49:49.976  32438-32438/com.brightcove.player.samples.exoplayer.basic D/MainActivity﹕ didStop { playheadPosition: 0 }
09-16 18:49:50.226    32438-332/com.brightcove.player.samples.exoplayer.basic D/HttpService﹕ response: GIF89a������������������!�����������,��������������D��;
09-16 18:49:50.226    32438-332/com.brightcove.player.samples.exoplayer.basic D/HttpService﹕ code: 200
09-16 18:49:50.226    32438-332/com.brightcove.player.samples.exoplayer.basic D/HttpService﹕ message: OK
09-16 18:49:50.236    32438-332/com.brightcove.player.samples.exoplayer.basic D/HttpService﹕ issuing GET request: https://metrics.brightcove.com/tracker?device_os=android&platform=android-native-sdk&device_os_version=4.4.2&time=1442409562964&platform_version=4.4.2&event=video_complete&device_type=tablet&domain=videocloud&account=accountID&device_cpu=armeabi-v7a&video_duration=30&video=videoID1&destination=bcsdk%3A%2F%2FExoPlayer+Sample+App%2Fcom.brightcove.player.samples.exoplayer.basic, headers: {}
09-16 18:49:50.477    32438-332/com.brightcove.player.samples.exoplayer.basic D/HttpService﹕ response: GIF89a������������������!�����������,��������������D��;
09-16 18:49:50.477    32438-332/com.brightcove.player.samples.exoplayer.basic D/HttpService﹕ code: 200
09-16 18:49:50.477    32438-332/com.brightcove.player.samples.exoplayer.basic D/HttpService﹕ message: OK
09-16 18:49:50.487    32438-332/com.brightcove.player.samples.exoplayer.basic D/HttpService﹕ issuing GET request: https://metrics.brightcove.com/tracker?device_os=android&platform=android-native-sdk&device_os_version=4.4.2&time=1442409589981&platform_version=4.4.2&event=video_impression&device_type=tablet&domain=videocloud&account=accountID&device_cpu=armeabi-v7a&video=videoID2&destination=bcsdk%3A%2F%2FExoPlayer+Sample+App%2Fcom.brightcove.player.samples.exoplayer.basic, headers: {}
09-16 18:49:50.727    32438-332/com.brightcove.player.samples.exoplayer.basic D/HttpService﹕ response: GIF89a������������������!�����������,��������������D��;
09-16 18:49:50.727    32438-332/com.brightcove.player.samples.exoplayer.basic D/HttpService﹕ code: 200
09-16 18:49:50.727    32438-332/com.brightcove.player.samples.exoplayer.basic D/HttpService﹕ message: OK

最佳答案

有点晚了,但考虑没有答案......

弄乱视频列表(即在 BC 播放器中动态添加/删除 Video 对象 - 任何派生自 BaseVideoView 的对象)会很快使您脱轨,并且会让您 1) 哭泣或 2) 向无辜的旁观者尖叫:)

我有自己的理论,但与问题无关。

我们通过动态停止/销毁完成的播放器然后添加一个全新的播放器来播放下一个视频来解决问题。

这意味着:

  • 将您的视频列表保存在您的 Activity/fragment/ View 容器中
  • 当视频结束时,确保清除资源,然后从 View 列表中物理删除播放器 View
  • 显示预加载器或一些漂亮的动画
  • 添加或扩充另一个 exo 播放器实例(使用 Runnable 以避免上面的预加载器在准备时卡住),然后加载下一个视频
  • 隐藏预加载器并在分派(dispatch)视频准备好播放时播放视频

这非常有效, View 交换几乎是即时的 - 几乎不引人注意。

关于android - 在 android Broghtcove Exoplayer 实现中一个接一个地播放视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32610116/

相关文章:

android - SharedPreferences setChecked 崩溃

android - fragment 不会替换和隐藏另一个 fragment

Android如何显示歌曲内部歌词

android - OpenCV 中的 Photoshop Vibrance 效果

ios - 在 iOS 中无法使用 avfoundation 播放特定的 MP4 文件

audio - 在Brightcove中创建音频播放器

audio - 为什么我不能用 ffmpeg 重新排序我的 mpg 容器中的流?

facebook - 如何在 Facebook 上分享 YouTube 视频并在 iPad 上运行?

javascript - 恢复或设置 Brightcove 视频的开始时间

java - 通过代理访问时,HttpURLConnection 返回 503 错误