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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PlaybackService.isRunning && playbackService == null) {
|
synchronized (waitForService) {
|
||||||
synchronized (waitForService) {
|
if (PlaybackService.isRunning && playbackService == null) {
|
||||||
bindService(new Intent(this, PlaybackService.class), mConnection, 0);
|
bindService(new Intent(this, PlaybackService.class), mConnection, 0);
|
||||||
while (playbackService == null) {
|
while (playbackService == null) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1680,6 +1680,9 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
||||||
* an invalid state.
|
* an invalid state.
|
||||||
*/
|
*/
|
||||||
public int getDuration() {
|
public int getDuration() {
|
||||||
|
if (mediaPlayer == null) {
|
||||||
|
return INVALID_TIME;
|
||||||
|
}
|
||||||
return mediaPlayer.getDuration();
|
return mediaPlayer.getDuration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1688,6 +1691,9 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
||||||
* is in an invalid state.
|
* is in an invalid state.
|
||||||
*/
|
*/
|
||||||
public int getCurrentPosition() {
|
public int getCurrentPosition() {
|
||||||
|
if (mediaPlayer == null) {
|
||||||
|
return INVALID_TIME;
|
||||||
|
}
|
||||||
return mediaPlayer.getPosition();
|
return mediaPlayer.getPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue