move back to pressesBegan for button presses and renamings
This commit is contained in:
parent
8c0d39b94d
commit
2e5eb48cc6
|
@ -12,7 +12,7 @@ protocol PlayerOverlayDelegate {
|
||||||
func didSelectClose()
|
func didSelectClose()
|
||||||
func didSelectGoogleCast()
|
func didSelectGoogleCast()
|
||||||
func didSelectAirplay()
|
func didSelectAirplay()
|
||||||
func didSelectCaptions()
|
func didSelectSubtitles()
|
||||||
func didSelectMenu()
|
func didSelectMenu()
|
||||||
func didDeselectMenu()
|
func didDeselectMenu()
|
||||||
|
|
||||||
|
|
|
@ -128,7 +128,7 @@ class VLCPlayerViewController: UIViewController {
|
||||||
|
|
||||||
setupPanGestureRecognizer()
|
setupPanGestureRecognizer()
|
||||||
|
|
||||||
setupButtonPressRecognizers()
|
addButtonPressRecognizer(pressType: .menu, action: #selector(didPressMenu))
|
||||||
|
|
||||||
let defaultNotificationCenter = NotificationCenter.default
|
let defaultNotificationCenter = NotificationCenter.default
|
||||||
defaultNotificationCenter.addObserver(self, selector: #selector(appWillTerminate), name: UIApplication.willTerminateNotification, object: nil)
|
defaultNotificationCenter.addObserver(self, selector: #selector(appWillTerminate), name: UIApplication.willTerminateNotification, object: nil)
|
||||||
|
@ -189,11 +189,32 @@ class VLCPlayerViewController: UIViewController {
|
||||||
view.addGestureRecognizer(panGestureRecognizer)
|
view.addGestureRecognizer(panGestureRecognizer)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func setupButtonPressRecognizers() {
|
// MARK: pressesBegan
|
||||||
addButtonPressRecognizer(pressType: .menu, action: #selector(didPressMenu))
|
override func pressesBegan(_ presses: Set<UIPress>, with event: UIPressesEvent?) {
|
||||||
addButtonPressRecognizer(pressType: .playPause, action: #selector(didPressPlayPause))
|
guard let buttonPress = presses.first?.type else { return }
|
||||||
addButtonPressRecognizer(pressType: .leftArrow, action: #selector(didPressLeftArrow))
|
|
||||||
addButtonPressRecognizer(pressType: .rightArrow, action: #selector(didPressRightArrow))
|
switch(buttonPress) {
|
||||||
|
case .menu:
|
||||||
|
print("Menu")
|
||||||
|
case .playPause:
|
||||||
|
didSelectMain()
|
||||||
|
case .select:
|
||||||
|
didGenerallyTap()
|
||||||
|
case .upArrow:
|
||||||
|
print("Up arrow")
|
||||||
|
case .downArrow:
|
||||||
|
print("Down arrow")
|
||||||
|
case .leftArrow:
|
||||||
|
didSelectBackward()
|
||||||
|
print("Left arrow")
|
||||||
|
case .rightArrow:
|
||||||
|
didSelectForward()
|
||||||
|
case .pageUp:
|
||||||
|
print("page up")
|
||||||
|
case .pageDown:
|
||||||
|
print("page down")
|
||||||
|
@unknown default: ()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func addButtonPressRecognizer(pressType: UIPress.PressType, action: Selector) {
|
private func addButtonPressRecognizer(pressType: UIPress.PressType, action: Selector) {
|
||||||
|
@ -213,22 +234,6 @@ class VLCPlayerViewController: UIViewController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc private func didPressPlayPause() {
|
|
||||||
didSelectMain()
|
|
||||||
}
|
|
||||||
|
|
||||||
@objc private func didPressSelect() {
|
|
||||||
didGenerallyTap()
|
|
||||||
}
|
|
||||||
|
|
||||||
@objc private func didPressLeftArrow() {
|
|
||||||
didSelectBackward()
|
|
||||||
}
|
|
||||||
|
|
||||||
@objc private func didPressRightArrow() {
|
|
||||||
didSelectForward()
|
|
||||||
}
|
|
||||||
|
|
||||||
@objc private func userPanned(panGestureRecognizer: UIPanGestureRecognizer) {
|
@objc private func userPanned(panGestureRecognizer: UIPanGestureRecognizer) {
|
||||||
if displayingOverlay {
|
if displayingOverlay {
|
||||||
restartOverlayDismissTimer()
|
restartOverlayDismissTimer()
|
||||||
|
@ -611,7 +616,7 @@ extension VLCPlayerViewController: PlayerOverlayDelegate {
|
||||||
print("didSelectAirplay")
|
print("didSelectAirplay")
|
||||||
}
|
}
|
||||||
|
|
||||||
func didSelectCaptions() {
|
func didSelectSubtitles() {
|
||||||
|
|
||||||
viewModel.subtitlesEnabled = !viewModel.subtitlesEnabled
|
viewModel.subtitlesEnabled = !viewModel.subtitlesEnabled
|
||||||
|
|
||||||
|
|
|
@ -74,12 +74,12 @@ struct tvOSVLCOverlay: View {
|
||||||
if !viewModel.subtitleStreams.isEmpty {
|
if !viewModel.subtitleStreams.isEmpty {
|
||||||
if viewModel.subtitlesEnabled {
|
if viewModel.subtitlesEnabled {
|
||||||
SFSymbolButton(systemName: "captions.bubble.fill") {
|
SFSymbolButton(systemName: "captions.bubble.fill") {
|
||||||
viewModel.playerOverlayDelegate?.didSelectCaptions()
|
viewModel.playerOverlayDelegate?.didSelectSubtitles()
|
||||||
}
|
}
|
||||||
.frame(maxWidth: 30, maxHeight: 30)
|
.frame(maxWidth: 30, maxHeight: 30)
|
||||||
} else {
|
} else {
|
||||||
SFSymbolButton(systemName: "captions.bubble") {
|
SFSymbolButton(systemName: "captions.bubble") {
|
||||||
viewModel.playerOverlayDelegate?.didSelectCaptions()
|
viewModel.playerOverlayDelegate?.didSelectSubtitles()
|
||||||
}
|
}
|
||||||
.frame(maxWidth: 30, maxHeight: 30)
|
.frame(maxWidth: 30, maxHeight: 30)
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,7 +117,7 @@ struct VLCPlayerCompactOverlayView: View, VideoPlayerOverlay {
|
||||||
|
|
||||||
if !viewModel.subtitleStreams.isEmpty {
|
if !viewModel.subtitleStreams.isEmpty {
|
||||||
Button {
|
Button {
|
||||||
viewModel.playerOverlayDelegate?.didSelectCaptions()
|
viewModel.playerOverlayDelegate?.didSelectSubtitles()
|
||||||
} label: {
|
} label: {
|
||||||
if viewModel.subtitlesEnabled {
|
if viewModel.subtitlesEnabled {
|
||||||
Image(systemName: "captions.bubble.fill")
|
Image(systemName: "captions.bubble.fill")
|
||||||
|
|
|
@ -76,7 +76,7 @@ struct VLCPlayerOverlayView: View {
|
||||||
}
|
}
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
viewModel.playerOverlayDelegate?.didSelectCaptions()
|
viewModel.playerOverlayDelegate?.didSelectSubtitles()
|
||||||
} label: {
|
} label: {
|
||||||
if viewModel.subtitlesEnabled {
|
if viewModel.subtitlesEnabled {
|
||||||
Image(systemName: "captions.bubble.fill")
|
Image(systemName: "captions.bubble.fill")
|
||||||
|
|
|
@ -12,7 +12,7 @@ protocol PlayerOverlayDelegate {
|
||||||
func didSelectClose()
|
func didSelectClose()
|
||||||
func didSelectGoogleCast()
|
func didSelectGoogleCast()
|
||||||
func didSelectAirplay()
|
func didSelectAirplay()
|
||||||
func didSelectCaptions()
|
func didSelectSubtitles()
|
||||||
func didSelectMenu()
|
func didSelectMenu()
|
||||||
func didDeselectMenu()
|
func didDeselectMenu()
|
||||||
|
|
||||||
|
|
|
@ -468,7 +468,7 @@ extension VLCPlayerViewController: PlayerOverlayDelegate {
|
||||||
print("didSelectAirplay")
|
print("didSelectAirplay")
|
||||||
}
|
}
|
||||||
|
|
||||||
func didSelectCaptions() {
|
func didSelectSubtitles() {
|
||||||
|
|
||||||
viewModel.subtitlesEnabled = !viewModel.subtitlesEnabled
|
viewModel.subtitlesEnabled = !viewModel.subtitlesEnabled
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue