mirror of
https://github.com/dirtydishes/dreamio.git
synced 2026-06-06 21:38:15 +00:00
add captions selection proof logging
This commit is contained in:
parent
d8ebc7c7f9
commit
2cbe982a47
5 changed files with 184 additions and 4 deletions
|
|
@ -380,13 +380,27 @@ final class NativePlayerViewController: UIViewController {
|
|||
|
||||
private func captionsMenu() -> UIMenu {
|
||||
let selectedTrackID = backend.selectedSubtitleTrackID
|
||||
let trackActions = SubtitleOptionMapper.options(from: backend.subtitleTracks).map { track in
|
||||
let tracks = backend.subtitleTracks
|
||||
let options = SubtitleOptionMapper.options(from: tracks)
|
||||
#if DEBUG
|
||||
print("[DreamioCaptions] build-menu tracks=\(SubtitleDebugFormatter.trackSummary(tracks)) options=\(SubtitleDebugFormatter.trackSummary(options)) selected=\(selectedTrackID)")
|
||||
#endif
|
||||
let trackActions = options.map { track in
|
||||
UIAction(
|
||||
title: track.name,
|
||||
state: track.id == selectedTrackID ? .on : .off
|
||||
) { [weak self] _ in
|
||||
self?.backend.selectSubtitleTrack(id: track.id)
|
||||
self?.refreshControls()
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
#if DEBUG
|
||||
print("[DreamioCaptions] select-request id=\(track.id) name=\(track.name) before=\(self.backend.selectedSubtitleTrackID)")
|
||||
#endif
|
||||
self.backend.selectSubtitleTrack(id: track.id)
|
||||
#if DEBUG
|
||||
print("[DreamioCaptions] select-result id=\(track.id) after=\(self.backend.selectedSubtitleTrackID) tracks=\(SubtitleDebugFormatter.trackSummary(self.backend.subtitleTracks))")
|
||||
#endif
|
||||
self.refreshControls()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -420,12 +434,17 @@ final class NativePlayerViewController: UIViewController {
|
|||
}
|
||||
|
||||
private func refreshControls() {
|
||||
let subtitleTracks = backend.subtitleTracks
|
||||
let subtitleOptions = SubtitleOptionMapper.options(from: subtitleTracks)
|
||||
playPauseButton.setImage(UIImage(systemName: backend.isPlaying ? "pause.fill" : "play.fill"), for: .normal)
|
||||
scrubber.isEnabled = backend.isSeekable
|
||||
jumpBackButton.isEnabled = backend.isSeekable
|
||||
jumpForwardButton.isEnabled = backend.isSeekable
|
||||
captionsButton.isEnabled = !SubtitleOptionMapper.options(from: backend.subtitleTracks).isEmpty
|
||||
captionsButton.isEnabled = !subtitleOptions.isEmpty
|
||||
captionsButton.menu = captionsMenu()
|
||||
#if DEBUG
|
||||
print("[DreamioCaptions] refresh enabled=\(captionsButton.isEnabled) tracks=\(SubtitleDebugFormatter.trackSummary(subtitleTracks)) selected=\(backend.selectedSubtitleTrackID)")
|
||||
#endif
|
||||
elapsedLabel.text = PlaybackTimeFormatter.label(for: backend.currentTime)
|
||||
remainingLabel.text = "-\(PlaybackTimeFormatter.label(for: backend.remainingTime))"
|
||||
if !isScrubbing {
|
||||
|
|
|
|||
|
|
@ -100,14 +100,26 @@ final class VLCNativePlaybackBackend: NSObject, NativePlaybackBackend {
|
|||
|
||||
func selectSubtitleTrack(id: Int32) {
|
||||
#if canImport(MobileVLCKit)
|
||||
#if DEBUG
|
||||
logSubtitleTracks(reason: "before-select-\(id)")
|
||||
#endif
|
||||
mediaPlayer.currentVideoSubTitleIndex = id
|
||||
#if DEBUG
|
||||
logSubtitleTracks(reason: "after-select-\(id)")
|
||||
#endif
|
||||
onSubtitleTracksChange?()
|
||||
#endif
|
||||
}
|
||||
|
||||
func adjustSubtitleDelay(by seconds: TimeInterval) {
|
||||
#if canImport(MobileVLCKit)
|
||||
#if DEBUG
|
||||
print("[DreamioVLC] subtitle delay before=\(subtitleDelay) delta=\(seconds)")
|
||||
#endif
|
||||
mediaPlayer.currentVideoSubTitleDelay += Int(seconds * 1_000_000)
|
||||
#if DEBUG
|
||||
print("[DreamioVLC] subtitle delay after=\(subtitleDelay)")
|
||||
#endif
|
||||
onSubtitleTracksChange?()
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue