mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-08-04 10:04:39 +02:00
Support local media progress
This commit is contained in:
parent
a107a25e43
commit
64707b0928
3 changed files with 15 additions and 1 deletions
|
@ -114,9 +114,17 @@ public class AbsDatabase: CAPPlugin {
|
|||
@objc func getLocalLibraryItemsInFolder(_ call: CAPPluginCall) {
|
||||
call.resolve([ "value": [] ])
|
||||
}
|
||||
|
||||
@objc func getAllLocalMediaProgress(_ call: CAPPluginCall) {
|
||||
call.resolve([ "value": [] ])
|
||||
do {
|
||||
call.resolve([ "value": try Database.shared.getAllLocalMediaProgress().asDictionaryArray() ])
|
||||
} catch {
|
||||
NSLog("Error while loading local media progress")
|
||||
debugPrint(error)
|
||||
call.resolve(["value": []])
|
||||
}
|
||||
}
|
||||
|
||||
@objc func updateDeviceSettings(_ call: CAPPluginCall) {
|
||||
let disableAutoRewind = call.getBool("disableAutoRewind") ?? false
|
||||
let enableAltView = call.getBool("enableAltView") ?? false
|
||||
|
|
|
@ -138,6 +138,7 @@ extension LocalMediaProgress {
|
|||
self.serverConnectionConfigId = localLibraryItem.serverConnectionConfigId
|
||||
|
||||
self.duration = progress.duration
|
||||
self.progress = progress.progress
|
||||
self.currentTime = progress.currentTime
|
||||
self.isFinished = false
|
||||
self.lastUpdate = progress.lastUpdate
|
||||
|
|
|
@ -166,6 +166,11 @@ class Database {
|
|||
return realm.objects(DeviceSettings.self).first ?? getDefaultDeviceSettings()
|
||||
}
|
||||
|
||||
public func getAllLocalMediaProgress() -> [LocalMediaProgress] {
|
||||
let realm = try! Realm()
|
||||
return Array(realm.objects(LocalMediaProgress.self))
|
||||
}
|
||||
|
||||
public func saveLocalMediaProgress(_ mediaProgress: LocalMediaProgress) {
|
||||
let realm = try! Realm()
|
||||
try! realm.write { realm.add(mediaProgress, update: .modified) }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue