Currently playing media song using .playFromMediaId like this
if (mMediaBrowser.isConnected()) {
MediaControllerCompat.getMediaController(PlaybackActivity.this).getTransportControls()
.playFromMediaId(song.getMediaId(), null);
}
Now got the new requirement to play Radio URL instead of media file / song, so I am playing using .playFromUri like this
MediaControllerCompat.getMediaController(PlaybackActivity.this).getTransportControls()
.playFromUri(Uri.parse("http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio1_mf_p"), null);
But always getting Exception:
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.support.v4.media.MediaDescriptionCompat.getMediaId()' on a null object reference
Method where I am getting exception
public Song getCurrentPlayingSong() {
try {
for (Song song : LocalQueueManager.getInstance().getCurrentQueue()) {
if (String.valueOf(song.getRandomMediaId()).equalsIgnoreCase(currentPlayingDescription.getMediaId())) { // Exception
return song;
}
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
So my question is what to use If I would like to play Radio URL instead Song