summaryrefslogtreecommitdiff
path: root/src/de
diff options
context:
space:
mode:
authordaniel oeh <daniel.oeh@gmail.com>2013-08-17 17:05:14 +0200
committerdaniel oeh <daniel.oeh@gmail.com>2013-08-17 17:05:14 +0200
commit462ff3cadc0c0c25d693b8028d0757cb82f1759e (patch)
treeef074c7376c3bf8b419be15bdeb3204c31a8ab85 /src/de
parent46459b7c4393b831b003ffaa438cf027a524d774 (diff)
downloadAntennaPod-462ff3cadc0c0c25d693b8028d0757cb82f1759e.zip
PlaybackService crashed when media file was incorrect/not found
Diffstat (limited to 'src/de')
-rw-r--r--src/de/danoeh/antennapod/service/PlaybackService.java24
-rw-r--r--src/de/danoeh/antennapod/util/playback/ExternalMedia.java7
2 files changed, 19 insertions, 12 deletions
diff --git a/src/de/danoeh/antennapod/service/PlaybackService.java b/src/de/danoeh/antennapod/service/PlaybackService.java
index 7c306984c..12c005765 100644
--- a/src/de/danoeh/antennapod/service/PlaybackService.java
+++ b/src/de/danoeh/antennapod/service/PlaybackService.java
@@ -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);
}
/**
diff --git a/src/de/danoeh/antennapod/util/playback/ExternalMedia.java b/src/de/danoeh/antennapod/util/playback/ExternalMedia.java
index 1ada0ec03..c08b221f9 100644
--- a/src/de/danoeh/antennapod/util/playback/ExternalMedia.java
+++ b/src/de/danoeh/antennapod/util/playback/ExternalMedia.java
@@ -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);
}