|
|
|
|
@ -1,49 +1,27 @@
|
|
|
|
|
diff --git a/ios/RNTrackPlayer/RNTrackPlayerBridge.m b/ios/RNTrackPlayer/RNTrackPlayerBridge.m
|
|
|
|
|
index 7741994191921ed86f7577f7ce589b3939d9dd49..776c09ec0ae450daa4dc9031ccd3ff4baba016d3 100644
|
|
|
|
|
--- a/ios/RNTrackPlayer/RNTrackPlayerBridge.m
|
|
|
|
|
+++ b/ios/RNTrackPlayer/RNTrackPlayerBridge.m
|
|
|
|
|
@@ -151,17 +151,4 @@ @interface RCT_EXTERN_REMAP_MODULE(TrackPlayerModule, RNTrackPlayer, NSObject)
|
|
|
|
|
resolver:(RCTPromiseResolveBlock)resolve
|
|
|
|
|
rejecter:(RCTPromiseRejectBlock)reject);
|
|
|
|
|
|
|
|
|
|
-RCT_EXTERN_METHOD(getSleepTimerProgress:(RCTPromiseResolveBlock)resolve
|
|
|
|
|
- rejecter:(RCTPromiseRejectBlock)reject);
|
|
|
|
|
-
|
|
|
|
|
-RCT_EXTERN_METHOD(setSleepTimer:(double)time
|
|
|
|
|
- resolver:(RCTPromiseResolveBlock)resolve
|
|
|
|
|
- rejecter:(RCTPromiseRejectBlock)reject);
|
|
|
|
|
-
|
|
|
|
|
-RCT_EXTERN_METHOD(sleepWhenActiveTrackReachesEnd:(RCTPromiseResolveBlock)resolve
|
|
|
|
|
- rejecter:(RCTPromiseRejectBlock)reject);
|
|
|
|
|
-
|
|
|
|
|
-RCT_EXTERN_METHOD(clearSleepTimer:(RCTPromiseResolveBlock)resolve
|
|
|
|
|
- rejecter:(RCTPromiseRejectBlock)reject);
|
|
|
|
|
-
|
|
|
|
|
@end
|
|
|
|
|
diff --git a/android/src/main/java/com/doublesymmetry/trackplayer/module/MusicModule.kt b/android/src/main/java/com/doublesymmetry/trackplayer/module/MusicModule.kt
|
|
|
|
|
index b2409a09939164c49c0f7a16bb6d3284e8eab8fb..099caae67c52d27e451a0a5e7b11ca3645dfcd9d 100644
|
|
|
|
|
index b2409a09939164c49c0f7a16bb6d3284e8eab8fb..5f434a6931977d4b56d359295d53ef024c5984a6 100644
|
|
|
|
|
--- a/android/src/main/java/com/doublesymmetry/trackplayer/module/MusicModule.kt
|
|
|
|
|
+++ b/android/src/main/java/com/doublesymmetry/trackplayer/module/MusicModule.kt
|
|
|
|
|
@@ -251,8 +251,8 @@ class MusicModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaM
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ReactMethod
|
|
|
|
|
- fun updateOptions(data: ReadableMap?, callback: Promise) = scope.launch {
|
|
|
|
|
- if (verifyServiceBoundOrReject(callback)) return@launch
|
|
|
|
|
+ fun updateOptions(data: ReadableMap?, callback: Promise) = launchInScope {
|
|
|
|
|
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val options = Arguments.toBundle(data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -264,14 +264,14 @@ class MusicModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaM
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ReactMethod
|
|
|
|
|
- fun add(data: ReadableArray?, insertBeforeIndex: Int, callback: Promise) = scope.launch {
|
|
|
|
|
- if (verifyServiceBoundOrReject(callback)) return@launch
|
|
|
|
|
+ fun add(data: ReadableArray?, insertBeforeIndex: Int, callback: Promise) = launchInScope {
|
|
|
|
|
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
val tracks = readableArrayToTrackList(data);
|
|
|
|
|
if (insertBeforeIndex < -1 || insertBeforeIndex > musicService.tracks.size) {
|
|
|
|
|
@ -55,7 +33,7 @@ index b2409a09939164c49c0f7a16bb6d3284e8eab8fb..099caae67c52d27e451a0a5e7b11ca36
|
|
|
|
|
musicService.add(
|
|
|
|
|
@@ -285,11 +285,11 @@ class MusicModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaM
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ReactMethod
|
|
|
|
|
- fun load(data: ReadableMap?, callback: Promise) = scope.launch {
|
|
|
|
|
- if (verifyServiceBoundOrReject(callback)) return@launch
|
|
|
|
|
@ -70,7 +48,7 @@ index b2409a09939164c49c0f7a16bb6d3284e8eab8fb..099caae67c52d27e451a0a5e7b11ca36
|
|
|
|
|
if (bundle is Bundle) {
|
|
|
|
|
@@ -301,15 +301,15 @@ class MusicModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaM
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ReactMethod
|
|
|
|
|
- fun move(fromIndex: Int, toIndex: Int, callback: Promise) = scope.launch {
|
|
|
|
|
- if (verifyServiceBoundOrReject(callback)) return@launch
|
|
|
|
|
@ -79,7 +57,7 @@ index b2409a09939164c49c0f7a16bb6d3284e8eab8fb..099caae67c52d27e451a0a5e7b11ca36
|
|
|
|
|
musicService.move(fromIndex, toIndex)
|
|
|
|
|
callback.resolve(null)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ReactMethod
|
|
|
|
|
- fun remove(data: ReadableArray?, callback: Promise) = scope.launch {
|
|
|
|
|
- if (verifyServiceBoundOrReject(callback)) return@launch
|
|
|
|
|
@ -98,262 +76,262 @@ index b2409a09939164c49c0f7a16bb6d3284e8eab8fb..099caae67c52d27e451a0a5e7b11ca36
|
|
|
|
|
indexes.add(index)
|
|
|
|
|
}
|
|
|
|
|
@@ -332,8 +332,8 @@ class MusicModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaM
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ReactMethod
|
|
|
|
|
fun updateMetadataForTrack(index: Int, map: ReadableMap?, callback: Promise) =
|
|
|
|
|
- scope.launch {
|
|
|
|
|
- if (verifyServiceBoundOrReject(callback)) return@launch
|
|
|
|
|
+ launchInScope {
|
|
|
|
|
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (index < 0 || index >= musicService.tracks.size) {
|
|
|
|
|
callback.reject("index_out_of_bounds", "The index is out of bounds")
|
|
|
|
|
@@ -348,8 +348,8 @@ class MusicModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaM
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ReactMethod
|
|
|
|
|
- fun updateNowPlayingMetadata(map: ReadableMap?, callback: Promise) = scope.launch {
|
|
|
|
|
- if (verifyServiceBoundOrReject(callback)) return@launch
|
|
|
|
|
+ fun updateNowPlayingMetadata(map: ReadableMap?, callback: Promise) = launchInScope {
|
|
|
|
|
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (musicService.tracks.isEmpty())
|
|
|
|
|
callback.reject("no_current_item", "There is no current item in the player")
|
|
|
|
|
@@ -364,8 +364,8 @@ class MusicModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaM
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ReactMethod
|
|
|
|
|
- fun clearNowPlayingMetadata(callback: Promise) = scope.launch {
|
|
|
|
|
- if (verifyServiceBoundOrReject(callback)) return@launch
|
|
|
|
|
+ fun clearNowPlayingMetadata(callback: Promise) = launchInScope {
|
|
|
|
|
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (musicService.tracks.isEmpty())
|
|
|
|
|
callback.reject("no_current_item", "There is no current item in the player")
|
|
|
|
|
@@ -375,16 +375,16 @@ class MusicModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaM
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ReactMethod
|
|
|
|
|
- fun removeUpcomingTracks(callback: Promise) = scope.launch {
|
|
|
|
|
- if (verifyServiceBoundOrReject(callback)) return@launch
|
|
|
|
|
+ fun removeUpcomingTracks(callback: Promise) = launchInScope {
|
|
|
|
|
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
musicService.removeUpcomingTracks()
|
|
|
|
|
callback.resolve(null)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ReactMethod
|
|
|
|
|
- fun skip(index: Int, initialTime: Float, callback: Promise) = scope.launch {
|
|
|
|
|
- if (verifyServiceBoundOrReject(callback)) return@launch
|
|
|
|
|
+ fun skip(index: Int, initialTime: Float, callback: Promise) = launchInScope {
|
|
|
|
|
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
musicService.skip(index)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -396,8 +396,8 @@ class MusicModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaM
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ReactMethod
|
|
|
|
|
- fun skipToNext(initialTime: Float, callback: Promise) = scope.launch {
|
|
|
|
|
- if (verifyServiceBoundOrReject(callback)) return@launch
|
|
|
|
|
+ fun skipToNext(initialTime: Float, callback: Promise) = launchInScope {
|
|
|
|
|
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
musicService.skipToNext()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -409,8 +409,8 @@ class MusicModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaM
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ReactMethod
|
|
|
|
|
- fun skipToPrevious(initialTime: Float, callback: Promise) = scope.launch {
|
|
|
|
|
- if (verifyServiceBoundOrReject(callback)) return@launch
|
|
|
|
|
+ fun skipToPrevious(initialTime: Float, callback: Promise) = launchInScope {
|
|
|
|
|
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
musicService.skipToPrevious()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -422,8 +422,8 @@ class MusicModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaM
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ReactMethod
|
|
|
|
|
- fun reset(callback: Promise) = scope.launch {
|
|
|
|
|
- if (verifyServiceBoundOrReject(callback)) return@launch
|
|
|
|
|
+ fun reset(callback: Promise) = launchInScope {
|
|
|
|
|
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
musicService.stop()
|
|
|
|
|
delay(300) // Allow playback to stop
|
|
|
|
|
@@ -433,116 +433,116 @@ class MusicModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaM
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ReactMethod
|
|
|
|
|
- fun play(callback: Promise) = scope.launch {
|
|
|
|
|
- if (verifyServiceBoundOrReject(callback)) return@launch
|
|
|
|
|
+ fun play(callback: Promise) = launchInScope {
|
|
|
|
|
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
musicService.play()
|
|
|
|
|
callback.resolve(null)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ReactMethod
|
|
|
|
|
- fun pause(callback: Promise) = scope.launch {
|
|
|
|
|
- if (verifyServiceBoundOrReject(callback)) return@launch
|
|
|
|
|
+ fun pause(callback: Promise) = launchInScope {
|
|
|
|
|
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
musicService.pause()
|
|
|
|
|
callback.resolve(null)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ReactMethod
|
|
|
|
|
- fun stop(callback: Promise) = scope.launch {
|
|
|
|
|
- if (verifyServiceBoundOrReject(callback)) return@launch
|
|
|
|
|
+ fun stop(callback: Promise) = launchInScope {
|
|
|
|
|
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
musicService.stop()
|
|
|
|
|
callback.resolve(null)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ReactMethod
|
|
|
|
|
- fun seekTo(seconds: Float, callback: Promise) = scope.launch {
|
|
|
|
|
- if (verifyServiceBoundOrReject(callback)) return@launch
|
|
|
|
|
+ fun seekTo(seconds: Float, callback: Promise) = launchInScope {
|
|
|
|
|
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
musicService.seekTo(seconds)
|
|
|
|
|
callback.resolve(null)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ReactMethod
|
|
|
|
|
- fun seekBy(offset: Float, callback: Promise) = scope.launch {
|
|
|
|
|
- if (verifyServiceBoundOrReject(callback)) return@launch
|
|
|
|
|
+ fun seekBy(offset: Float, callback: Promise) = launchInScope {
|
|
|
|
|
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
musicService.seekBy(offset)
|
|
|
|
|
callback.resolve(null)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ReactMethod
|
|
|
|
|
- fun retry(callback: Promise) = scope.launch {
|
|
|
|
|
- if (verifyServiceBoundOrReject(callback)) return@launch
|
|
|
|
|
+ fun retry(callback: Promise) = launchInScope {
|
|
|
|
|
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
musicService.retry()
|
|
|
|
|
callback.resolve(null)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ReactMethod
|
|
|
|
|
- fun setVolume(volume: Float, callback: Promise) = scope.launch {
|
|
|
|
|
- if (verifyServiceBoundOrReject(callback)) return@launch
|
|
|
|
|
+ fun setVolume(volume: Float, callback: Promise) = launchInScope {
|
|
|
|
|
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
musicService.setVolume(volume)
|
|
|
|
|
callback.resolve(null)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ReactMethod
|
|
|
|
|
- fun getVolume(callback: Promise) = scope.launch {
|
|
|
|
|
- if (verifyServiceBoundOrReject(callback)) return@launch
|
|
|
|
|
+ fun getVolume(callback: Promise) = launchInScope {
|
|
|
|
|
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
callback.resolve(musicService.getVolume())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ReactMethod
|
|
|
|
|
- fun setRate(rate: Float, callback: Promise) = scope.launch {
|
|
|
|
|
- if (verifyServiceBoundOrReject(callback)) return@launch
|
|
|
|
|
+ fun setRate(rate: Float, callback: Promise) = launchInScope {
|
|
|
|
|
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
musicService.setRate(rate)
|
|
|
|
|
callback.resolve(null)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ReactMethod
|
|
|
|
|
- fun getRate(callback: Promise) = scope.launch {
|
|
|
|
|
- if (verifyServiceBoundOrReject(callback)) return@launch
|
|
|
|
|
+ fun getRate(callback: Promise) = launchInScope {
|
|
|
|
|
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
callback.resolve(musicService.getRate())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ReactMethod
|
|
|
|
|
- fun setRepeatMode(mode: Int, callback: Promise) = scope.launch {
|
|
|
|
|
- if (verifyServiceBoundOrReject(callback)) return@launch
|
|
|
|
|
+ fun setRepeatMode(mode: Int, callback: Promise) = launchInScope {
|
|
|
|
|
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
musicService.setRepeatMode(RepeatMode.fromOrdinal(mode))
|
|
|
|
|
callback.resolve(null)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ReactMethod
|
|
|
|
|
- fun getRepeatMode(callback: Promise) = scope.launch {
|
|
|
|
|
- if (verifyServiceBoundOrReject(callback)) return@launch
|
|
|
|
|
+ fun getRepeatMode(callback: Promise) = launchInScope {
|
|
|
|
|
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
callback.resolve(musicService.getRepeatMode().ordinal)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ReactMethod
|
|
|
|
|
- fun setPlayWhenReady(playWhenReady: Boolean, callback: Promise) = scope.launch {
|
|
|
|
|
- if (verifyServiceBoundOrReject(callback)) return@launch
|
|
|
|
|
+ fun setPlayWhenReady(playWhenReady: Boolean, callback: Promise) = launchInScope {
|
|
|
|
|
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
musicService.playWhenReady = playWhenReady
|
|
|
|
|
callback.resolve(null)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ReactMethod
|
|
|
|
|
- fun getPlayWhenReady(callback: Promise) = scope.launch {
|
|
|
|
|
- if (verifyServiceBoundOrReject(callback)) return@launch
|
|
|
|
|
+ fun getPlayWhenReady(callback: Promise) = launchInScope {
|
|
|
|
|
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
callback.resolve(musicService.playWhenReady)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ReactMethod
|
|
|
|
|
- fun getTrack(index: Int, callback: Promise) = scope.launch {
|
|
|
|
|
- if (verifyServiceBoundOrReject(callback)) return@launch
|
|
|
|
|
+ fun getTrack(index: Int, callback: Promise) = launchInScope {
|
|
|
|
|
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (index >= 0 && index < musicService.tracks.size) {
|
|
|
|
|
callback.resolve(Arguments.fromBundle(musicService.tracks[index].originalItem))
|
|
|
|
|
@@ -552,15 +552,15 @@ class MusicModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaM
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ReactMethod
|
|
|
|
|
- fun getQueue(callback: Promise) = scope.launch {
|
|
|
|
|
- if (verifyServiceBoundOrReject(callback)) return@launch
|
|
|
|
|
+ fun getQueue(callback: Promise) = launchInScope {
|
|
|
|
|
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
callback.resolve(Arguments.fromList(musicService.tracks.map { it.originalItem }))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ReactMethod
|
|
|
|
|
- fun setQueue(data: ReadableArray?, callback: Promise) = scope.launch {
|
|
|
|
|
- if (verifyServiceBoundOrReject(callback)) return@launch
|
|
|
|
|
+ fun setQueue(data: ReadableArray?, callback: Promise) = launchInScope {
|
|
|
|
|
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
musicService.clear()
|
|
|
|
|
@@ -572,16 +572,16 @@ class MusicModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaM
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ReactMethod
|
|
|
|
|
- fun getActiveTrackIndex(callback: Promise) = scope.launch {
|
|
|
|
|
- if (verifyServiceBoundOrReject(callback)) return@launch
|
|
|
|
|
@ -363,7 +341,7 @@ index b2409a09939164c49c0f7a16bb6d3284e8eab8fb..099caae67c52d27e451a0a5e7b11ca36
|
|
|
|
|
if (musicService.tracks.isEmpty()) null else musicService.getCurrentTrackIndex()
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ReactMethod
|
|
|
|
|
- fun getActiveTrack(callback: Promise) = scope.launch {
|
|
|
|
|
- if (verifyServiceBoundOrReject(callback)) return@launch
|
|
|
|
|
@ -374,34 +352,34 @@ index b2409a09939164c49c0f7a16bb6d3284e8eab8fb..099caae67c52d27e451a0a5e7b11ca36
|
|
|
|
|
else Arguments.fromBundle(
|
|
|
|
|
@@ -591,29 +591,29 @@ class MusicModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaM
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ReactMethod
|
|
|
|
|
- fun getDuration(callback: Promise) = scope.launch {
|
|
|
|
|
- if (verifyServiceBoundOrReject(callback)) return@launch
|
|
|
|
|
+ fun getDuration(callback: Promise) = launchInScope {
|
|
|
|
|
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
callback.resolve(musicService.getDurationInSeconds())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ReactMethod
|
|
|
|
|
- fun getBufferedPosition(callback: Promise) = scope.launch {
|
|
|
|
|
- if (verifyServiceBoundOrReject(callback)) return@launch
|
|
|
|
|
+ fun getBufferedPosition(callback: Promise) = launchInScope {
|
|
|
|
|
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
callback.resolve(musicService.getBufferedPositionInSeconds())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ReactMethod
|
|
|
|
|
- fun getPosition(callback: Promise) = scope.launch {
|
|
|
|
|
- if (verifyServiceBoundOrReject(callback)) return@launch
|
|
|
|
|
+ fun getPosition(callback: Promise) = launchInScope {
|
|
|
|
|
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
callback.resolve(musicService.getPositionInSeconds())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ReactMethod
|
|
|
|
|
- fun getProgress(callback: Promise) = scope.launch {
|
|
|
|
|
- if (verifyServiceBoundOrReject(callback)) return@launch
|
|
|
|
|
@ -412,7 +390,7 @@ index b2409a09939164c49c0f7a16bb6d3284e8eab8fb..099caae67c52d27e451a0a5e7b11ca36
|
|
|
|
|
bundle.putDouble("position", musicService.getPositionInSeconds());
|
|
|
|
|
@@ -622,8 +622,16 @@ class MusicModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaM
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ReactMethod
|
|
|
|
|
- fun getPlaybackState(callback: Promise) = scope.launch {
|
|
|
|
|
- if (verifyServiceBoundOrReject(callback)) return@launch
|
|
|
|
|
@ -429,3 +407,40 @@ index b2409a09939164c49c0f7a16bb6d3284e8eab8fb..099caae67c52d27e451a0a5e7b11ca36
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
}
|
|
|
|
|
diff --git a/android/src/main/java/com/doublesymmetry/trackplayer/service/MusicService.kt b/android/src/main/java/com/doublesymmetry/trackplayer/service/MusicService.kt
|
|
|
|
|
index 9d6d869efcece065618d4f2cefdc8c54831af9ed..1bd9bf68f158079a4625254232dd1430340364f5 100644
|
|
|
|
|
--- a/android/src/main/java/com/doublesymmetry/trackplayer/service/MusicService.kt
|
|
|
|
|
+++ b/android/src/main/java/com/doublesymmetry/trackplayer/service/MusicService.kt
|
|
|
|
|
@@ -760,8 +760,9 @@ class MusicService : HeadlessJsTaskService() {
|
|
|
|
|
return HeadlessJsTaskConfig(TASK_KEY, Arguments.createMap(), 0, true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // https://github.com/doublesymmetry/react-native-track-player/pull/2451
|
|
|
|
|
@MainThread
|
|
|
|
|
- override fun onBind(intent: Intent?): IBinder {
|
|
|
|
|
+ override fun onBind(intent: Intent): IBinder {
|
|
|
|
|
return binder
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
diff --git a/ios/RNTrackPlayer/RNTrackPlayerBridge.m b/ios/RNTrackPlayer/RNTrackPlayerBridge.m
|
|
|
|
|
index 7741994191921ed86f7577f7ce589b3939d9dd49..776c09ec0ae450daa4dc9031ccd3ff4baba016d3 100644
|
|
|
|
|
--- a/ios/RNTrackPlayer/RNTrackPlayerBridge.m
|
|
|
|
|
+++ b/ios/RNTrackPlayer/RNTrackPlayerBridge.m
|
|
|
|
|
@@ -151,17 +151,4 @@ RCT_EXTERN_METHOD(updateNowPlayingMetadata:(NSDictionary *)metadata
|
|
|
|
|
resolver:(RCTPromiseResolveBlock)resolve
|
|
|
|
|
rejecter:(RCTPromiseRejectBlock)reject);
|
|
|
|
|
|
|
|
|
|
-RCT_EXTERN_METHOD(getSleepTimerProgress:(RCTPromiseResolveBlock)resolve
|
|
|
|
|
- rejecter:(RCTPromiseRejectBlock)reject);
|
|
|
|
|
-
|
|
|
|
|
-RCT_EXTERN_METHOD(setSleepTimer:(double)time
|
|
|
|
|
- resolver:(RCTPromiseResolveBlock)resolve
|
|
|
|
|
- rejecter:(RCTPromiseRejectBlock)reject);
|
|
|
|
|
-
|
|
|
|
|
-RCT_EXTERN_METHOD(sleepWhenActiveTrackReachesEnd:(RCTPromiseResolveBlock)resolve
|
|
|
|
|
- rejecter:(RCTPromiseRejectBlock)reject);
|
|
|
|
|
-
|
|
|
|
|
-RCT_EXTERN_METHOD(clearSleepTimer:(RCTPromiseResolveBlock)resolve
|
|
|
|
|
- rejecter:(RCTPromiseRejectBlock)reject);
|
|
|
|
|
-
|
|
|
|
|
@end
|
|
|
|
|
|