mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2026-08-07 20:38:43 +02:00
Merge pull request #1094 from fidoriel/disable-widget-ios-scrubing
Disable ios/android scrubbing in MPRemoteCommandCenter/MediaBrowserServiceCompat
This commit is contained in:
@@ -103,6 +103,9 @@ class MainActivity : BridgeActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
fun isPlayerNotificationServiceInitialized():Boolean {
|
||||
return ::foregroundService.isInitialized
|
||||
}
|
||||
|
||||
fun stopMyService() {
|
||||
if (mBounded) {
|
||||
|
||||
@@ -107,6 +107,7 @@ data class PlayItemRequestPayload(
|
||||
data class DeviceSettings(
|
||||
var disableAutoRewind:Boolean,
|
||||
var enableAltView:Boolean,
|
||||
var allowSeekingOnMediaControls:Boolean,
|
||||
var jumpBackwardsTime:Int,
|
||||
var jumpForwardTime:Int,
|
||||
var enableMp3IndexSeeking:Boolean,
|
||||
@@ -130,6 +131,7 @@ data class DeviceSettings(
|
||||
return DeviceSettings(
|
||||
disableAutoRewind = false,
|
||||
enableAltView = true,
|
||||
allowSeekingOnMediaControls = false,
|
||||
jumpBackwardsTime = 10,
|
||||
jumpForwardTime = 10,
|
||||
enableMp3IndexSeeking = false,
|
||||
|
||||
+15
-9
@@ -329,15 +329,7 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
|
||||
}
|
||||
}
|
||||
|
||||
mediaSessionConnector.setEnabledPlaybackActions(
|
||||
PlaybackStateCompat.ACTION_PLAY_PAUSE
|
||||
or PlaybackStateCompat.ACTION_PLAY
|
||||
or PlaybackStateCompat.ACTION_PAUSE
|
||||
or PlaybackStateCompat.ACTION_SEEK_TO
|
||||
or PlaybackStateCompat.ACTION_FAST_FORWARD
|
||||
or PlaybackStateCompat.ACTION_REWIND
|
||||
or PlaybackStateCompat.ACTION_STOP
|
||||
)
|
||||
setMediaSessionConnectorPlaybackActions()
|
||||
mediaSessionConnector.setQueueNavigator(queueNavigator)
|
||||
mediaSessionConnector.setPlaybackPreparer(MediaSessionPlaybackPreparer(this))
|
||||
|
||||
@@ -512,6 +504,20 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
|
||||
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.allowSeekingOnMediaControls) {
|
||||
playbackActions = playbackActions or PlaybackStateCompat.ACTION_SEEK_TO
|
||||
}
|
||||
mediaSessionConnector.setEnabledPlaybackActions(playbackActions)
|
||||
}
|
||||
|
||||
fun handlePlayerPlaybackError(errorMessage:String) {
|
||||
// On error and was attempting to direct play - fallback to transcode
|
||||
currentPlaybackSession?.let { playbackSession ->
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.audiobookshelf.app.plugins
|
||||
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.util.Log
|
||||
import com.audiobookshelf.app.MainActivity
|
||||
import com.audiobookshelf.app.data.*
|
||||
@@ -493,9 +495,16 @@ class AbsDatabase : Plugin() {
|
||||
fun updateDeviceSettings(call:PluginCall) { // Returns device data
|
||||
Log.d(tag, "updateDeviceSettings ${call.data}")
|
||||
val newDeviceSettings = jacksonMapper.readValue<DeviceSettings>(call.data.toString())
|
||||
GlobalScope.launch(Dispatchers.IO) {
|
||||
|
||||
Handler(Looper.getMainLooper()).post {
|
||||
DeviceManager.deviceData.deviceSettings = newDeviceSettings
|
||||
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)))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
// Override point for customization after application launch.
|
||||
|
||||
let configuration = Realm.Configuration(
|
||||
schemaVersion: 16,
|
||||
schemaVersion: 17,
|
||||
migrationBlock: { [weak self] migration, oldSchemaVersion in
|
||||
if (oldSchemaVersion < 1) {
|
||||
self?.logger.log("Realm schema version was \(oldSchemaVersion)")
|
||||
|
||||
@@ -238,6 +238,7 @@ public class AbsDatabase: CAPPlugin {
|
||||
@objc func updateDeviceSettings(_ call: CAPPluginCall) {
|
||||
let disableAutoRewind = call.getBool("disableAutoRewind") ?? false
|
||||
let enableAltView = call.getBool("enableAltView") ?? false
|
||||
let allowSeekingOnMediaControls = call.getBool("allowSeekingOnMediaControls") ?? false
|
||||
let jumpBackwardsTime = call.getInt("jumpBackwardsTime") ?? 10
|
||||
let jumpForwardTime = call.getInt("jumpForwardTime") ?? 10
|
||||
let lockOrientation = call.getString("lockOrientation") ?? "NONE"
|
||||
@@ -246,6 +247,7 @@ public class AbsDatabase: CAPPlugin {
|
||||
let settings = DeviceSettings()
|
||||
settings.disableAutoRewind = disableAutoRewind
|
||||
settings.enableAltView = enableAltView
|
||||
settings.allowSeekingOnMediaControls = allowSeekingOnMediaControls
|
||||
settings.jumpBackwardsTime = jumpBackwardsTime
|
||||
settings.jumpForwardTime = jumpForwardTime
|
||||
settings.lockOrientation = lockOrientation
|
||||
@@ -254,7 +256,9 @@ public class AbsDatabase: CAPPlugin {
|
||||
|
||||
Database.shared.setDeviceSettings(deviceSettings: settings)
|
||||
|
||||
// call.resolve([ "value": [] ])
|
||||
// Updates the media notification controls (for allowSeekingOnMediaControls setting)
|
||||
PlayerHandler.updateRemoteTransportControls()
|
||||
|
||||
getDeviceData(call)
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import RealmSwift
|
||||
class DeviceSettings: Object {
|
||||
@Persisted var disableAutoRewind: Bool = false
|
||||
@Persisted var enableAltView: Bool = true
|
||||
@Persisted var allowSeekingOnMediaControls: Bool = false
|
||||
@Persisted var jumpBackwardsTime: Int = 10
|
||||
@Persisted var jumpForwardTime: Int = 10
|
||||
@Persisted var lockOrientation: String = "NONE"
|
||||
@@ -26,6 +27,7 @@ func deviceSettingsToJSON(settings: DeviceSettings) -> Dictionary<String, Any> {
|
||||
return [
|
||||
"disableAutoRewind": settings.disableAutoRewind,
|
||||
"enableAltView": settings.enableAltView,
|
||||
"allowSeekingOnMediaControls": settings.allowSeekingOnMediaControls,
|
||||
"jumpBackwardsTime": settings.jumpBackwardsTime,
|
||||
"jumpForwardTime": settings.jumpForwardTime,
|
||||
"lockOrientation": settings.lockOrientation,
|
||||
|
||||
@@ -588,7 +588,7 @@ class AudioPlayer: NSObject {
|
||||
}
|
||||
|
||||
// MARK: - Now playing
|
||||
private func setupRemoteTransportControls() {
|
||||
func setupRemoteTransportControls() {
|
||||
DispatchQueue.runOnMainQueue {
|
||||
UIApplication.shared.beginReceivingRemoteControlEvents()
|
||||
}
|
||||
@@ -672,7 +672,7 @@ class AudioPlayer: NSObject {
|
||||
return .success
|
||||
}
|
||||
|
||||
commandCenter.changePlaybackPositionCommand.isEnabled = true
|
||||
commandCenter.changePlaybackPositionCommand.isEnabled = deviceSettings.allowSeekingOnMediaControls
|
||||
commandCenter.changePlaybackPositionCommand.addTarget { [weak self] event in
|
||||
guard let event = event as? MPChangePlaybackPositionCommandEvent else {
|
||||
return .noSuchContent
|
||||
|
||||
@@ -135,6 +135,10 @@ class PlayerHandler {
|
||||
)
|
||||
}
|
||||
|
||||
public static func updateRemoteTransportControls() {
|
||||
self.player?.setupRemoteTransportControls()
|
||||
}
|
||||
|
||||
// MARK: - Helper logic
|
||||
|
||||
private static func cleanupOldSessions(currentSessionId: String?) {
|
||||
|
||||
@@ -61,6 +61,12 @@
|
||||
<p class="pl-4">{{ $strings.LabelEnableMp3IndexSeeking }}</p>
|
||||
<span class="material-icons-outlined ml-2" @click.stop="showConfirmMp3IndexSeeking">info</span>
|
||||
</div>
|
||||
<div class="flex items-center py-3">
|
||||
<div class="w-10 flex justify-center" @click="toggleAllowSeekingOnMediaControls">
|
||||
<ui-toggle-switch v-model="settings.allowSeekingOnMediaControls" @input="saveSettings" />
|
||||
</div>
|
||||
<p class="pl-4">{{ $strings.LabelAllowSeekingOnMediaControls }}</p>
|
||||
</div>
|
||||
|
||||
<!-- Sleep timer settings -->
|
||||
<template v-if="!isiOS">
|
||||
@@ -154,6 +160,7 @@ export default {
|
||||
settings: {
|
||||
disableAutoRewind: false,
|
||||
enableAltView: true,
|
||||
allowSeekingOnMediaControls: false,
|
||||
jumpForwardTime: 10,
|
||||
jumpBackwardsTime: 10,
|
||||
enableMp3IndexSeeking: false,
|
||||
@@ -429,6 +436,10 @@ export default {
|
||||
this.settings.enableAltView = !this.settings.enableAltView
|
||||
this.saveSettings()
|
||||
},
|
||||
toggleAllowSeekingOnMediaControls() {
|
||||
this.settings.allowSeekingOnMediaControls = !this.settings.allowSeekingOnMediaControls
|
||||
this.saveSettings()
|
||||
},
|
||||
getCurrentOrientation() {
|
||||
const orientation = window.screen?.orientation || {}
|
||||
const type = orientation.type || ''
|
||||
@@ -471,6 +482,7 @@ export default {
|
||||
const deviceSettings = this.deviceData.deviceSettings || {}
|
||||
this.settings.disableAutoRewind = !!deviceSettings.disableAutoRewind
|
||||
this.settings.enableAltView = !!deviceSettings.enableAltView
|
||||
this.settings.allowSeekingOnMediaControls = !!deviceSettings.allowSeekingOnMediaControls
|
||||
this.settings.jumpForwardTime = deviceSettings.jumpForwardTime || 10
|
||||
this.settings.jumpBackwardsTime = deviceSettings.jumpBackwardsTime || 10
|
||||
this.settings.enableMp3IndexSeeking = !!deviceSettings.enableMp3IndexSeeking
|
||||
|
||||
+2
-1
@@ -85,6 +85,7 @@
|
||||
"LabelAddedAt": "Přidáno v",
|
||||
"LabelAddToPlaylist": "Přidat do seznamu skladeb",
|
||||
"LabelAll": "Vše",
|
||||
"LabelAllowSeekingOnMediaControls": "Allow position seeking on media notification controls",
|
||||
"LabelAuthor": "Autor",
|
||||
"LabelAuthorFirstLast": "Autor (jméno a příjmení)",
|
||||
"LabelAuthorLastFirst": "Autor (příjmení a jméno)",
|
||||
@@ -289,4 +290,4 @@
|
||||
"ToastPodcastCreateSuccess": "Podcast byl úspěšně vytvořen",
|
||||
"ToastRSSFeedCloseFailed": "Nepodařilo se zavřít RSS kanál",
|
||||
"ToastRSSFeedCloseSuccess": "RSS kanál uzavřen"
|
||||
}
|
||||
}
|
||||
@@ -85,6 +85,7 @@
|
||||
"LabelAddedAt": "Tilføjet Kl.",
|
||||
"LabelAddToPlaylist": "Tilføj til Afspilningsliste",
|
||||
"LabelAll": "Alle",
|
||||
"LabelAllowSeekingOnMediaControls": "Allow position seeking on media notification controls",
|
||||
"LabelAuthor": "Forfatter",
|
||||
"LabelAuthorFirstLast": "Forfatter (Fornavn Efternavn)",
|
||||
"LabelAuthorLastFirst": "Forfatter (Efternavn, Fornavn)",
|
||||
|
||||
@@ -85,6 +85,7 @@
|
||||
"LabelAddedAt": "Hinzugefügt am",
|
||||
"LabelAddToPlaylist": "Zur Wiedergabeliste hinzufügen",
|
||||
"LabelAll": "Alle",
|
||||
"LabelAllowSeekingOnMediaControls": "Erlaube Vor- und Zurückspulen auf dem Medienkontrollelement bei den Benachrichtigungen",
|
||||
"LabelAuthor": "Autor",
|
||||
"LabelAuthorFirstLast": "Autor (Vorname Nachname)",
|
||||
"LabelAuthorLastFirst": "Autor (Nachname, Vorname)",
|
||||
|
||||
@@ -85,6 +85,7 @@
|
||||
"LabelAddedAt": "Added At",
|
||||
"LabelAddToPlaylist": "Add to Playlist",
|
||||
"LabelAll": "All",
|
||||
"LabelAllowSeekingOnMediaControls": "Allow position seeking on media notification controls",
|
||||
"LabelAuthor": "Author",
|
||||
"LabelAuthorFirstLast": "Author (First Last)",
|
||||
"LabelAuthorLastFirst": "Author (Last, First)",
|
||||
|
||||
@@ -85,6 +85,7 @@
|
||||
"LabelAddedAt": "Añadido",
|
||||
"LabelAddToPlaylist": "Añadido a la Lista de Reproducción",
|
||||
"LabelAll": "Todos",
|
||||
"LabelAllowSeekingOnMediaControls": "Allow position seeking on media notification controls",
|
||||
"LabelAuthor": "Autor",
|
||||
"LabelAuthorFirstLast": "Autor (Nombre Apellido)",
|
||||
"LabelAuthorLastFirst": "Autor (Apellido, Nombre)",
|
||||
|
||||
@@ -85,6 +85,7 @@
|
||||
"LabelAddedAt": "Date d’ajout",
|
||||
"LabelAddToPlaylist": "Ajouter à la liste de lecture",
|
||||
"LabelAll": "Tout",
|
||||
"LabelAllowSeekingOnMediaControls": "Allow position seeking on media notification controls",
|
||||
"LabelAuthor": "Auteur",
|
||||
"LabelAuthorFirstLast": "Auteur (Prénom Nom)",
|
||||
"LabelAuthorLastFirst": "Auteur (Nom, Prénom)",
|
||||
|
||||
@@ -85,6 +85,7 @@
|
||||
"LabelAddedAt": "Added At",
|
||||
"LabelAddToPlaylist": "Add to Playlist",
|
||||
"LabelAll": "All",
|
||||
"LabelAllowSeekingOnMediaControls": "Allow position seeking on media notification controls",
|
||||
"LabelAuthor": "Author",
|
||||
"LabelAuthorFirstLast": "Author (First Last)",
|
||||
"LabelAuthorLastFirst": "Author (Last, First)",
|
||||
|
||||
@@ -85,6 +85,7 @@
|
||||
"LabelAddedAt": "Added At",
|
||||
"LabelAddToPlaylist": "Add to Playlist",
|
||||
"LabelAll": "All",
|
||||
"LabelAllowSeekingOnMediaControls": "Allow position seeking on media notification controls",
|
||||
"LabelAuthor": "Author",
|
||||
"LabelAuthorFirstLast": "Author (First Last)",
|
||||
"LabelAuthorLastFirst": "Author (Last, First)",
|
||||
|
||||
@@ -85,6 +85,7 @@
|
||||
"LabelAddedAt": "Added At",
|
||||
"LabelAddToPlaylist": "Add to Playlist",
|
||||
"LabelAll": "All",
|
||||
"LabelAllowSeekingOnMediaControls": "Allow position seeking on media notification controls",
|
||||
"LabelAuthor": "Autor",
|
||||
"LabelAuthorFirstLast": "Author (First Last)",
|
||||
"LabelAuthorLastFirst": "Author (Last, First)",
|
||||
|
||||
+2
-1
@@ -85,6 +85,7 @@
|
||||
"LabelAddedAt": "Aggiunto il",
|
||||
"LabelAddToPlaylist": "aggiungi alla Playlist",
|
||||
"LabelAll": "Tutti",
|
||||
"LabelAllowSeekingOnMediaControls": "Allow position seeking on media notification controls",
|
||||
"LabelAuthor": "Autore",
|
||||
"LabelAuthorFirstLast": "Autore (Per Nome)",
|
||||
"LabelAuthorLastFirst": "Autori (Per Cognome)",
|
||||
@@ -289,4 +290,4 @@
|
||||
"ToastPodcastCreateSuccess": "Podcast creato Correttamente",
|
||||
"ToastRSSFeedCloseFailed": "Errore chiusura RSS feed",
|
||||
"ToastRSSFeedCloseSuccess": "RSS feed chiuso"
|
||||
}
|
||||
}
|
||||
@@ -85,6 +85,7 @@
|
||||
"LabelAddedAt": "Pridėta {0}",
|
||||
"LabelAddToPlaylist": "Pridėti į grojaraštį",
|
||||
"LabelAll": "Visi",
|
||||
"LabelAllowSeekingOnMediaControls": "Allow position seeking on media notification controls",
|
||||
"LabelAuthor": "Autorius",
|
||||
"LabelAuthorFirstLast": "Autorius (Vardas Pavardė)",
|
||||
"LabelAuthorLastFirst": "Autorius (Pavardė, Vardas)",
|
||||
|
||||
@@ -85,6 +85,7 @@
|
||||
"LabelAddedAt": "Toegevoegd op",
|
||||
"LabelAddToPlaylist": "Toevoegen aan afspeellijst",
|
||||
"LabelAll": "Alle",
|
||||
"LabelAllowSeekingOnMediaControls": "Allow position seeking on media notification controls",
|
||||
"LabelAuthor": "Auteur",
|
||||
"LabelAuthorFirstLast": "Auteur (Voornaam Achternaam)",
|
||||
"LabelAuthorLastFirst": "Auteur (Achternaam, Voornaam)",
|
||||
|
||||
@@ -85,6 +85,7 @@
|
||||
"LabelAddedAt": "Dato lagt til ",
|
||||
"LabelAddToPlaylist": "Legg til i spilleliste",
|
||||
"LabelAll": "Alle",
|
||||
"LabelAllowSeekingOnMediaControls": "Allow position seeking on media notification controls",
|
||||
"LabelAuthor": "Forfatter",
|
||||
"LabelAuthorFirstLast": "Forfatter (Fornavn Etternavn)",
|
||||
"LabelAuthorLastFirst": "Forfatter (Etternavn Fornavn)",
|
||||
|
||||
@@ -85,6 +85,7 @@
|
||||
"LabelAddedAt": "Dodano w",
|
||||
"LabelAddToPlaylist": "Dodaj do playlisty",
|
||||
"LabelAll": "Wszystkie",
|
||||
"LabelAllowSeekingOnMediaControls": "Allow position seeking on media notification controls",
|
||||
"LabelAuthor": "Autor",
|
||||
"LabelAuthorFirstLast": "Autor (Rosnąco)",
|
||||
"LabelAuthorLastFirst": "Author (Malejąco)",
|
||||
|
||||
+2
-1
@@ -85,6 +85,7 @@
|
||||
"LabelAddedAt": "Acrescentado Em",
|
||||
"LabelAddToPlaylist": "Adicionar à Lista de Reprodução",
|
||||
"LabelAll": "Todos",
|
||||
"LabelAllowSeekingOnMediaControls": "Allow position seeking on media notification controls",
|
||||
"LabelAuthor": "Autor",
|
||||
"LabelAuthorFirstLast": "Autor (Nome Sobrenome)",
|
||||
"LabelAuthorLastFirst": "Autor (Sobrenome, Nome)",
|
||||
@@ -289,4 +290,4 @@
|
||||
"ToastPodcastCreateSuccess": "Podcast criado",
|
||||
"ToastRSSFeedCloseFailed": "Falha ao fechar feed RSS",
|
||||
"ToastRSSFeedCloseSuccess": "Feed RSS fechado"
|
||||
}
|
||||
}
|
||||
@@ -85,6 +85,7 @@
|
||||
"LabelAddedAt": "Дата добавления",
|
||||
"LabelAddToPlaylist": "Добавить в плейлист",
|
||||
"LabelAll": "Все",
|
||||
"LabelAllowSeekingOnMediaControls": "Allow position seeking on media notification controls",
|
||||
"LabelAuthor": "Автор",
|
||||
"LabelAuthorFirstLast": "Автор (Имя Фамилия)",
|
||||
"LabelAuthorLastFirst": "Автор (Фамилия, Имя)",
|
||||
|
||||
@@ -85,6 +85,7 @@
|
||||
"LabelAddedAt": "Tillagd vid",
|
||||
"LabelAddToPlaylist": "Lägg till i Spellista",
|
||||
"LabelAll": "Alla",
|
||||
"LabelAllowSeekingOnMediaControls": "Allow position seeking on media notification controls",
|
||||
"LabelAuthor": "Författare",
|
||||
"LabelAuthorFirstLast": "Författare (Förnamn Efternamn)",
|
||||
"LabelAuthorLastFirst": "Författare (Efternamn, Förnamn)",
|
||||
|
||||
@@ -85,6 +85,7 @@
|
||||
"LabelAddedAt": "添加于",
|
||||
"LabelAddToPlaylist": "添加到播放列表",
|
||||
"LabelAll": "全部",
|
||||
"LabelAllowSeekingOnMediaControls": "Allow position seeking on media notification controls",
|
||||
"LabelAuthor": "作者",
|
||||
"LabelAuthorFirstLast": "作者 (姓 名)",
|
||||
"LabelAuthorLastFirst": "作者 (名, 姓)",
|
||||
|
||||
Reference in New Issue
Block a user