ExoPlayer android Null指针异常

时间:2016-03-01 11:47:35

标签: android exoplayer

我一直在尝试使用开源Exo播放器流式传输视频,但我有一个空指针异常。我从Exo播放器开发者指南中获取了示例代码。请不要建议使用Exo Media。我想仅使用Exo播放器来实现它。希望有人能指导/指出我至少正确的方向。 surfaceView = (SurfaceView) findViewById(R.id.videoView); LoadControl loadControl= new DefaultLoadControl(new DefaultAllocator(BUFFER_SEGMENT_SIZE)); DefaultBandwidthMeter bandwidthMeter=new DefaultBandwidthMeter(); MediaPresentationDescriptionParser parser=new MediaPresentationDescriptionParser(); UriDataSource manifestDataSource=new DefaultUriDataSource(MainActivity.this,USER_AGENT); ManifestFetcher<MediaPresentationDescription> manifestFetcher=new ManifestFetcher<>(TEST_URL,manifestDataSource,parser);

    //Video renderer
    DataSource dataSource=new DefaultUriDataSource(MainActivity.this,bandwidthMeter,USER_AGENT);
    ChunkSource videoChunkSource=new DashChunkSource(manifestFetcher,
            DefaultDashTrackSelector.newVideoInstance(MainActivity.this,true,false),
            dataSource,new AdaptiveEvaluator(bandwidthMeter),
            LIVE_EDGE_LATENCY_MS,elapsedRealtimeOffset,
            null,null,TYPE_VIDEO);   // ***** NPE in this line ***
    ChunkSampleSource videoSampleSource=new ChunkSampleSource(videoChunkSource,loadControl, VIDEO_BUFFER_SEGMENTS*BUFFER_SEGMENT_SIZE);
    MediaCodecVideoTrackRenderer videoTrackRenderer=new MediaCodecVideoTrackRenderer(MainActivity.this,videoSampleSource,MediaCodecSelector.DEFAULT,MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT);


    //Audio renderer
    DataSource audioDataSource=new DefaultUriDataSource(MainActivity.this,bandwidthMeter,USER_AGENT);
    ChunkSource audioChunkSource=new DashChunkSource(manifestFetcher,DefaultDashTrackSelector.newAudioInstance(),audioDataSource,null,LIVE_EDGE_LATENCY_MS,elapsedRealtimeOffset,null,null,TYPE_AUDIO);
    ChunkSampleSource audioSampleSource=new ChunkSampleSource(audioChunkSource,loadControl,AUDIO_BUFFER_SEGMENTS*BUFFER_SEGMENT_SIZE);
    MediaCodecAudioTrackRenderer audioTrackRenderer=new MediaCodecAudioTrackRenderer(audioSampleSource,MediaCodecSelector.DEFAULT);

LOG

03-01 17:10:53.792 32222-32222/com.example.tinfimate.exotest1 E/AndroidRuntime: FATAL EXCEPTION: main
                                                                            java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.tinfimate.exotest1/com.example.tinfimate.exotest1.MainActivity}: java.lang.NullPointerException
                                                                                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2306)
                                                                                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2358)
                                                                                at android.app.ActivityThread.access$600(ActivityThread.java:156)
                                                                                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1340)
                                                                                at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                                at android.os.Looper.loop(Looper.java:153)
                                                                                at android.app.ActivityThread.main(ActivityThread.java:5299)
                                                                                at java.lang.reflect.Method.invokeNative(Native Method)
                                                                                at java.lang.reflect.Method.invoke(Method.java:511)
                                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
                                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
                                                                                at dalvik.system.NativeStart.main(Native Method)
                                                                             Caused by: java.lang.NullPointerException
                                                                                at com.google.android.exoplayer.dash.DashChunkSource.<init>(DashChunkSource.java:276)
                                                                                at com.google.android.exoplayer.dash.DashChunkSource.<init>(DashChunkSource.java:215)
                                                                                at com.example.tinfimate.exotest1.MainActivity.onCreate(MainActivity.java:87)
                                                                                at android.app.Activity.performCreate(Activity.java:5122)
                                                                                at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081)
                                                                                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2270)
                                                                                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2358) 
                                                                                at android.app.ActivityThread.access$600(ActivityThread.java:156) 
                                                                                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1340) 
                                                                                at android.os.Handler.dispatchMessage(Handler.java:99) 
                                                                                at android.os.Looper.loop(Looper.java:153) 
                                                                                at android.app.ActivityThread.main(ActivityThread.java:5299) 
                                                                                at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                                at java.lang.reflect.Method.invoke(Method.java:511) 
                                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833) 
                                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 
                                                                                at dalvik.system.NativeStart.main(Native Method) 

0 个答案:

没有答案