Skip to content

Commit

Permalink
Add new setting to enable seek controls on lock screen
Browse files Browse the repository at this point in the history
  • Loading branch information
GianniCarlo committed Feb 6, 2025
1 parent ac889b2 commit 4d4c892
Show file tree
Hide file tree
Showing 29 changed files with 134 additions and 24 deletions.
7 changes: 6 additions & 1 deletion BookPlayer/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate, BPLogger {
return .success
}

center.changePlaybackPositionCommand.isEnabled = true
setupChangePlaybackPositionCommand()
}

func setupChangePlaybackPositionCommand() {
let center = MPRemoteCommandCenter.shared()
center.changePlaybackPositionCommand.isEnabled = UserDefaults.standard.bool(forKey: Constants.UserDefaults.seekProgressBarEnabled)
center.changePlaybackPositionCommand.addTarget { [weak self] remoteEvent in
guard
let playerManager = self?.coreServices?.playerManager,
Expand Down
2 changes: 2 additions & 0 deletions BookPlayer/Base.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,5 @@ We're working hard on providing a seamless experience, if possible, please conta
"runtime_unknown" = "Unknown duration";
"subscription_required_title" = "Subscription required";
"Swipe rows to see download options" = "Swipe rows to see download options";
"settings_seekprogressbar_title" = "Progress Bar Seeking";
"settings_seekprogressbar_description" = "Enable seeking on the lock screen";
84 changes: 62 additions & 22 deletions BookPlayer/Settings/Base.lproj/Settings.storyboard

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ import BookPlayerKit
import Combine
import Themeable
import UIKit
import MediaPlayer

class PlayerSettingsViewController: UITableViewController, Storyboarded {
@IBOutlet weak var autoSleepTimerSwitch: UISwitch!
@IBOutlet weak var smartRewindSwitch: UISwitch!
@IBOutlet weak var boostVolumeSwitch: UISwitch!
@IBOutlet weak var globalSpeedSwitch: UISwitch!
@IBOutlet weak var seekProgressBarSwitch: UISwitch!
@IBOutlet weak var rewindIntervalLabel: UILabel!
@IBOutlet weak var forwardIntervalLabel: UILabel!
@IBOutlet weak var playerListPreferenceLabel: UILabel!
Expand All @@ -28,7 +30,7 @@ class PlayerSettingsViewController: UITableViewController, Storyboarded {

enum SettingsSection: Int {
case intervals = 0
case rewind, sleepTimer, volume, speed, playerList, progressLabels
case rewind, sleepTimer, volume, speed, seek, playerList, progressLabels
}

let playerListPreferencePath = IndexPath(row: 0, section: SettingsSection.playerList.rawValue)
Expand All @@ -49,6 +51,7 @@ class PlayerSettingsViewController: UITableViewController, Storyboarded {
autoSleepTimerSwitch.addTarget(self, action: #selector(autoSleepTimerToggleDidChange), for: .valueChanged)
boostVolumeSwitch.addTarget(self, action: #selector(boostVolumeToggleDidChange), for: .valueChanged)
globalSpeedSwitch.addTarget(self, action: #selector(globalSpeedToggleDidChange), for: .valueChanged)
seekProgressBarSwitch.addTarget(self, action: #selector(seekProgressBarToggleDidChange), for: .valueChanged)

// Set initial switch positions
smartRewindSwitch.setOn(
Expand All @@ -67,6 +70,10 @@ class PlayerSettingsViewController: UITableViewController, Storyboarded {
UserDefaults.standard.bool(forKey: Constants.UserDefaults.globalSpeedEnabled),
animated: false
)
seekProgressBarSwitch.setOn(
UserDefaults.standard.bool(forKey: Constants.UserDefaults.seekProgressBarEnabled),
animated: false
)
chapterTimeSwitch.setOn(
viewModel.prefersChapterContext,
animated: false
Expand Down Expand Up @@ -204,6 +211,8 @@ class PlayerSettingsViewController: UITableViewController, Storyboarded {
return "settings_boostvolume_description".localized
case .speed:
return "settings_globalspeed_description".localized
case .seek:
return "settings_seekprogressbar_description".localized
case .progressLabels:
return "settings_progresslabels_description".localized
case .playerList:
Expand All @@ -230,6 +239,11 @@ class PlayerSettingsViewController: UITableViewController, Storyboarded {
@objc func globalSpeedToggleDidChange() {
UserDefaults.standard.set(self.globalSpeedSwitch.isOn, forKey: Constants.UserDefaults.globalSpeedEnabled)
}

@objc func seekProgressBarToggleDidChange() {
UserDefaults.standard.set(self.seekProgressBarSwitch.isOn, forKey: Constants.UserDefaults.seekProgressBarEnabled)
MPRemoteCommandCenter.shared().changePlaybackPositionCommand.isEnabled = seekProgressBarSwitch.isOn
}
}

extension PlayerSettingsViewController: Themeable {
Expand Down
2 changes: 2 additions & 0 deletions BookPlayer/ar.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,5 @@
"runtime_unknown" = "مدة غير معروفة";
"subscription_required_title" = "الاشتراك مطلوب";
"Swipe rows to see download options" = "مرر الصفوف لرؤية خيارات التنزيل";
"settings_seekprogressbar_title" = "Progress Bar Seeking";
"settings_seekprogressbar_description" = "Enable seeking on the lock screen";
2 changes: 2 additions & 0 deletions BookPlayer/cs.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,5 @@
"runtime_unknown" = "Neznámá doba trvání";
"subscription_required_title" = "Je vyžadováno předplatné";
"Swipe rows to see download options" = "Přejetím po řádcích zobrazíte možnosti stahování";
"settings_seekprogressbar_title" = "Progress Bar Seeking";
"settings_seekprogressbar_description" = "Enable seeking on the lock screen";
2 changes: 2 additions & 0 deletions BookPlayer/da.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,5 @@
"runtime_unknown" = "Ukendt varighed";
"subscription_required_title" = "Kræver abonnement";
"Swipe rows to see download options" = "Stryg rækkerne for at se downloadmuligheder";
"settings_seekprogressbar_title" = "Progress Bar Seeking";
"settings_seekprogressbar_description" = "Enable seeking on the lock screen";
2 changes: 2 additions & 0 deletions BookPlayer/de.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,5 @@
"runtime_unknown" = "Unbekannte Dauer";
"subscription_required_title" = "Abonnement erforderlich";
"Swipe rows to see download options" = "Wischen Sie durch die Zeilen, um die Download-Optionen anzuzeigen";
"settings_seekprogressbar_title" = "Progress Bar Seeking";
"settings_seekprogressbar_description" = "Enable seeking on the lock screen";
2 changes: 2 additions & 0 deletions BookPlayer/el.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,5 @@
"runtime_unknown" = "Άγνωστη διάρκεια";
"subscription_required_title" = "Απαιτείται συνδρομή";
"Swipe rows to see download options" = "Σύρετε σειρές για να δείτε τις επιλογές λήψης";
"settings_seekprogressbar_title" = "Progress Bar Seeking";
"settings_seekprogressbar_description" = "Enable seeking on the lock screen";
2 changes: 2 additions & 0 deletions BookPlayer/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,5 @@ We're working hard on providing a seamless experience, if possible, please conta
"runtime_unknown" = "Unknown duration";
"subscription_required_title" = "Subscription required";
"Swipe rows to see download options" = "Swipe rows to see download options";
"settings_seekprogressbar_title" = "Progress Bar Seeking";
"settings_seekprogressbar_description" = "Enable seeking on the lock screen";
2 changes: 2 additions & 0 deletions BookPlayer/es.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,5 @@
"runtime_unknown" = "Duración desconocida";
"subscription_required_title" = "Se requiere suscripción";
"Swipe rows to see download options" = "Desliza las filas para ver las opciones de descarga";
"settings_seekprogressbar_title" = "Progress Bar Seeking";
"settings_seekprogressbar_description" = "Enable seeking on the lock screen";
2 changes: 2 additions & 0 deletions BookPlayer/fi.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,5 @@
"runtime_unknown" = "Tuntematon kesto";
"subscription_required_title" = "Tilaus vaaditaan";
"Swipe rows to see download options" = "Pyyhkäise rivejä nähdäksesi latausvaihtoehdot";
"settings_seekprogressbar_title" = "Progress Bar Seeking";
"settings_seekprogressbar_description" = "Enable seeking on the lock screen";
2 changes: 2 additions & 0 deletions BookPlayer/fr.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,5 @@
"runtime_unknown" = "Durée inconnue";
"subscription_required_title" = "Abonnement requis";
"Swipe rows to see download options" = "Faites glisser les lignes pour voir les options de téléchargement";
"settings_seekprogressbar_title" = "Progress Bar Seeking";
"settings_seekprogressbar_description" = "Enable seeking on the lock screen";
2 changes: 2 additions & 0 deletions BookPlayer/hu.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,5 @@
"runtime_unknown" = "Ismeretlen időtartam";
"subscription_required_title" = "Előfizetés szükséges";
"Swipe rows to see download options" = "Csúsztassa el a sorokat a letöltési lehetőségek megtekintéséhez";
"settings_seekprogressbar_title" = "Progress Bar Seeking";
"settings_seekprogressbar_description" = "Enable seeking on the lock screen";
2 changes: 2 additions & 0 deletions BookPlayer/it.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,5 @@
"runtime_unknown" = "Durata sconosciuta";
"subscription_required_title" = "Abbonamento richiesto";
"Swipe rows to see download options" = "Scorri le righe per vedere le opzioni di download";
"settings_seekprogressbar_title" = "Progress Bar Seeking";
"settings_seekprogressbar_description" = "Enable seeking on the lock screen";
2 changes: 2 additions & 0 deletions BookPlayer/ja.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,5 @@ We're working hard on providing a seamless experience, if possible, please conta
"runtime_unknown" = "Unknown duration";
"subscription_required_title" = "Subscription required";
"Swipe rows to see download options" = "Swipe rows to see download options";
"settings_seekprogressbar_title" = "Progress Bar Seeking";
"settings_seekprogressbar_description" = "Enable seeking on the lock screen";
2 changes: 2 additions & 0 deletions BookPlayer/nb.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,5 @@ Vi jobber hardt for å gi deg en sømløs opplevelse. Hvis mulig, kontakt oss p
"runtime_unknown" = "Ukjent varighet";
"subscription_required_title" = "Abonnement kreves";
"Swipe rows to see download options" = "Sveip rader for å se nedlastingsalternativer";
"settings_seekprogressbar_title" = "Progress Bar Seeking";
"settings_seekprogressbar_description" = "Enable seeking on the lock screen";
2 changes: 2 additions & 0 deletions BookPlayer/nl.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,5 @@
"runtime_unknown" = "Onbekende duur";
"subscription_required_title" = "Abonnement vereist";
"Swipe rows to see download options" = "Veeg over de rijen om de downloadopties te zien";
"settings_seekprogressbar_title" = "Progress Bar Seeking";
"settings_seekprogressbar_description" = "Enable seeking on the lock screen";
2 changes: 2 additions & 0 deletions BookPlayer/pl.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,5 @@
"runtime_unknown" = "Nieznany czas trwania";
"subscription_required_title" = "Wymagana subskrypcja";
"Swipe rows to see download options" = "Przesuń wiersze, aby zobaczyć opcje pobierania";
"settings_seekprogressbar_title" = "Progress Bar Seeking";
"settings_seekprogressbar_description" = "Enable seeking on the lock screen";
2 changes: 2 additions & 0 deletions BookPlayer/pt-BR.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,5 @@
"runtime_unknown" = "Duração desconhecida";
"subscription_required_title" = "Assinatura necessária";
"Swipe rows to see download options" = "Deslize as linhas para ver as opções de download";
"settings_seekprogressbar_title" = "Progress Bar Seeking";
"settings_seekprogressbar_description" = "Enable seeking on the lock screen";
2 changes: 2 additions & 0 deletions BookPlayer/pt-PT.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,5 @@
"runtime_unknown" = "Duração desconhecida";
"subscription_required_title" = "Assinatura necessária";
"Swipe rows to see download options" = "Deslize as linhas para ver as opções de download";
"settings_seekprogressbar_title" = "Progress Bar Seeking";
"settings_seekprogressbar_description" = "Enable seeking on the lock screen";
2 changes: 2 additions & 0 deletions BookPlayer/ro.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,5 @@
"runtime_unknown" = "Durată necunoscută";
"subscription_required_title" = "Este necesar un abonament";
"Swipe rows to see download options" = "Glisați rândurile pentru a vedea opțiunile de descărcare";
"settings_seekprogressbar_title" = "Progress Bar Seeking";
"settings_seekprogressbar_description" = "Enable seeking on the lock screen";
2 changes: 2 additions & 0 deletions BookPlayer/ru.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,5 @@
"runtime_unknown" = "Неизвестная продолжительность";
"subscription_required_title" = "Требуется подписка";
"Swipe rows to see download options" = "Проведите пальцем по строкам, чтобы увидеть варианты загрузки";
"settings_seekprogressbar_title" = "Progress Bar Seeking";
"settings_seekprogressbar_description" = "Enable seeking on the lock screen";
2 changes: 2 additions & 0 deletions BookPlayer/sk-SK.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,5 @@ Usilovne pracujeme na poskytovaní bezproblémového zážitku, ak je to možné
"runtime_unknown" = "Neznáme trvanie";
"subscription_required_title" = "Vyžaduje sa predplatné";
"Swipe rows to see download options" = "Potiahnutím riadkov zobrazíte možnosti sťahovania";
"settings_seekprogressbar_title" = "Progress Bar Seeking";
"settings_seekprogressbar_description" = "Enable seeking on the lock screen";
2 changes: 2 additions & 0 deletions BookPlayer/sv.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,5 @@
"runtime_unknown" = "Okänd varaktighet";
"subscription_required_title" = "Prenumeration krävs";
"Swipe rows to see download options" = "Svep rader för att se nedladdningsalternativ";
"settings_seekprogressbar_title" = "Progress Bar Seeking";
"settings_seekprogressbar_description" = "Enable seeking on the lock screen";
2 changes: 2 additions & 0 deletions BookPlayer/tr.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,5 @@
"runtime_unknown" = "Bilinmeyen süre";
"subscription_required_title" = "Abonelik gerekli";
"Swipe rows to see download options" = "İndirme seçeneklerini görmek için satırları kaydırın";
"settings_seekprogressbar_title" = "Progress Bar Seeking";
"settings_seekprogressbar_description" = "Enable seeking on the lock screen";
2 changes: 2 additions & 0 deletions BookPlayer/uk.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,5 @@
"runtime_unknown" = "Невідома тривалість";
"subscription_required_title" = "Потрібна підписка";
"Swipe rows to see download options" = "Гортайте рядки, щоб переглянути параметри завантаження";
"settings_seekprogressbar_title" = "Progress Bar Seeking";
"settings_seekprogressbar_description" = "Enable seeking on the lock screen";
2 changes: 2 additions & 0 deletions BookPlayer/zh-Hans.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,5 @@
"runtime_unknown" = "持续时间未知";
"subscription_required_title" = "需要订阅";
"Swipe rows to see download options" = "滑动行查看下载选项";
"settings_seekprogressbar_title" = "Progress Bar Seeking";
"settings_seekprogressbar_description" = "Enable seeking on the lock screen";
1 change: 1 addition & 0 deletions Shared/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public enum Constants {
public static let smartRewindEnabled = "userSettingsSmartRewind"
public static let boostVolumeEnabled = "userSettingsBoostVolume"
public static let globalSpeedEnabled = "userSettingsGlobalSpeed"
public static let seekProgressBarEnabled = "userSettingsSeekProgressBar"
public static let autoplayEnabled = "userSettingsAutoplay"
public static let autoplayRestartEnabled = "userSettingsAutoplayRestart"
public static let allowCellularData = "userSettingsAllowCellularData"
Expand Down

0 comments on commit 4d4c892

Please sign in to comment.