Merge pull request #2832 from ByteHamster/null-media-player
Do not crash if mediaPlayer is null
This commit is contained in:
commit
0ca7fc60b2
|
@ -44,8 +44,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 {
|
||||
|
|
|
@ -1685,6 +1685,9 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||
* an invalid state.
|
||||
*/
|
||||
public int getDuration() {
|
||||
if (mediaPlayer == null) {
|
||||
return INVALID_TIME;
|
||||
}
|
||||
return mediaPlayer.getDuration();
|
||||
}
|
||||
|
||||
|
@ -1693,6 +1696,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