add setting for widget scrubbing

This commit is contained in:
fidoriel 2024-02-20 21:58:31 +01:00
parent 57d5dbc0d0
commit 41a65c0f9d
8 changed files with 33 additions and 10 deletions

View file

@ -107,6 +107,7 @@ data class PlayItemRequestPayload(
data class DeviceSettings( data class DeviceSettings(
var disableAutoRewind:Boolean, var disableAutoRewind:Boolean,
var enableAltView:Boolean, var enableAltView:Boolean,
var allowSeekingOnWidget:Boolean,
var jumpBackwardsTime:Int, var jumpBackwardsTime:Int,
var jumpForwardTime:Int, var jumpForwardTime:Int,
var enableMp3IndexSeeking:Boolean, var enableMp3IndexSeeking:Boolean,
@ -130,6 +131,7 @@ data class DeviceSettings(
return DeviceSettings( return DeviceSettings(
disableAutoRewind = false, disableAutoRewind = false,
enableAltView = true, enableAltView = true,
allowSeekingOnWidget = false,
jumpBackwardsTime = 10, jumpBackwardsTime = 10,
jumpForwardTime = 10, jumpForwardTime = 10,
enableMp3IndexSeeking = false, enableMp3IndexSeeking = false,

View file

@ -329,15 +329,18 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
} }
} }
mediaSessionConnector.setEnabledPlaybackActions( val playbackActions = PlaybackStateCompat.ACTION_PLAY_PAUSE or
PlaybackStateCompat.ACTION_PLAY_PAUSE PlaybackStateCompat.ACTION_PLAY or
or PlaybackStateCompat.ACTION_PLAY PlaybackStateCompat.ACTION_PAUSE or
or PlaybackStateCompat.ACTION_PAUSE PlaybackStateCompat.ACTION_FAST_FORWARD or
or PlaybackStateCompat.ACTION_SEEK_TO PlaybackStateCompat.ACTION_REWIND or
or PlaybackStateCompat.ACTION_FAST_FORWARD PlaybackStateCompat.ACTION_STOP
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))

View file

@ -238,6 +238,7 @@ public class AbsDatabase: CAPPlugin {
@objc func updateDeviceSettings(_ call: CAPPluginCall) { @objc func updateDeviceSettings(_ call: CAPPluginCall) {
let disableAutoRewind = call.getBool("disableAutoRewind") ?? false let disableAutoRewind = call.getBool("disableAutoRewind") ?? false
let enableAltView = call.getBool("enableAltView") ?? false let enableAltView = call.getBool("enableAltView") ?? false
let allowSeekingOnWidget = call.getBool("allowSeekingOnWidget") ?? false
let jumpBackwardsTime = call.getInt("jumpBackwardsTime") ?? 10 let jumpBackwardsTime = call.getInt("jumpBackwardsTime") ?? 10
let jumpForwardTime = call.getInt("jumpForwardTime") ?? 10 let jumpForwardTime = call.getInt("jumpForwardTime") ?? 10
let lockOrientation = call.getString("lockOrientation") ?? "NONE" let lockOrientation = call.getString("lockOrientation") ?? "NONE"
@ -246,6 +247,7 @@ public class AbsDatabase: CAPPlugin {
let settings = DeviceSettings() let settings = DeviceSettings()
settings.disableAutoRewind = disableAutoRewind settings.disableAutoRewind = disableAutoRewind
settings.enableAltView = enableAltView settings.enableAltView = enableAltView
settings.allowSeekingOnWidget = allowSeekingOnWidget
settings.jumpBackwardsTime = jumpBackwardsTime settings.jumpBackwardsTime = jumpBackwardsTime
settings.jumpForwardTime = jumpForwardTime settings.jumpForwardTime = jumpForwardTime
settings.lockOrientation = lockOrientation settings.lockOrientation = lockOrientation

View file

@ -11,6 +11,7 @@ import RealmSwift
class DeviceSettings: Object { class DeviceSettings: Object {
@Persisted var disableAutoRewind: Bool = false @Persisted var disableAutoRewind: Bool = false
@Persisted var enableAltView: Bool = true @Persisted var enableAltView: Bool = true
@Persisted var allowSeekingOnWidget: Bool = true
@Persisted var jumpBackwardsTime: Int = 10 @Persisted var jumpBackwardsTime: Int = 10
@Persisted var jumpForwardTime: Int = 10 @Persisted var jumpForwardTime: Int = 10
@Persisted var lockOrientation: String = "NONE" @Persisted var lockOrientation: String = "NONE"
@ -26,6 +27,7 @@ func deviceSettingsToJSON(settings: DeviceSettings) -> Dictionary<String, Any> {
return [ return [
"disableAutoRewind": settings.disableAutoRewind, "disableAutoRewind": settings.disableAutoRewind,
"enableAltView": settings.enableAltView, "enableAltView": settings.enableAltView,
"allowSeekingOnWidget": settings.allowSeekingOnWidget,
"jumpBackwardsTime": settings.jumpBackwardsTime, "jumpBackwardsTime": settings.jumpBackwardsTime,
"jumpForwardTime": settings.jumpForwardTime, "jumpForwardTime": settings.jumpForwardTime,
"lockOrientation": settings.lockOrientation, "lockOrientation": settings.lockOrientation,

View file

@ -672,7 +672,7 @@ class AudioPlayer: NSObject {
return .success return .success
} }
commandCenter.changePlaybackPositionCommand.isEnabled = true commandCenter.changePlaybackPositionCommand.isEnabled = deviceSettings.allowSeekingOnWidget
commandCenter.changePlaybackPositionCommand.addTarget { [weak self] event in commandCenter.changePlaybackPositionCommand.addTarget { [weak self] event in
guard let event = event as? MPChangePlaybackPositionCommandEvent else { guard let event = event as? MPChangePlaybackPositionCommandEvent else {
return .noSuchContent return .noSuchContent

View file

@ -8,6 +8,12 @@
</div> </div>
<p class="pl-4">{{ $strings.LabelUseBookshelfView }}</p> <p class="pl-4">{{ $strings.LabelUseBookshelfView }}</p>
</div> </div>
<div class="flex items-center py-3">
<div class="w-10 flex justify-center" @click="toggleAllowSeekingOnWidget">
<ui-toggle-switch v-model="settings.allowSeekingOnWidget" @input="saveSettings" />
</div>
<p class="pl-4">{{ $strings.LabelAllowSeekingOnWidget }}</p>
</div>
<!-- screen.orientation.lock not supported on iOS webview --> <!-- screen.orientation.lock not supported on iOS webview -->
<div v-if="!isiOS" class="flex items-center py-3"> <div v-if="!isiOS" class="flex items-center py-3">
<div class="w-10 flex justify-center" @click.stop="toggleLockOrientation"> <div class="w-10 flex justify-center" @click.stop="toggleLockOrientation">
@ -154,6 +160,7 @@ export default {
settings: { settings: {
disableAutoRewind: false, disableAutoRewind: false,
enableAltView: true, enableAltView: true,
allowSeekingOnWidget: false,
jumpForwardTime: 10, jumpForwardTime: 10,
jumpBackwardsTime: 10, jumpBackwardsTime: 10,
enableMp3IndexSeeking: false, enableMp3IndexSeeking: false,
@ -429,6 +436,10 @@ export default {
this.settings.enableAltView = !this.settings.enableAltView this.settings.enableAltView = !this.settings.enableAltView
this.saveSettings() this.saveSettings()
}, },
toggleAllowSeekingOnWidget() {
this.settings.allowSeekingOnWidget = !this.settings.allowSeekingOnWidget
this.saveSettings()
},
getCurrentOrientation() { getCurrentOrientation() {
const orientation = window.screen?.orientation || {} const orientation = window.screen?.orientation || {}
const type = orientation.type || '' const type = orientation.type || ''
@ -471,6 +482,7 @@ export default {
const deviceSettings = this.deviceData.deviceSettings || {} const deviceSettings = this.deviceData.deviceSettings || {}
this.settings.disableAutoRewind = !!deviceSettings.disableAutoRewind this.settings.disableAutoRewind = !!deviceSettings.disableAutoRewind
this.settings.enableAltView = !!deviceSettings.enableAltView this.settings.enableAltView = !!deviceSettings.enableAltView
this.settings.allowSeekingOnWidget = !!deviceSettings.allowSeekingOnWidget
this.settings.jumpForwardTime = deviceSettings.jumpForwardTime || 10 this.settings.jumpForwardTime = deviceSettings.jumpForwardTime || 10
this.settings.jumpBackwardsTime = deviceSettings.jumpBackwardsTime || 10 this.settings.jumpBackwardsTime = deviceSettings.jumpBackwardsTime || 10
this.settings.enableMp3IndexSeeking = !!deviceSettings.enableMp3IndexSeeking this.settings.enableMp3IndexSeeking = !!deviceSettings.enableMp3IndexSeeking

View file

@ -228,6 +228,7 @@
"LabelType": "Typ", "LabelType": "Typ",
"LabelUnlockPlayer": "Mediaplayer entsperren", "LabelUnlockPlayer": "Mediaplayer entsperren",
"LabelUseBookshelfView": "Benutze Bücherregalansicht", "LabelUseBookshelfView": "Benutze Bücherregalansicht",
"LabelAllowSeekingOnWidget": "Erlaube Vor- oder Zurückspulen auf dem 'Jetzt Läuft' Widget",
"LabelUser": "Benutzer", "LabelUser": "Benutzer",
"LabelUsername": "Benutzername", "LabelUsername": "Benutzername",
"LabelVeryHigh": "Sehr hoch", "LabelVeryHigh": "Sehr hoch",

View file

@ -228,6 +228,7 @@
"LabelType": "Type", "LabelType": "Type",
"LabelUnlockPlayer": "Unlock Player", "LabelUnlockPlayer": "Unlock Player",
"LabelUseBookshelfView": "Use bookshelf view", "LabelUseBookshelfView": "Use bookshelf view",
"LabelAllowSeekingOnWidget": "Allow position seeking on the 'Now Playing' widget",
"LabelUser": "User", "LabelUser": "User",
"LabelUsername": "Username", "LabelUsername": "Username",
"LabelVeryHigh": "Very High", "LabelVeryHigh": "Very High",