Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,9 @@ public enum FeatureFlag: String, CaseIterable {
/// Enable the Share Profile feature
case shareProfile

/// Rewind ~1s on auto-resume after an audio interruption (e.g. CarPlay nav prompts)
case rewindOnResumeAfterInterruption

public var enabled: Bool {
if let overriddenValue = FeatureFlagOverrideStore().overriddenValue(for: self) {
return overriddenValue
Expand Down Expand Up @@ -535,6 +538,8 @@ public enum FeatureFlag: String, CaseIterable {
false
case .shareProfile:
BuildEnvironment.current == .debug
case .rewindOnResumeAfterInterruption:
true
}
}

Expand Down
9 changes: 8 additions & 1 deletion podcasts/PlaybackManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2104,7 +2104,14 @@ class PlaybackManager: ServerPlaybackDelegate {
let interruptionOption = userInfo[AVAudioSessionInterruptionOptionKey] as! NSNumber
FileLog.shared.addMessage("PlaybackManager handleAudioInterrupt ended, should attempt to restart audio: \(interruptionOption) reason: \(interruptionReason?.description ?? "unknown")")
if interruptionOption.uintValue == AVAudioSession.InterruptionOptions.shouldResume.rawValue, wasPlayingBeforeInterruption {
play(userInitiated: false)
if FeatureFlag.rewindOnResumeAfterInterruption.enabled {
let rewindInterval: TimeInterval = 1.0
let resumeTime = max(0, currentTime() - rewindInterval)
FileLog.shared.addMessage("PlaybackManager rewinding \(rewindInterval)s before resuming after interruption (from \(currentTime()) to \(resumeTime))")
seekTo(time: resumeTime, startPlaybackAfterSeek: true)
} else {
play(userInitiated: false)
}
wasPlayingBeforeInterruption = false
}
} else if interruptionType.uintValue == AVAudioSession.InterruptionType.began.rawValue {
Expand Down