mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 21:43:41 +00:00
Merge pull request #636 from stonerl/captions
fix handling and displaying captions
This commit is contained in:
commit
d9aa5105fa
@ -275,6 +275,10 @@ final class MPVBackend: PlayerBackend {
|
||||
|
||||
self.startClientUpdates()
|
||||
|
||||
// Captions should only be displayed when selected by the user,
|
||||
// not when the video starts. So, we remove them.
|
||||
self.client?.removeSubs()
|
||||
|
||||
if !preservingTime,
|
||||
!upgrading,
|
||||
let segment = self.model.sponsorBlock.segments.first,
|
||||
|
@ -771,10 +771,12 @@ final class PlayerModel: ObservableObject {
|
||||
|
||||
func handleCurrentItemChange() {
|
||||
if currentItem == nil {
|
||||
captions = nil
|
||||
FeedModel.shared.calculateUnwatchedFeed()
|
||||
}
|
||||
|
||||
// Captions need to be set to nil on item change, to clear the previus values.
|
||||
captions = nil
|
||||
|
||||
#if os(macOS)
|
||||
Windows.player.window?.title = windowTitle
|
||||
#endif
|
||||
@ -1188,7 +1190,8 @@ final class PlayerModel: ObservableObject {
|
||||
if !self.controls.isLoadingVideo {
|
||||
self.backend.togglePlay()
|
||||
}
|
||||
default: return keyEvent
|
||||
default:
|
||||
return keyEvent
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -312,7 +312,6 @@ struct ControlsOverlay: View {
|
||||
.foregroundColor(.primary)
|
||||
}
|
||||
.transaction { t in t.animation = .none }
|
||||
|
||||
.buttonStyle(.plain)
|
||||
.foregroundColor(.primary)
|
||||
.frame(width: 240, height: 40)
|
||||
@ -374,14 +373,14 @@ struct ControlsOverlay: View {
|
||||
let captions = player.currentVideo?.captions ?? []
|
||||
Picker("Captions", selection: captionsBinding) {
|
||||
if captions.isEmpty {
|
||||
Text("Not available")
|
||||
Text("Not available").tag(Captions?.none)
|
||||
} else {
|
||||
Text("Disabled").tag(Captions?.none)
|
||||
}
|
||||
ForEach(captions) { caption in
|
||||
Text(caption.description).tag(Optional(caption))
|
||||
}
|
||||
}
|
||||
}
|
||||
.disabled(captions.isEmpty)
|
||||
}
|
||||
|
||||
|
@ -433,14 +433,14 @@ struct PlaybackSettings: View {
|
||||
let captions = player.currentVideo?.captions ?? []
|
||||
Picker("Captions".localized(), selection: $player.captions) {
|
||||
if captions.isEmpty {
|
||||
Text("Not available")
|
||||
Text("Not available").tag(Captions?.none)
|
||||
} else {
|
||||
Text("Disabled").tag(Captions?.none)
|
||||
}
|
||||
ForEach(captions) { caption in
|
||||
Text(caption.description).tag(Optional(caption))
|
||||
}
|
||||
}
|
||||
}
|
||||
.disabled(captions.isEmpty)
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct ImportSettings: View {
|
||||
|
Loading…
Reference in New Issue
Block a user