mirror of
https://github.com/yattee/yattee.git
synced 2024-12-13 22:00:31 +05:30
Add advanced setting "Show video context menu options to force selected backend"
This commit is contained in:
parent
e5f137a2d2
commit
562df2d9ba
@ -55,6 +55,7 @@ final class PlayerModel: ObservableObject {
|
|||||||
|
|
||||||
@Published var presentingPlayer = false { didSet { handlePresentationChange() } }
|
@Published var presentingPlayer = false { didSet { handlePresentationChange() } }
|
||||||
@Published var activeBackend = PlayerBackendType.mpv
|
@Published var activeBackend = PlayerBackendType.mpv
|
||||||
|
@Published var forceBackendOnPlay: PlayerBackendType?
|
||||||
|
|
||||||
var avPlayerBackend = AVPlayerBackend()
|
var avPlayerBackend = AVPlayerBackend()
|
||||||
var mpvBackend = MPVBackend()
|
var mpvBackend = MPVBackend()
|
||||||
@ -416,6 +417,10 @@ final class PlayerModel: ObservableObject {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
self.forceBackendOnPlay = nil
|
||||||
|
}
|
||||||
|
|
||||||
if !upgrading {
|
if !upgrading {
|
||||||
DispatchQueue.global(qos: .userInitiated).asyncAfter(deadline: .now() + 0.5) {
|
DispatchQueue.global(qos: .userInitiated).asyncAfter(deadline: .now() + 0.5) {
|
||||||
self.updateCurrentArtwork()
|
self.updateCurrentArtwork()
|
||||||
@ -452,7 +457,7 @@ final class PlayerModel: ObservableObject {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if let backend = (live && forceAVPlayerForLiveStreams) ? PlayerBackendType.appleAVPlayer : qualityProfile?.backend,
|
if let backend = forceBackendOnPlay ?? ((live && forceAVPlayerForLiveStreams) ? PlayerBackendType.appleAVPlayer : qualityProfile?.backend),
|
||||||
backend != activeBackend,
|
backend != activeBackend,
|
||||||
backend == .appleAVPlayer || !(avPlayerBackend.startPictureInPictureOnPlay || playingInPictureInPicture)
|
backend == .appleAVPlayer || !(avPlayerBackend.startPictureInPictureOnPlay || playingInPictureInPicture)
|
||||||
{
|
{
|
||||||
@ -621,6 +626,7 @@ final class PlayerModel: ObservableObject {
|
|||||||
func closeCurrentItem(finished: Bool = false) {
|
func closeCurrentItem(finished: Bool = false) {
|
||||||
pause()
|
pause()
|
||||||
videoBeingOpened = nil
|
videoBeingOpened = nil
|
||||||
|
forceBackendOnPlay = nil
|
||||||
|
|
||||||
closing = true
|
closing = true
|
||||||
controls.presentingControls = false
|
controls.presentingControls = false
|
||||||
|
@ -198,6 +198,7 @@ extension Defaults.Keys {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static let showMPVPlaybackStats = Key<Bool>("showMPVPlaybackStats", default: false)
|
static let showMPVPlaybackStats = Key<Bool>("showMPVPlaybackStats", default: false)
|
||||||
|
static let showPlayNowInBackendContextMenu = Key<Bool>("showPlayNowInBackendContextMenu", default: false)
|
||||||
|
|
||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
static let playerDetailsPageButtonLabelStyleDefault = ButtonLabelStyle.iconAndText
|
static let playerDetailsPageButtonLabelStyleDefault = ButtonLabelStyle.iconAndText
|
||||||
|
@ -8,6 +8,7 @@ struct AdvancedSettings: View {
|
|||||||
@Default(.mpvEnableLogging) private var mpvEnableLogging
|
@Default(.mpvEnableLogging) private var mpvEnableLogging
|
||||||
@Default(.showCacheStatus) private var showCacheStatus
|
@Default(.showCacheStatus) private var showCacheStatus
|
||||||
@Default(.feedCacheSize) private var feedCacheSize
|
@Default(.feedCacheSize) private var feedCacheSize
|
||||||
|
@Default(.showPlayNowInBackendContextMenu) private var showPlayNowInBackendContextMenu
|
||||||
|
|
||||||
@State private var filesToShare = [MPVClient.logFile]
|
@State private var filesToShare = [MPVClient.logFile]
|
||||||
@State private var presentingShareSheet = false
|
@State private var presentingShareSheet = false
|
||||||
@ -56,6 +57,10 @@ struct AdvancedSettings: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ViewBuilder var advancedSettings: some View {
|
@ViewBuilder var advancedSettings: some View {
|
||||||
|
Section(header: SettingsHeader(text: "Advanced")) {
|
||||||
|
showPlayNowInBackendButtonsToggle
|
||||||
|
}
|
||||||
|
|
||||||
Section(header: SettingsHeader(text: "MPV"), footer: mpvFooter) {
|
Section(header: SettingsHeader(text: "MPV"), footer: mpvFooter) {
|
||||||
showMPVPlaybackStatsToggle
|
showMPVPlaybackStatsToggle
|
||||||
#if !os(tvOS)
|
#if !os(tvOS)
|
||||||
@ -115,6 +120,10 @@ struct AdvancedSettings: View {
|
|||||||
.foregroundColor(.secondary)
|
.foregroundColor(.secondary)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var showPlayNowInBackendButtonsToggle: some View {
|
||||||
|
Toggle("Show video context menu options to force selected backend", isOn: $showPlayNowInBackendContextMenu)
|
||||||
|
}
|
||||||
|
|
||||||
var showMPVPlaybackStatsToggle: some View {
|
var showMPVPlaybackStatsToggle: some View {
|
||||||
Toggle("Show playback statistics", isOn: $showMPVPlaybackStats)
|
Toggle("Show playback statistics", isOn: $showMPVPlaybackStats)
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ struct VideoContextMenuView: View {
|
|||||||
@FetchRequest private var watchRequest: FetchedResults<Watch>
|
@FetchRequest private var watchRequest: FetchedResults<Watch>
|
||||||
|
|
||||||
@Default(.saveHistory) private var saveHistory
|
@Default(.saveHistory) private var saveHistory
|
||||||
|
@Default(.showPlayNowInBackendContextMenu) private var showPlayNowInBackendContextMenu
|
||||||
|
|
||||||
private var backgroundContext = PersistenceController.shared.container.newBackgroundContext()
|
private var backgroundContext = PersistenceController.shared.container.newBackgroundContext()
|
||||||
|
|
||||||
@ -71,6 +72,14 @@ struct VideoContextMenuView: View {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if showPlayNowInBackendContextMenu {
|
||||||
|
Section {
|
||||||
|
ForEach(PlayerBackendType.allCases, id: \.self) { backend in
|
||||||
|
playNowInBackendButton(backend)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Section {
|
Section {
|
||||||
playNextButton
|
playNextButton
|
||||||
addToQueueButton
|
addToQueueButton
|
||||||
@ -187,6 +196,20 @@ struct VideoContextMenuView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func playNowInBackendButton(_ backend: PlayerBackendType) -> some View {
|
||||||
|
Button {
|
||||||
|
if player.musicMode {
|
||||||
|
player.toggleMusicMode()
|
||||||
|
}
|
||||||
|
|
||||||
|
player.forceBackendOnPlay = backend
|
||||||
|
|
||||||
|
player.play(video)
|
||||||
|
} label: {
|
||||||
|
Label("Play Now in \(backend.label)", systemImage: "play")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private var playNowInPictureInPictureButton: some View {
|
private var playNowInPictureInPictureButton: some View {
|
||||||
Button {
|
Button {
|
||||||
player.avPlayerBackend.startPictureInPictureOnPlay = true
|
player.avPlayerBackend.startPictureInPictureOnPlay = true
|
||||||
|
Loading…
Reference in New Issue
Block a user