嗨,在Android中使用Exoplayer,当用户单击任意位置时,它将引发空指针异常

时间:2018-08-29 05:55:52

标签: android exoplayer

我将解释以下情况:

我正在使用回收站视图将歌曲存储在列表中。 当用户单击回收商列表中的任何位置时,将执行用户单击的位置。例如:

歌曲索引是用户点击的位置

仅供参考,    例如:歌曲索引= 3;    mediaSources.length = 6;

MediaSource[] mediaSources = new MediaSource[playlist_ChildModelArrayList.size()];
for (int i = SongIndex; i < mediaSources.length; i++) {
if(mediaSources.length > 0){
String songUri = playlist_ChildModelArrayList.get(i).getMusicFile();
mediaSources[i] = new ExtractorMediaSource(Uri.parse(songUri), dataSourceFactory, extractorsFactory, null, null);
}
mediaSource = new ConcatenatingMediaSource(mediaSources);
/*mediaSource = mediaSources.length == 1 ? mediaSources[0]
}

我遇到以下错误

08-29 11:05:57.004 14688-15520/com.android.sampleexoaudioplayer E/AndroidRuntime: FATAL EXCEPTION: ExoPlayerImplInternal:Handler
Process: com.android.sampleexoaudioplayer, PID: 14688
**java.lang.NullPointerException: Attempt to invoke interface method 'void com.google.android.exoplayer2.source.MediaSource.releaseSource()' on a null object reference**
at com.google.android.exoplayer2.source.ConcatenatingMediaSource.releaseSource(ConcatenatingMediaSource.java:103)
at com.google.android.exoplayer2.ExoPlayerImplInternal.resetInternal(ExoPlayerImplInternal.java:724)
at com.google.android.exoplayer2.ExoPlayerImplInternal.stopInternal(ExoPlayerImplInternal.java:684)
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:364)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:148)
at android.os.HandlerThread.run(HandlerThread.java:61)
08-29 11:05:57.056 15108-15108/? E/STBMonitorReceiver: dropboxTag:data_app_crash;dropboxTime:1535520957050
08-29 11:05:57.115 15108-15108/? E/STBIntentService: Service Started..

伙计们帮帮我。

任何答案将不胜感激。

0 个答案:

没有答案