@javascriptcommon/react-native-track-player 1.2.25 → 1.2.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -18,9 +18,12 @@ import android.support.v4.media.MediaBrowserCompat.MediaItem
|
|
|
18
18
|
import android.support.v4.media.RatingCompat
|
|
19
19
|
import android.support.v4.media.session.MediaSessionCompat
|
|
20
20
|
import android.support.v4.media.session.PlaybackStateCompat
|
|
21
|
+
import android.view.KeyEvent
|
|
22
|
+
import android.view.KeyEvent.KEYCODE_MEDIA_STOP
|
|
21
23
|
import androidx.annotation.MainThread
|
|
22
24
|
import androidx.core.app.NotificationCompat
|
|
23
25
|
import androidx.media.MediaBrowserServiceCompat
|
|
26
|
+
import androidx.media.session.MediaButtonReceiver
|
|
24
27
|
import androidx.media.utils.MediaConstants
|
|
25
28
|
import com.facebook.react.ReactHost
|
|
26
29
|
import com.facebook.react.ReactInstanceEventListener
|
|
@@ -668,8 +671,34 @@ class MusicService : HeadlessJsMediaService() {
|
|
|
668
671
|
}
|
|
669
672
|
|
|
670
673
|
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
|
674
|
+
if (intent == null) {
|
|
675
|
+
return START_NOT_STICKY
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
if (Intent.ACTION_MEDIA_BUTTON == intent.action) {
|
|
679
|
+
@Suppress("DEPRECATION")
|
|
680
|
+
val intentExtra: KeyEvent? = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT)
|
|
681
|
+
if (intentExtra!!.keyCode == KEYCODE_MEDIA_STOP) {
|
|
682
|
+
intentToStop = true
|
|
683
|
+
startServiceOreoAndAbove()
|
|
684
|
+
stopSelf()
|
|
685
|
+
} else {
|
|
686
|
+
intentToStop = false
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
if (manager != null) {
|
|
690
|
+
MediaButtonReceiver.handleIntent(manager!!.metadata.session, intent)
|
|
691
|
+
return START_NOT_STICKY
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
if (manager == null) manager = MusicManager(this)
|
|
696
|
+
|
|
697
|
+
@Suppress("DEPRECATION")
|
|
698
|
+
if (handler == null) handler = Handler()
|
|
699
|
+
|
|
671
700
|
startTask(getTaskConfig(intent))
|
|
672
|
-
|
|
701
|
+
startAndStopEmptyNotificationToAvoidANR()
|
|
673
702
|
return START_STICKY
|
|
674
703
|
}
|
|
675
704
|
|