mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-08-03 09:34:51 +02:00
Merge branch 'master' of https://github.com/advplyr/audiobookshelf-app into advplyr-master
This commit is contained in:
commit
ac71d39265
12 changed files with 362 additions and 109 deletions
|
@ -32,6 +32,7 @@ class PlayerHandler {
|
|||
}
|
||||
}
|
||||
private static var listeningTimePassedSinceLastSync: Double = 0.0
|
||||
private static var lastSyncReport: PlaybackReport?
|
||||
|
||||
public static var paused: Bool {
|
||||
get {
|
||||
|
@ -86,7 +87,7 @@ class PlayerHandler {
|
|||
}
|
||||
|
||||
let destinationTime = player.getCurrentTime() + amount
|
||||
player.seek(destinationTime)
|
||||
player.seek(destinationTime, from: "handler")
|
||||
}
|
||||
public static func seekBackward(amount: Double) {
|
||||
guard let player = player else {
|
||||
|
@ -94,10 +95,10 @@ class PlayerHandler {
|
|||
}
|
||||
|
||||
let destinationTime = player.getCurrentTime() - amount
|
||||
player.seek(destinationTime)
|
||||
player.seek(destinationTime, from: "handler")
|
||||
}
|
||||
public static func seek(amount: Double) {
|
||||
player?.seek(amount)
|
||||
player?.seek(amount, from: "handler")
|
||||
}
|
||||
public static func getMetdata() -> [String: Any] {
|
||||
DispatchQueue.main.async {
|
||||
|
@ -132,10 +133,17 @@ class PlayerHandler {
|
|||
if session == nil { return }
|
||||
guard let player = player else { return }
|
||||
|
||||
let report = PlaybackReport(currentTime: player.getCurrentTime(), duration: player.getDuration(), timeListened: listeningTimePassedSinceLastSync)
|
||||
let playerCurrentTime = player.getCurrentTime()
|
||||
if (lastSyncReport != nil && lastSyncReport?.currentTime == playerCurrentTime) {
|
||||
// No need to syncProgress
|
||||
return
|
||||
}
|
||||
|
||||
session!.currentTime = player.getCurrentTime()
|
||||
let report = PlaybackReport(currentTime: playerCurrentTime, duration: player.getDuration(), timeListened: listeningTimePassedSinceLastSync)
|
||||
|
||||
session!.currentTime = playerCurrentTime
|
||||
listeningTimePassedSinceLastSync = 0
|
||||
lastSyncReport = report
|
||||
|
||||
// TODO: check if online
|
||||
NSLog("sending playback report")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue