mirror of
https://github.com/TeamNewPipe/NewPipe/
synced 2024-12-24 16:11:07 +01:00
Review Fixes
This commit is contained in:
parent
1d629e7b2e
commit
36457400e7
@ -152,6 +152,7 @@ public final class BackgroundPlayer extends Service {
|
|||||||
lockManager.releaseWifiAndCpu();
|
lockManager.releaseWifiAndCpu();
|
||||||
}
|
}
|
||||||
if (basePlayerImpl != null) {
|
if (basePlayerImpl != null) {
|
||||||
|
basePlayerImpl.audioReactor.unregisterMediaButtonEventReceiver(mReceiverComponent);
|
||||||
basePlayerImpl.stopActivityBinding();
|
basePlayerImpl.stopActivityBinding();
|
||||||
basePlayerImpl.destroy();
|
basePlayerImpl.destroy();
|
||||||
}
|
}
|
||||||
@ -160,8 +161,6 @@ public final class BackgroundPlayer extends Service {
|
|||||||
basePlayerImpl = null;
|
basePlayerImpl = null;
|
||||||
lockManager = null;
|
lockManager = null;
|
||||||
|
|
||||||
basePlayerImpl.audioReactor.unregisterMediaButtonEventReceiver(mReceiverComponent);
|
|
||||||
|
|
||||||
stopForeground(true);
|
stopForeground(true);
|
||||||
stopSelf();
|
stopSelf();
|
||||||
}
|
}
|
||||||
@ -594,6 +593,10 @@ public final class BackgroundPlayer extends Service {
|
|||||||
pendingIntent = PendingIntent.getBroadcast(context, NOTIFICATION_ID, new Intent(ACTION_PLAY_PREVIOUS), PendingIntent.FLAG_UPDATE_CURRENT);
|
pendingIntent = PendingIntent.getBroadcast(context, NOTIFICATION_ID, new Intent(ACTION_PLAY_PREVIOUS), PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
} else if (keycode == KeyEvent.KEYCODE_HEADSETHOOK) {
|
} else if (keycode == KeyEvent.KEYCODE_HEADSETHOOK) {
|
||||||
pendingIntent = PendingIntent.getBroadcast(context, NOTIFICATION_ID, new Intent(ACTION_PLAY_PAUSE), PendingIntent.FLAG_UPDATE_CURRENT);
|
pendingIntent = PendingIntent.getBroadcast(context, NOTIFICATION_ID, new Intent(ACTION_PLAY_PAUSE), PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
|
} else if (keycode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD) {
|
||||||
|
pendingIntent = PendingIntent.getBroadcast(context, NOTIFICATION_ID, new Intent(ACTION_FAST_FORWARD), PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
|
} else if (keycode == KeyEvent.KEYCODE_MEDIA_REWIND) {
|
||||||
|
pendingIntent = PendingIntent.getBroadcast(context, NOTIFICATION_ID, new Intent(ACTION_FAST_REWIND), PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
}
|
}
|
||||||
if (pendingIntent != null) {
|
if (pendingIntent != null) {
|
||||||
try {
|
try {
|
||||||
|
@ -88,10 +88,18 @@ public class AudioReactor implements AudioManager.OnAudioFocusChangeListener, Au
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void registerMediaButtonEventReceiver(ComponentName componentName) {
|
public void registerMediaButtonEventReceiver(ComponentName componentName) {
|
||||||
|
if (android.os.Build.VERSION.SDK_INT > 27) {
|
||||||
|
Log.e(TAG, "registerMediaButtonEventReceiver has been deprecated and maybe not supported anymore.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
audioManager.registerMediaButtonEventReceiver(componentName);
|
audioManager.registerMediaButtonEventReceiver(componentName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unregisterMediaButtonEventReceiver(ComponentName componentName) {
|
public void unregisterMediaButtonEventReceiver(ComponentName componentName) {
|
||||||
|
if (android.os.Build.VERSION.SDK_INT > 27) {
|
||||||
|
Log.e(TAG, "unregisterMediaButtonEventReceiver has been deprecated and maybe not supported anymore.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
audioManager.unregisterMediaButtonEventReceiver(componentName);
|
audioManager.unregisterMediaButtonEventReceiver(componentName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user