mirror of
https://github.com/yattee/yattee.git
synced 2024-11-10 00:08:21 +00:00
Add playback mode menu in AVPlayer on tvOS
This commit is contained in:
parent
6deaec90f8
commit
5c038b2aa7
@ -30,6 +30,19 @@ final class PlayerModel: ObservableObject {
|
||||
return "infinity"
|
||||
}
|
||||
}
|
||||
|
||||
var description: String {
|
||||
switch self {
|
||||
case .queue:
|
||||
return "Queue"
|
||||
case .shuffle:
|
||||
return "Queue, shuffled"
|
||||
case .loopOne:
|
||||
return "Loop one"
|
||||
case .related:
|
||||
return "Autoplay next"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static let availableRates: [Float] = [0.5, 0.67, 0.8, 1, 1.25, 1.5, 2]
|
||||
|
@ -69,6 +69,20 @@ extension PlayerModel {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var playbackModeMenu: UIMenu {
|
||||
UIMenu(title: "Playback Mode", image: UIImage(systemName: playbackMode.systemImage), children: playbackModeMenuActions)
|
||||
}
|
||||
|
||||
private var playbackModeMenuActions: [UIAction] {
|
||||
PlaybackMode.allCases.map { mode in
|
||||
UIAction(title: mode.description, image: UIImage(systemName: mode.systemImage)) { _ in
|
||||
DispatchQueue.main.async {
|
||||
self.playbackMode = mode
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
func rebuildTVMenu() {
|
||||
@ -77,6 +91,7 @@ extension PlayerModel {
|
||||
restoreLastSkippedSegmentAction,
|
||||
rateMenu,
|
||||
streamsMenu,
|
||||
playbackModeMenu,
|
||||
switchToMPVAction
|
||||
].compactMap { $0 }
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user