mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-08-29 14:28:34 +02:00
Update android disable media control seek setting to update in realtime
This commit is contained in:
parent
7be82d03f3
commit
430d200151
3 changed files with 28 additions and 13 deletions
|
@ -103,6 +103,9 @@ class MainActivity : BridgeActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun isPlayerNotificationServiceInitialized():Boolean {
|
||||||
|
return ::foregroundService.isInitialized
|
||||||
|
}
|
||||||
|
|
||||||
fun stopMyService() {
|
fun stopMyService() {
|
||||||
if (mBounded) {
|
if (mBounded) {
|
||||||
|
|
|
@ -329,18 +329,7 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var playbackActions = PlaybackStateCompat.ACTION_PLAY_PAUSE or
|
setMediaSessionConnectorPlaybackActions()
|
||||||
PlaybackStateCompat.ACTION_PLAY or
|
|
||||||
PlaybackStateCompat.ACTION_PAUSE or
|
|
||||||
PlaybackStateCompat.ACTION_FAST_FORWARD or
|
|
||||||
PlaybackStateCompat.ACTION_REWIND or
|
|
||||||
PlaybackStateCompat.ACTION_STOP
|
|
||||||
|
|
||||||
if (deviceSettings.allowSeekingOnWidget) {
|
|
||||||
playbackActions = playbackActions or PlaybackStateCompat.ACTION_SEEK_TO
|
|
||||||
}
|
|
||||||
|
|
||||||
mediaSessionConnector.setEnabledPlaybackActions(playbackActions)
|
|
||||||
mediaSessionConnector.setQueueNavigator(queueNavigator)
|
mediaSessionConnector.setQueueNavigator(queueNavigator)
|
||||||
mediaSessionConnector.setPlaybackPreparer(MediaSessionPlaybackPreparer(this))
|
mediaSessionConnector.setPlaybackPreparer(MediaSessionPlaybackPreparer(this))
|
||||||
|
|
||||||
|
@ -515,6 +504,20 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
|
||||||
mediaSessionConnector.setCustomActionProviders(*customActionProviders.toTypedArray())
|
mediaSessionConnector.setCustomActionProviders(*customActionProviders.toTypedArray())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setMediaSessionConnectorPlaybackActions() {
|
||||||
|
var playbackActions = PlaybackStateCompat.ACTION_PLAY_PAUSE or
|
||||||
|
PlaybackStateCompat.ACTION_PLAY or
|
||||||
|
PlaybackStateCompat.ACTION_PAUSE or
|
||||||
|
PlaybackStateCompat.ACTION_FAST_FORWARD or
|
||||||
|
PlaybackStateCompat.ACTION_REWIND or
|
||||||
|
PlaybackStateCompat.ACTION_STOP
|
||||||
|
|
||||||
|
if (deviceSettings.allowSeekingOnWidget) {
|
||||||
|
playbackActions = playbackActions or PlaybackStateCompat.ACTION_SEEK_TO
|
||||||
|
}
|
||||||
|
mediaSessionConnector.setEnabledPlaybackActions(playbackActions)
|
||||||
|
}
|
||||||
|
|
||||||
fun handlePlayerPlaybackError(errorMessage:String) {
|
fun handlePlayerPlaybackError(errorMessage:String) {
|
||||||
// On error and was attempting to direct play - fallback to transcode
|
// On error and was attempting to direct play - fallback to transcode
|
||||||
currentPlaybackSession?.let { playbackSession ->
|
currentPlaybackSession?.let { playbackSession ->
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.audiobookshelf.app.plugins
|
package com.audiobookshelf.app.plugins
|
||||||
|
|
||||||
|
import android.os.Handler
|
||||||
|
import android.os.Looper
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import com.audiobookshelf.app.MainActivity
|
import com.audiobookshelf.app.MainActivity
|
||||||
import com.audiobookshelf.app.data.*
|
import com.audiobookshelf.app.data.*
|
||||||
|
@ -493,9 +495,16 @@ class AbsDatabase : Plugin() {
|
||||||
fun updateDeviceSettings(call:PluginCall) { // Returns device data
|
fun updateDeviceSettings(call:PluginCall) { // Returns device data
|
||||||
Log.d(tag, "updateDeviceSettings ${call.data}")
|
Log.d(tag, "updateDeviceSettings ${call.data}")
|
||||||
val newDeviceSettings = jacksonMapper.readValue<DeviceSettings>(call.data.toString())
|
val newDeviceSettings = jacksonMapper.readValue<DeviceSettings>(call.data.toString())
|
||||||
GlobalScope.launch(Dispatchers.IO) {
|
|
||||||
|
Handler(Looper.getMainLooper()).post {
|
||||||
DeviceManager.deviceData.deviceSettings = newDeviceSettings
|
DeviceManager.deviceData.deviceSettings = newDeviceSettings
|
||||||
DeviceManager.dbManager.saveDeviceData(DeviceManager.deviceData)
|
DeviceManager.dbManager.saveDeviceData(DeviceManager.deviceData)
|
||||||
|
|
||||||
|
// Updates playback actions for media notification (handles media control seek locking setting)
|
||||||
|
if (mainActivity.isPlayerNotificationServiceInitialized()) {
|
||||||
|
mainActivity.foregroundService.setMediaSessionConnectorPlaybackActions()
|
||||||
|
}
|
||||||
|
|
||||||
call.resolve(JSObject(jacksonMapper.writeValueAsString(DeviceManager.deviceData)))
|
call.resolve(JSObject(jacksonMapper.writeValueAsString(DeviceManager.deviceData)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue