mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-08-29 22:29:29 +02:00
Update Now Playing info with correct default rate so that third party apps don't mistake current status as scrubbing.
This commit is contained in:
parent
e94d6fdc1e
commit
0f2cd3b132
2 changed files with 4 additions and 3 deletions
|
@ -707,12 +707,13 @@ class AudioPlayer: NSObject {
|
||||||
duration: currentChapter.getRelativeChapterEndTime(),
|
duration: currentChapter.getRelativeChapterEndTime(),
|
||||||
currentTime: currentChapter.getRelativeChapterCurrentTime(sessionCurrentTime: session.currentTime),
|
currentTime: currentChapter.getRelativeChapterCurrentTime(sessionCurrentTime: session.currentTime),
|
||||||
rate: rate,
|
rate: rate,
|
||||||
|
defaultRate: tmpRate,
|
||||||
chapterName: currentChapter.title,
|
chapterName: currentChapter.title,
|
||||||
chapterNumber: (session.chapters.firstIndex(of: currentChapter) ?? 0) + 1,
|
chapterNumber: (session.chapters.firstIndex(of: currentChapter) ?? 0) + 1,
|
||||||
chapterCount: session.chapters.count
|
chapterCount: session.chapters.count
|
||||||
)
|
)
|
||||||
} else if let duration = self.getDuration(), let currentTime = self.getCurrentTime() {
|
} else if let duration = self.getDuration(), let currentTime = self.getCurrentTime() {
|
||||||
NowPlayingInfo.shared.update(duration: duration, currentTime: currentTime, rate: rate)
|
NowPlayingInfo.shared.update(duration: duration, currentTime: currentTime, rate: rate, defaultRate: tmpRate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,14 +53,14 @@ class NowPlayingInfo {
|
||||||
self.setMetadata(artwork: artwork, metadata: metadata)
|
self.setMetadata(artwork: artwork, metadata: metadata)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public func update(duration: Double, currentTime: Double, rate: Float, chapterName: String? = nil, chapterNumber: Int? = nil, chapterCount: Int? = nil) {
|
public func update(duration: Double, currentTime: Double, rate: Float, defaultRate: Float, chapterName: String? = nil, chapterNumber: Int? = nil, chapterCount: Int? = nil) {
|
||||||
// Update on the main to prevent access collisions
|
// Update on the main to prevent access collisions
|
||||||
DispatchQueue.main.async { [weak self] in
|
DispatchQueue.main.async { [weak self] in
|
||||||
if let self = self {
|
if let self = self {
|
||||||
self.nowPlayingInfo[MPMediaItemPropertyPlaybackDuration] = duration
|
self.nowPlayingInfo[MPMediaItemPropertyPlaybackDuration] = duration
|
||||||
self.nowPlayingInfo[MPNowPlayingInfoPropertyElapsedPlaybackTime] = currentTime
|
self.nowPlayingInfo[MPNowPlayingInfoPropertyElapsedPlaybackTime] = currentTime
|
||||||
self.nowPlayingInfo[MPNowPlayingInfoPropertyPlaybackRate] = rate
|
self.nowPlayingInfo[MPNowPlayingInfoPropertyPlaybackRate] = rate
|
||||||
self.nowPlayingInfo[MPNowPlayingInfoPropertyDefaultPlaybackRate] = 1.0
|
self.nowPlayingInfo[MPNowPlayingInfoPropertyDefaultPlaybackRate] = defaultRate
|
||||||
|
|
||||||
|
|
||||||
if let chapterName = chapterName, let chapterNumber = chapterNumber, let chapterCount = chapterCount {
|
if let chapterName = chapterName, let chapterNumber = chapterNumber, let chapterCount = chapterCount {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue