PlaybackService crashed when media file was incorrect/not found

This commit is contained in:
daniel oeh 2013-08-17 17:05:14 +02:00
parent 46459b7c43
commit 462ff3cadc
2 changed files with 19 additions and 12 deletions

View File

@ -1282,18 +1282,20 @@ public class PlaybackService extends Service {
isPlaying = true;
}
Intent i = new Intent(AVRCP_ACTION_PLAYER_STATUS_CHANGED);
i.putExtra("id", 1);
i.putExtra("artist", "");
i.putExtra("album", media.getFeedTitle());
i.putExtra("track", media.getEpisodeTitle());
i.putExtra("playing", isPlaying);
if (queue != null) {
i.putExtra("ListSize", queue.size());
if (media != null) {
Intent i = new Intent(AVRCP_ACTION_PLAYER_STATUS_CHANGED);
i.putExtra("id", 1);
i.putExtra("artist", "");
i.putExtra("album", media.getFeedTitle());
i.putExtra("track", media.getEpisodeTitle());
i.putExtra("playing", isPlaying);
if (queue != null) {
i.putExtra("ListSize", queue.size());
}
i.putExtra("duration", media.getDuration());
i.putExtra("position", media.getPosition());
sendBroadcast(i);
}
i.putExtra("duration", media.getDuration());
i.putExtra("position", media.getPosition());
sendBroadcast(i);
}
/**

View File

@ -80,8 +80,13 @@ public class ExternalMedia implements Playable {
.extractMetadata(MediaMetadataRetriever.METADATA_KEY_TITLE);
feedTitle = mmr
.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ALBUM);
duration = Integer.parseInt(mmr
try {
duration = Integer.parseInt(mmr
.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION));
} catch (NumberFormatException e) {
e.printStackTrace();
throw new PlayableException("NumberFormatException when reading duration of media file");
}
ChapterUtils.loadChaptersFromFileUrl(this);
}