diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2013-08-23 14:58:09 +0200 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2013-08-23 14:58:09 +0200 |
commit | e8d0abe954b6cda97c99f90e9b0da75e8fa5f73a (patch) | |
tree | 112dab36af69e09957e3cc8089a9981dba480c87 /src | |
parent | eeec2d846f4b9af140a9620756cd29437d9294e1 (diff) | |
download | AntennaPod-e8d0abe954b6cda97c99f90e9b0da75e8fa5f73a.zip |
Catch RuntimeException thrown by MediaPlayer constructor
Diffstat (limited to 'src')
-rw-r--r-- | src/de/danoeh/antennapod/service/download/DownloadService.java | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/de/danoeh/antennapod/service/download/DownloadService.java b/src/de/danoeh/antennapod/service/download/DownloadService.java index c84a6f913..8b090981c 100644 --- a/src/de/danoeh/antennapod/service/download/DownloadService.java +++ b/src/de/danoeh/antennapod/service/download/DownloadService.java @@ -828,8 +828,9 @@ public class DownloadService extends Service { media.setFile_url(request.getDestination()); // Get duration - MediaPlayer mediaplayer = new MediaPlayer(); + MediaPlayer mediaplayer = null; try { + mediaplayer = new MediaPlayer(); mediaplayer.setDataSource(media.getFile_url()); mediaplayer.prepare(); media.setDuration(mediaplayer.getDuration()); @@ -838,8 +839,13 @@ public class DownloadService extends Service { mediaplayer.reset(); } catch (IOException e) { e.printStackTrace(); + } catch (RuntimeException e) { + // Thrown by MediaPlayer initialization on some devices + e.printStackTrace(); } finally { - mediaplayer.release(); + if (mediaplayer != null) { + mediaplayer.release(); + } } if (media.getItem().getChapters() == null) { |