Merge pull request #2832 from ByteHamster/null-media-player

Do not crash if mediaPlayer is null
This commit is contained in:
Martin Fietz 2018-09-27 13:53:41 +02:00 committed by GitHub
commit 0ca7fc60b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -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 {

View File

@ -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();
}