Do not crash if mediaPlayer is null
This commit is contained in:
parent
819d2df8ed
commit
33674625b4
|
@ -41,8 +41,8 @@ public class PlayerWidgetJobService extends JobIntentService {
|
|||
return;
|
||||
}
|
||||
|
||||
if (PlaybackService.isRunning && playbackService == null) {
|
||||
synchronized (waitForService) {
|
||||
synchronized (waitForService) {
|
||||
if (PlaybackService.isRunning && playbackService == null) {
|
||||
bindService(new Intent(this, PlaybackService.class), mConnection, 0);
|
||||
while (playbackService == null) {
|
||||
try {
|
||||
|
|
|
@ -1680,6 +1680,9 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||
* an invalid state.
|
||||
*/
|
||||
public int getDuration() {
|
||||
if (mediaPlayer == null) {
|
||||
return INVALID_TIME;
|
||||
}
|
||||
return mediaPlayer.getDuration();
|
||||
}
|
||||
|
||||
|
@ -1688,6 +1691,9 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||
* is in an invalid state.
|
||||
*/
|
||||
public int getCurrentPosition() {
|
||||
if (mediaPlayer == null) {
|
||||
return INVALID_TIME;
|
||||
}
|
||||
return mediaPlayer.getPosition();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue