Skip to content

Commit

Permalink
Merge pull request #1178 from indiefan/master
Browse files Browse the repository at this point in the history
Update Now Playing info with correct default rate.
  • Loading branch information
advplyr authored Apr 27, 2024
2 parents e94d6fd + 0f2cd3b commit 6746c06
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion ios/App/Shared/player/AudioPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -707,12 +707,13 @@ class AudioPlayer: NSObject {
duration: currentChapter.getRelativeChapterEndTime(),
currentTime: currentChapter.getRelativeChapterCurrentTime(sessionCurrentTime: session.currentTime),
rate: rate,
defaultRate: tmpRate,
chapterName: currentChapter.title,
chapterNumber: (session.chapters.firstIndex(of: currentChapter) ?? 0) + 1,
chapterCount: session.chapters.count
)
} 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)
}
}

Expand Down
4 changes: 2 additions & 2 deletions ios/App/Shared/util/NowPlayingInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ class NowPlayingInfo {
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
DispatchQueue.main.async { [weak self] in
if let self = self {
self.nowPlayingInfo[MPMediaItemPropertyPlaybackDuration] = duration
self.nowPlayingInfo[MPNowPlayingInfoPropertyElapsedPlaybackTime] = currentTime
self.nowPlayingInfo[MPNowPlayingInfoPropertyPlaybackRate] = rate
self.nowPlayingInfo[MPNowPlayingInfoPropertyDefaultPlaybackRate] = 1.0
self.nowPlayingInfo[MPNowPlayingInfoPropertyDefaultPlaybackRate] = defaultRate


if let chapterName = chapterName, let chapterNumber = chapterNumber, let chapterCount = chapterCount {
Expand Down

0 comments on commit 6746c06

Please sign in to comment.