Catch RuntimeException thrown by MediaPlayer constructor
This commit is contained in:
parent
eeec2d846f
commit
e8d0abe954
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue