fix NPE when media is 'uncastable'

This commit is contained in:
Domingos Lopes 2016-05-07 14:10:37 -04:00
parent 4c81f0217d
commit 232ec987b5
2 changed files with 6 additions and 1 deletions

View File

@ -701,7 +701,7 @@ public class PlaybackService extends Service {
boolean isInQueue = false;
FeedItem nextItem = null;
if (playable instanceof FeedMedia) {
if (playable instanceof FeedMedia && ((FeedMedia) playable).getItem() != null) {
FeedMedia media = (FeedMedia) playable;
FeedItem item = media.getItem();

View File

@ -264,6 +264,11 @@ public class RemotePSMP extends PlaybackServiceMediaPlayer {
if (!CastUtils.isCastable(playable)) {
Log.d(TAG, "media provided is not compatible with cast device");
callback.onMediaPlayerInfo(CAST_ERROR_PRIORITY_HIGH, R.string.cast_not_castable);
try {
playable.loadMetadata();
} catch (Playable.PlayableException e) {
Log.e(TAG, "Unable to load metadata of playable", e);
}
callback.endPlayback(playable, startWhenPrepared, true, false);
return;
}