mirror of
https://github.com/cranci1/Sora.git
synced 2026-04-21 16:42:01 +00:00
would this wrk?
This commit is contained in:
parent
ad2ade2f45
commit
92585beaba
1 changed files with 71 additions and 57 deletions
|
|
@ -13,6 +13,7 @@ import AVFoundation
|
|||
import MarqueeLabel
|
||||
|
||||
class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDelegate {
|
||||
private var airplayButton: AVRoutePickerView!
|
||||
let module: ScrapingModule
|
||||
let streamURL: String
|
||||
let fullUrl: String
|
||||
|
|
@ -176,7 +177,9 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
|
|||
qualityButton,
|
||||
speedButton,
|
||||
watchNextButton,
|
||||
volumeSliderHostingView
|
||||
volumeSliderHostingView,
|
||||
pipButton,
|
||||
airplayButton
|
||||
].compactMap { $0 }
|
||||
|
||||
private var originalHiddenStates: [UIView: Bool] = [:]
|
||||
|
|
@ -1239,6 +1242,16 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
|
|||
}
|
||||
|
||||
private func setupPipIfSupported() {
|
||||
airplayButton = AVRoutePickerView(frame: .zero)
|
||||
airplayButton.translatesAutoresizingMaskIntoConstraints = false
|
||||
airplayButton.activeTintColor = .white
|
||||
airplayButton.tintColor = .white
|
||||
airplayButton.backgroundColor = .clear
|
||||
airplayButton.prioritizesVideoDevices = true
|
||||
airplayButton.setContentHuggingPriority(.required, for: .horizontal)
|
||||
airplayButton.setContentCompressionResistancePriority(.required, for: .horizontal)
|
||||
controlsContainerView.addSubview(airplayButton)
|
||||
|
||||
guard AVPictureInPictureController.isPictureInPictureSupported() else {
|
||||
return
|
||||
}
|
||||
|
|
@ -1250,39 +1263,43 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
|
|||
pipController = AVPictureInPictureController(playerLayer: pipPlayerLayer)
|
||||
pipController?.delegate = self
|
||||
|
||||
let config = UIImage.SymbolConfiguration(pointSize: 15, weight: .medium)
|
||||
let Image = UIImage(systemName: "pip", withConfiguration: config)
|
||||
pipButton = UIButton(type: .system)
|
||||
pipButton.setImage(Image, for: .normal)
|
||||
pipButton.tintColor = .white
|
||||
pipButton.addTarget(self, action: #selector(pipButtonTapped(_:)), for: .touchUpInside)
|
||||
|
||||
pipButton.layer.shadowColor = UIColor.black.cgColor
|
||||
pipButton.layer.shadowOffset = CGSize(width: 0, height: 2)
|
||||
pipButton.layer.shadowOpacity = 0.6
|
||||
pipButton.layer.shadowRadius = 4
|
||||
pipButton.layer.masksToBounds = false
|
||||
let config = UIImage.SymbolConfiguration(pointSize: 15, weight: .medium)
|
||||
let Image = UIImage(systemName: "pip", withConfiguration: config)
|
||||
pipButton = UIButton(type: .system)
|
||||
pipButton.setImage(Image, for: .normal)
|
||||
pipButton.tintColor = .white
|
||||
pipButton.addTarget(self, action: #selector(pipButtonTapped(_:)), for: .touchUpInside)
|
||||
|
||||
controlsContainerView.addSubview(pipButton)
|
||||
pipButton.translatesAutoresizingMaskIntoConstraints = false
|
||||
pipButton.layer.shadowColor = UIColor.black.cgColor
|
||||
pipButton.layer.shadowOffset = CGSize(width: 0, height: 2)
|
||||
pipButton.layer.shadowOpacity = 0.6
|
||||
pipButton.layer.shadowRadius = 4
|
||||
pipButton.layer.masksToBounds = false
|
||||
|
||||
// NEW: pin pipButton to the left of lockButton:
|
||||
NSLayoutConstraint.activate([
|
||||
pipButton.centerYAnchor.constraint(equalTo: dimButton.centerYAnchor),
|
||||
pipButton.trailingAnchor.constraint(equalTo: dimButton.leadingAnchor, constant: -8),
|
||||
pipButton.widthAnchor.constraint(equalToConstant: 44),
|
||||
pipButton.heightAnchor.constraint(equalToConstant: 44)
|
||||
])
|
||||
controlsContainerView.addSubview(pipButton)
|
||||
pipButton.translatesAutoresizingMaskIntoConstraints = false
|
||||
|
||||
pipButton.isHidden = !isPipButtonVisible
|
||||
NSLayoutConstraint.activate([
|
||||
pipButton.centerYAnchor.constraint(equalTo: dimButton.centerYAnchor),
|
||||
pipButton.trailingAnchor.constraint(equalTo: dimButton.leadingAnchor, constant: -8),
|
||||
pipButton.widthAnchor.constraint(equalToConstant: 44),
|
||||
pipButton.heightAnchor.constraint(equalToConstant: 44),
|
||||
airplayButton.centerYAnchor.constraint(equalTo: pipButton.centerYAnchor),
|
||||
airplayButton.trailingAnchor.constraint(equalTo: pipButton.leadingAnchor, constant: -8),
|
||||
airplayButton.widthAnchor.constraint(equalToConstant: 44),
|
||||
airplayButton.heightAnchor.constraint(equalToConstant: 44)
|
||||
])
|
||||
|
||||
NotificationCenter.default.addObserver(
|
||||
self,
|
||||
selector: #selector(startPipIfNeeded),
|
||||
name: UIApplication.willResignActiveNotification,
|
||||
object: nil
|
||||
)
|
||||
}
|
||||
pipButton.isHidden = !isPipButtonVisible
|
||||
|
||||
NotificationCenter.default.addObserver(
|
||||
self,
|
||||
selector: #selector(startPipIfNeeded),
|
||||
name: UIApplication.willResignActiveNotification,
|
||||
object: nil
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
func setupMenuButton() {
|
||||
|
|
@ -1754,8 +1771,8 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
|
|||
guard isPipAutoEnabled,
|
||||
let pip = pipController,
|
||||
!pip.isPictureInPictureActive else {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
pip.startPictureInPicture()
|
||||
}
|
||||
|
||||
|
|
@ -1845,19 +1862,16 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
|
|||
|
||||
UIView.animate(withDuration: 0.25) {
|
||||
self.blackCoverView.alpha = self.isDimmed ? 1.0 : 0.4
|
||||
// fade all controls (and lock button) in or out
|
||||
for v in self.controlsToHide { v.alpha = self.isDimmed ? 0 : 1 }
|
||||
self.dimButton.alpha = self.isDimmed ? 0 : 1
|
||||
self.lockButton.alpha = self.isDimmed ? 0 : 1
|
||||
|
||||
// switch subtitle constraints just like toggleControls()
|
||||
self.subtitleBottomToSafeAreaConstraint?.isActive = !self.isControlsVisible
|
||||
self.subtitleBottomToSliderConstraint?.isActive = self.isControlsVisible
|
||||
|
||||
self.view.layoutIfNeeded()
|
||||
}
|
||||
|
||||
// slide the dim-icon over
|
||||
dimButtonToSlider.isActive = !isDimmed
|
||||
dimButtonToRight.isActive = isDimmed
|
||||
}
|
||||
|
|
@ -2625,4 +2639,4 @@ extension CustomMediaPlayerViewController: AVPictureInPictureControllerDelegate
|
|||
// The mind is the source of good and evil, only you yourself can decide which you will bring yourself. -seiike
|
||||
// guys watch Clannad already - ibro
|
||||
// May the Divine Providence bestow its infinite mercy upon your soul, and may eternal grace find you beyond the shadows of this mortal realm. - paul, 15/11/2005 - 13/05/2023
|
||||
// this dumbass ↑ defo used gpt
|
||||
// this dumbass ↑ defo used gpt, ong he did bro
|
||||
|
|
|
|||
Loading…
Reference in a new issue