mirror of
https://github.com/yattee/yattee.git
synced 2025-01-10 23:07:10 +00:00
Add playback mode menu in AVPlayer on tvOS
This commit is contained in:
parent
0a95b805f2
commit
cbd1102563
@ -30,6 +30,19 @@ final class PlayerModel: ObservableObject {
|
|||||||
return "infinity"
|
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]
|
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
|
#endif
|
||||||
|
|
||||||
func rebuildTVMenu() {
|
func rebuildTVMenu() {
|
||||||
@ -77,6 +91,7 @@ extension PlayerModel {
|
|||||||
restoreLastSkippedSegmentAction,
|
restoreLastSkippedSegmentAction,
|
||||||
rateMenu,
|
rateMenu,
|
||||||
streamsMenu,
|
streamsMenu,
|
||||||
|
playbackModeMenu,
|
||||||
switchToMPVAction
|
switchToMPVAction
|
||||||
].compactMap { $0 }
|
].compactMap { $0 }
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user