Prevented IllegalStateException when calling getDurationSafe()
This commit is contained in:
parent
f76ac9ed42
commit
9df7f7989d
|
@ -766,7 +766,8 @@ public class PlaybackService extends Service {
|
||||||
* @param abandonFocus
|
* @param abandonFocus
|
||||||
* is true if the service should release audio focus
|
* is true if the service should release audio focus
|
||||||
* @param reset
|
* @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) {
|
public void pause(boolean abandonFocus, boolean reinit) {
|
||||||
if (player.isPlaying()) {
|
if (player.isPlaying()) {
|
||||||
|
@ -1226,7 +1227,12 @@ public class PlaybackService extends Service {
|
||||||
case PLAYING:
|
case PLAYING:
|
||||||
case PAUSED:
|
case PAUSED:
|
||||||
case SEEKING:
|
case SEEKING:
|
||||||
return player.getDuration();
|
try {
|
||||||
|
return player.getDuration();
|
||||||
|
} catch (IllegalStateException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return INVALID_TIME;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return INVALID_TIME;
|
return INVALID_TIME;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue