@5stones/react-native-audio-browser 0.1.2 → 0.1.4
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.
|
@@ -3,7 +3,6 @@ package com.audiobrowser.player
|
|
|
3
3
|
import androidx.media3.common.C
|
|
4
4
|
import androidx.media3.exoplayer.DefaultLoadControl
|
|
5
5
|
import androidx.media3.exoplayer.LoadControl
|
|
6
|
-
import androidx.media3.exoplayer.analytics.PlayerId
|
|
7
6
|
import androidx.media3.exoplayer.source.TrackGroupArray
|
|
8
7
|
import androidx.media3.exoplayer.trackselection.ExoTrackSelection
|
|
9
8
|
import androidx.media3.exoplayer.upstream.Allocator
|
|
@@ -98,11 +97,11 @@ class DynamicLoadControl(initialConfig: BufferConfig = BufferConfig()) : LoadCon
|
|
|
98
97
|
updateBufferConfig(BufferConfig())
|
|
99
98
|
}
|
|
100
99
|
|
|
101
|
-
override fun getAllocator(
|
|
100
|
+
override fun getAllocator(): Allocator = allocator
|
|
102
101
|
|
|
103
|
-
override fun getBackBufferDurationUs(
|
|
102
|
+
override fun getBackBufferDurationUs(): Long = backBufferUs
|
|
104
103
|
|
|
105
|
-
override fun retainBackBufferFromKeyframe(
|
|
104
|
+
override fun retainBackBufferFromKeyframe(): Boolean = false
|
|
106
105
|
|
|
107
106
|
override fun shouldContinueLoading(parameters: LoadControl.Parameters): Boolean {
|
|
108
107
|
return parameters.bufferedDurationUs < maxBufferUs
|
|
@@ -138,7 +137,7 @@ class DynamicLoadControl(initialConfig: BufferConfig = BufferConfig()) : LoadCon
|
|
|
138
137
|
}
|
|
139
138
|
}
|
|
140
139
|
|
|
141
|
-
override fun onPrepared(
|
|
140
|
+
override fun onPrepared() {
|
|
142
141
|
allocator.reset()
|
|
143
142
|
prepareStartTimeMs = System.currentTimeMillis()
|
|
144
143
|
playbackStarted = false
|
|
@@ -152,11 +151,11 @@ class DynamicLoadControl(initialConfig: BufferConfig = BufferConfig()) : LoadCon
|
|
|
152
151
|
// Required by LoadControl interface - buffer config is managed via updateBufferConfig()
|
|
153
152
|
}
|
|
154
153
|
|
|
155
|
-
override fun onStopped(
|
|
154
|
+
override fun onStopped() {
|
|
156
155
|
// Required by LoadControl interface
|
|
157
156
|
}
|
|
158
157
|
|
|
159
|
-
override fun onReleased(
|
|
158
|
+
override fun onReleased() {
|
|
160
159
|
// Reset allocator when released
|
|
161
160
|
allocator.reset()
|
|
162
161
|
}
|
|
@@ -521,20 +521,14 @@ class MediaSessionCallback(private val player: Player) :
|
|
|
521
521
|
override fun onPlaybackResumption(
|
|
522
522
|
mediaSession: MediaSession,
|
|
523
523
|
controller: MediaSession.ControllerInfo,
|
|
524
|
-
playback: Boolean,
|
|
525
524
|
): ListenableFuture<MediaSession.MediaItemsWithStartPosition> {
|
|
526
|
-
Timber.d("${controller.packageName}
|
|
525
|
+
Timber.d("${controller.packageName}")
|
|
527
526
|
|
|
528
527
|
return scope.future {
|
|
529
|
-
//
|
|
530
|
-
// When playback=false, system is just gathering info for UI (e.g., boot-time notification)
|
|
528
|
+
// Restore player settings and persisted state
|
|
531
529
|
val state =
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
withContext(Dispatchers.Main) { player.playbackStateStore.restore() }
|
|
535
|
-
} else {
|
|
536
|
-
player.playbackStateStore.get()
|
|
537
|
-
}
|
|
530
|
+
// restore() sets player properties which must happen on main thread
|
|
531
|
+
withContext(Dispatchers.Main) { player.playbackStateStore.restore() }
|
|
538
532
|
?: run {
|
|
539
533
|
Timber.w("No persisted playback state found")
|
|
540
534
|
throw IllegalStateException("No playback state to resume")
|
|
@@ -545,11 +545,18 @@ public class HybridAudioBrowser: HybridAudioBrowserSpec, @unchecked Sendable {
|
|
|
545
545
|
|
|
546
546
|
public func updateOptions(options: NativeUpdateOptions) {
|
|
547
547
|
onMainActor {
|
|
548
|
+
let previousInterval = playerOptions.progressUpdateEventInterval
|
|
549
|
+
|
|
548
550
|
// Update stored options
|
|
549
551
|
playerOptions.update(from: options)
|
|
550
552
|
|
|
551
553
|
// Apply remote commands to player
|
|
552
554
|
applyRemoteCommands()
|
|
555
|
+
|
|
556
|
+
// Apply progress update interval if changed
|
|
557
|
+
if playerOptions.progressUpdateEventInterval != previousInterval {
|
|
558
|
+
player?.setProgressUpdateInterval(playerOptions.progressUpdateEventInterval)
|
|
559
|
+
}
|
|
553
560
|
}
|
|
554
561
|
}
|
|
555
562
|
|