fixes for 23
This commit is contained in:
parent
bd386b4e45
commit
decd0bd5c0
|
@ -155,11 +155,13 @@ class PlayerViewController: UIViewController, VLCMediaDelegate, VLCMediaPlayerDe
|
||||||
|
|
||||||
@IBAction func settingsButtonTapped(_ sender: UIButton) {
|
@IBAction func settingsButtonTapped(_ sender: UIButton) {
|
||||||
let optionsVC = VideoPlayerSettingsView()
|
let optionsVC = VideoPlayerSettingsView()
|
||||||
|
print(self.selectedAudioTrack)
|
||||||
|
print(self.selectedCaptionTrack)
|
||||||
|
optionsVC.currentSubtitleTrack = self.selectedCaptionTrack
|
||||||
|
optionsVC.currentAudioTrack = self.selectedAudioTrack
|
||||||
optionsVC.delegate = self;
|
optionsVC.delegate = self;
|
||||||
optionsVC.subtitles = subtitleTrackArray
|
optionsVC.subtitles = subtitleTrackArray
|
||||||
optionsVC.audioTracks = audioTrackArray
|
optionsVC.audioTracks = audioTrackArray
|
||||||
optionsVC.currentSubtitleTrack = selectedCaptionTrack
|
|
||||||
optionsVC.currentAudioTrack = selectedAudioTrack
|
|
||||||
// Use the popover presentation style for your view controller.
|
// Use the popover presentation style for your view controller.
|
||||||
optionsVC.modalPresentationStyle = .popover
|
optionsVC.modalPresentationStyle = .popover
|
||||||
|
|
||||||
|
@ -297,6 +299,7 @@ class PlayerViewController: UIViewController, VLCMediaDelegate, VLCMediaPlayerDe
|
||||||
DispatchQueue.global(qos: .background).async {
|
DispatchQueue.global(qos: .background).async {
|
||||||
mediaPlayer.media = VLCMedia(url: playbackItem.videoUrl)
|
mediaPlayer.media = VLCMedia(url: playbackItem.videoUrl)
|
||||||
mediaPlayer.play()
|
mediaPlayer.play()
|
||||||
|
mediaPlayer.jumpForward(Int32(manifest.Progress/10000000))
|
||||||
subtitleTrackArray.forEach() { sub in
|
subtitleTrackArray.forEach() { sub in
|
||||||
if(sub.id != -1 && sub.delivery == "External" && sub.codec != "subrip") {
|
if(sub.id != -1 && sub.delivery == "External" && sub.codec != "subrip") {
|
||||||
print("adding subs for id: \(sub.id) w/ url: \(sub.url)")
|
print("adding subs for id: \(sub.id) w/ url: \(sub.url)")
|
||||||
|
@ -306,10 +309,9 @@ class PlayerViewController: UIViewController, VLCMediaDelegate, VLCMediaPlayerDe
|
||||||
mediaPlayer.pause()
|
mediaPlayer.pause()
|
||||||
delegate?.showLoadingView(self)
|
delegate?.showLoadingView(self)
|
||||||
sleep(3)
|
sleep(3)
|
||||||
mediaPlayer.pause()
|
|
||||||
mediaPlayer.currentVideoSubTitleIndex = selectedCaptionTrack;
|
mediaPlayer.currentVideoSubTitleIndex = selectedCaptionTrack;
|
||||||
|
mediaPlayer.pause()
|
||||||
mediaPlayer.play()
|
mediaPlayer.play()
|
||||||
mediaPlayer.jumpForward(Int32(manifest.Progress/10000000))
|
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
|
|
||||||
|
|
|
@ -62,21 +62,19 @@ class VideoPlayerSettingsView: UIViewController {
|
||||||
private var shouldClosePublisher: AnyCancellable?
|
private var shouldClosePublisher: AnyCancellable?
|
||||||
var subtitles: [Subtitle] = []
|
var subtitles: [Subtitle] = []
|
||||||
var audioTracks: [AudioTrack] = []
|
var audioTracks: [AudioTrack] = []
|
||||||
var currentSubtitleTrack: Int32 = -1;
|
var currentSubtitleTrack: Int32!
|
||||||
var currentAudioTrack: Int32 = 0;
|
var currentAudioTrack: Int32!
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
contentViewDelegate.audioTrackID = currentAudioTrack;
|
ctntView = VideoPlayerSettings(delegate: self.contentViewDelegate, subtitles: self.subtitles, audioTracks: self.audioTracks, initSub: currentSubtitleTrack, initAudio: currentAudioTrack)
|
||||||
contentViewDelegate.subtitleTrackID = currentSubtitleTrack;
|
|
||||||
ctntView = VideoPlayerSettings(delegate: self.contentViewDelegate, subtitles: self.subtitles, audioTracks: self.audioTracks)
|
|
||||||
let contentView = UIHostingController(rootView: ctntView)
|
let contentView = UIHostingController(rootView: ctntView)
|
||||||
self.view.addSubview(contentView.view)
|
self.view.addSubview(contentView.view)
|
||||||
contentView.view.translatesAutoresizingMaskIntoConstraints = false;
|
contentView.view.translatesAutoresizingMaskIntoConstraints = false
|
||||||
contentView.view.topAnchor.constraint(equalTo: view.topAnchor).isActive = true;
|
contentView.view.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
|
||||||
contentView.view.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true;
|
contentView.view.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
|
||||||
contentView.view.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true;
|
contentView.view.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true
|
||||||
contentView.view.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true;
|
contentView.view.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true
|
||||||
|
|
||||||
self.subChangePublisher = self.contentViewDelegate.subtitlesDidChange.sink { suiDelegate in
|
self.subChangePublisher = self.contentViewDelegate.subtitlesDidChange.sink { suiDelegate in
|
||||||
self.delegate?.subtitleTrackChanged(newTrackID: suiDelegate.subtitleTrackID)
|
self.delegate?.subtitleTrackChanged(newTrackID: suiDelegate.subtitleTrackID)
|
||||||
|
@ -104,32 +102,54 @@ struct VideoPlayerSettings: View {
|
||||||
@ObservedObject var delegate: SettingsViewDelegate
|
@ObservedObject var delegate: SettingsViewDelegate
|
||||||
@State private var subtitles: [Subtitle]
|
@State private var subtitles: [Subtitle]
|
||||||
@State private var audioTracks: [AudioTrack]
|
@State private var audioTracks: [AudioTrack]
|
||||||
|
@State private var subtitleSelection: Int32
|
||||||
|
@State private var audioTrackSelection: Int32
|
||||||
|
|
||||||
|
init(delegate: SettingsViewDelegate, subtitles: [Subtitle], audioTracks: [AudioTrack], initSub: Int32, initAudio: Int32) {
|
||||||
init(delegate: SettingsViewDelegate, subtitles: [Subtitle], audioTracks: [AudioTrack]) {
|
|
||||||
self.delegate = delegate
|
self.delegate = delegate
|
||||||
self.subtitles = subtitles
|
self.subtitles = subtitles
|
||||||
self.audioTracks = audioTracks
|
self.audioTracks = audioTracks
|
||||||
|
|
||||||
print(subtitles)
|
self.subtitleSelection = initSub
|
||||||
print(audioTracks)
|
self.audioTrackSelection = initAudio
|
||||||
|
print(initSub)
|
||||||
|
print(initAudio)
|
||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
NavigationView() {
|
GeometryReader { proxy in
|
||||||
Form() {
|
NavigationView() {
|
||||||
Picker("Closed Captions", selection: self.$delegate.subtitleTrackID) {
|
Form() {
|
||||||
ForEach(subtitles, id: \.id) { caption in
|
Picker("Closed Captions", selection: $subtitleSelection) {
|
||||||
Text(caption.name).tag(caption.id)
|
ForEach(subtitles, id: \.id) { caption in
|
||||||
|
Text(caption.name).tag(caption.id)
|
||||||
|
}
|
||||||
|
}.onChange(of: subtitleSelection) { id in
|
||||||
|
self.delegate.subtitleTrackID = id
|
||||||
|
}
|
||||||
|
Picker("Audio Track", selection: $audioTrackSelection) {
|
||||||
|
ForEach(audioTracks, id: \.id) { caption in
|
||||||
|
Text(caption.name).tag(caption.id).lineLimit(1)
|
||||||
|
}
|
||||||
|
}.onChange(of: audioTrackSelection) { id in
|
||||||
|
self.delegate.audioTrackID = id
|
||||||
|
}
|
||||||
|
}.navigationTitle("Audio & Captions")
|
||||||
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
|
.toolbar {
|
||||||
|
ToolbarItemGroup(placement: .navigationBarLeading) {
|
||||||
|
Button {
|
||||||
|
delegate.close = true;
|
||||||
|
} label: {
|
||||||
|
HStack() {
|
||||||
|
Text("Back").font(.callout)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Picker("Audio Track", selection: self.$delegate.audioTrackID) {
|
}.navigationViewStyle(StackNavigationViewStyle())
|
||||||
ForEach(audioTracks, id: \.id) { caption in
|
.padding(6)
|
||||||
Text(caption.name).tag(caption.id).lineLimit(1)
|
.frame(width: proxy.size.width, height: proxy.size.height)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}.navigationTitle("Audio & Captions")
|
|
||||||
.navigationBarTitleDisplayMode(.inline)
|
|
||||||
}.navigationViewStyle(StackNavigationViewStyle())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue