Prevented IllegalStateException when calling getDurationSafe()

This commit is contained in:
daniel oeh 2012-10-14 12:40:47 +02:00
parent f76ac9ed42
commit 9df7f7989d
1 changed files with 8 additions and 2 deletions

View File

@ -766,7 +766,8 @@ public class PlaybackService extends Service {
* @param abandonFocus
* is true if the service should release audio focus
* @param reset
* is true if service should reinit after pausing if the media file is being streamed
* is true if service should reinit after pausing if the media
* file is being streamed
*/
public void pause(boolean abandonFocus, boolean reinit) {
if (player.isPlaying()) {
@ -1226,7 +1227,12 @@ public class PlaybackService extends Service {
case PLAYING:
case PAUSED:
case SEEKING:
return player.getDuration();
try {
return player.getDuration();
} catch (IllegalStateException e) {
e.printStackTrace();
return INVALID_TIME;
}
default:
return INVALID_TIME;
}