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;
|
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 {
|
||||||
|
@ -1685,6 +1685,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();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1693,6 +1696,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…
x
Reference in New Issue
Block a user