mirror of
https://gitlab.com/ultrasonic/ultrasonic.git
synced 2025-04-29 15:11:34 +03:00
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();
|
int keyCode = event.getKeyCode();
|
||||||
boolean autoStart = (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE ||
|
boolean autoStart = (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE ||
|
||||||
keyCode == KeyEvent.KEYCODE_MEDIA_PLAY ||
|
keyCode == KeyEvent.KEYCODE_MEDIA_PLAY ||
|
||||||
|
keyCode == KeyEvent.KEYCODE_HEADSETHOOK ||
|
||||||
keyCode == KeyEvent.KEYCODE_MEDIA_PREVIOUS ||
|
keyCode == KeyEvent.KEYCODE_MEDIA_PREVIOUS ||
|
||||||
keyCode == KeyEvent.KEYCODE_MEDIA_NEXT);
|
keyCode == KeyEvent.KEYCODE_MEDIA_NEXT);
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ public class MediaPlayerService extends Service
|
|||||||
public static MediaPlayerService getInstance(Context context)
|
public static MediaPlayerService getInstance(Context context)
|
||||||
{
|
{
|
||||||
synchronized (instanceLock) {
|
synchronized (instanceLock) {
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 20; i++) {
|
||||||
if (instance != null) return instance;
|
if (instance != null) return instance;
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
@ -113,6 +113,12 @@ public class MediaPlayerService extends Service
|
|||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
MediaPlayerService instance = getInstance(context);
|
MediaPlayerService instance = getInstance(context);
|
||||||
|
if (instance == null)
|
||||||
|
{
|
||||||
|
Log.e(TAG, "ExecuteOnStartedMediaPlayerService failed to get a MediaPlayerService instance!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
taskToExecute.accept(instance);
|
taskToExecute.accept(instance);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user