mirror of
https://github.com/yattee/yattee.git
synced 2026-08-06 07:11:28 +00:00
Add loading external subtitle files for media-source playback
Adds a "Load subtitle from file…" row to the Subtitles section on iOS (document picker) and macOS (open panel), available when playing files from local folder, SMB, or WebDAV sources. The picked file is copied into the per-video temp subtitle directory, registered as a selectable Caption (displayed by filename), and activated through the existing loadCaption flow. The Subtitles tab and captions control button now also appear for media-source files without any subtitles.
This commit is contained in:
@@ -957,11 +957,51 @@ extension QualitySelectorView {
|
||||
.padding(.vertical, 8)
|
||||
.padding(.horizontal, 12)
|
||||
}
|
||||
|
||||
if canLoadExternalSubtitles {
|
||||
Divider()
|
||||
|
||||
loadSubtitleFileRow
|
||||
.padding(.vertical, 8)
|
||||
.padding(.horizontal, 12)
|
||||
}
|
||||
}
|
||||
.cardBackground()
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !os(tvOS)
|
||||
/// Row that opens a file picker to load an external subtitle file into
|
||||
/// the current media-source playback.
|
||||
private var loadSubtitleFileRow: some View {
|
||||
Button {
|
||||
#if os(iOS)
|
||||
showingSubtitleFilePicker = true
|
||||
#elseif os(macOS)
|
||||
SubtitleFilePanel.present { url in
|
||||
handlePickedSubtitleFile(url)
|
||||
}
|
||||
#endif
|
||||
} label: {
|
||||
HStack(spacing: 8) {
|
||||
Image(systemName: "folder.badge.plus")
|
||||
.foregroundStyle(.secondary)
|
||||
Text("stream.subtitles.loadFromFile")
|
||||
.font(.headline)
|
||||
Spacer()
|
||||
}
|
||||
.frame(maxWidth: .infinity, minHeight: 36)
|
||||
.contentShape(Rectangle())
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
|
||||
func handlePickedSubtitleFile(_ url: URL) {
|
||||
appEnvironment?.playerService.loadExternalSubtitleFile(from: url)
|
||||
performDismiss()
|
||||
}
|
||||
#endif
|
||||
|
||||
@ViewBuilder
|
||||
private func embeddedSubtitleTrackRow(_ track: MPVTrack) -> some View {
|
||||
EmbeddedTrackRowView(
|
||||
|
||||
Reference in New Issue
Block a user