Merge pull request #1927 from domingos86/uncastable-fix

fix NPE when media is 'uncastable'
This commit is contained in:
Tom Hennen 2016-05-08 13:54:08 -04:00
commit bd8e94b3bc
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;
}