Fixed wired headset handling
Fixed MediaPlayer start timeout for slow phones
This commit is contained in:
parent
60250a42a9
commit
091374f922
|
@ -184,6 +184,7 @@ public class MediaPlayerLifecycleSupport
|
|||
int keyCode = event.getKeyCode();
|
||||
boolean autoStart = (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE ||
|
||||
keyCode == KeyEvent.KEYCODE_MEDIA_PLAY ||
|
||||
keyCode == KeyEvent.KEYCODE_HEADSETHOOK ||
|
||||
keyCode == KeyEvent.KEYCODE_MEDIA_PREVIOUS ||
|
||||
keyCode == KeyEvent.KEYCODE_MEDIA_NEXT);
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ public class MediaPlayerService extends Service
|
|||
public static MediaPlayerService getInstance(Context context)
|
||||
{
|
||||
synchronized (instanceLock) {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
for (int i = 0; i < 20; i++) {
|
||||
if (instance != null) return instance;
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
|
@ -113,6 +113,12 @@ public class MediaPlayerService extends Service
|
|||
public void run()
|
||||
{
|
||||
MediaPlayerService instance = getInstance(context);
|
||||
if (instance == null)
|
||||
{
|
||||
Log.e(TAG, "ExecuteOnStartedMediaPlayerService failed to get a MediaPlayerService instance!");
|
||||
return;
|
||||
}
|
||||
|
||||
taskToExecute.accept(instance);
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue