mirror of
https://github.com/cranci1/Sora.git
synced 2026-03-11 17:45:37 +00:00
Yeah idk i need to study now
This commit is contained in:
parent
0bd4d21cbf
commit
c42216f793
2 changed files with 21 additions and 29 deletions
|
|
@ -68,10 +68,6 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
|
||||||
return UserDefaults.standard.bool(forKey: "doubleTapSeekEnabled")
|
return UserDefaults.standard.bool(forKey: "doubleTapSeekEnabled")
|
||||||
}
|
}
|
||||||
|
|
||||||
private var isPipAutoEnabled: Bool {
|
|
||||||
UserDefaults.standard.bool(forKey: "pipAutoEnabled")
|
|
||||||
}
|
|
||||||
|
|
||||||
private var isPipButtonVisible: Bool {
|
private var isPipButtonVisible: Bool {
|
||||||
if UserDefaults.standard.object(forKey: "pipButtonVisible") == nil {
|
if UserDefaults.standard.object(forKey: "pipButtonVisible") == nil {
|
||||||
return true
|
return true
|
||||||
|
|
@ -484,8 +480,7 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
|
||||||
name: .AVPlayerItemDidPlayToEndTime,
|
name: .AVPlayerItemDidPlayToEndTime,
|
||||||
object: player.currentItem
|
object: player.currentItem
|
||||||
)
|
)
|
||||||
|
NotificationCenter.default.addObserver(self, selector: #selector(startPipIfNeeded), name: UIApplication.didEnterBackgroundNotification, object: nil)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private func setupTopRowLayout() {
|
private func setupTopRowLayout() {
|
||||||
|
|
@ -2211,28 +2206,17 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc private func pipButtonTapped(_ sender: UIButton) {
|
@objc private func pipButtonTapped(_ sender: UIButton) {
|
||||||
Logger.shared.log("PiP button tapped", type: "Debug")
|
guard let pip = pipController else { return }
|
||||||
guard let pip = pipController else {
|
|
||||||
Logger.shared.log("PiP controller is nil", type: "Error")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
Logger.shared.log("PiP controller found, isActive: \(pip.isPictureInPictureActive)", type: "Debug")
|
|
||||||
if pip.isPictureInPictureActive {
|
if pip.isPictureInPictureActive {
|
||||||
pip.stopPictureInPicture()
|
pip.stopPictureInPicture()
|
||||||
Logger.shared.log("Stopping PiP", type: "Debug")
|
|
||||||
} else {
|
} else {
|
||||||
pip.startPictureInPicture()
|
pip.startPictureInPicture()
|
||||||
Logger.shared.log("Starting PiP", type: "Debug")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc private func startPipIfNeeded() {
|
@objc private func startPipIfNeeded() {
|
||||||
guard isPipAutoEnabled,
|
Logger.shared.log("PIP", type: "Genral")
|
||||||
let pip = pipController,
|
pipController!.startPictureInPicture()
|
||||||
!pip.isPictureInPictureActive else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
pip.startPictureInPicture()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc private func lockTapped() {
|
@objc private func lockTapped() {
|
||||||
|
|
@ -3595,12 +3579,12 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
|
||||||
playerLayerContainer.trailingAnchor.constraint(equalTo: view.trailingAnchor)
|
playerLayerContainer.trailingAnchor.constraint(equalTo: view.trailingAnchor)
|
||||||
])
|
])
|
||||||
|
|
||||||
let playerLayer = AVPlayerLayer(player: player)
|
let pipPlayerLayer = AVPlayerLayer(player: playerViewController.player)
|
||||||
playerLayer.frame = playerLayerContainer.bounds
|
pipPlayerLayer.frame = playerViewController.view.layer.bounds
|
||||||
playerLayer.videoGravity = .resizeAspect
|
pipPlayerLayer.videoGravity = .resizeAspect
|
||||||
playerLayerContainer.layer.addSublayer(playerLayer)
|
|
||||||
|
|
||||||
pipController = AVPictureInPictureController(playerLayer: playerLayer)
|
playerViewController.view.layer.insertSublayer(pipPlayerLayer, at: 0)
|
||||||
|
pipController = AVPictureInPictureController(playerLayer: pipPlayerLayer)
|
||||||
pipController?.delegate = self
|
pipController?.delegate = self
|
||||||
|
|
||||||
let Image = UIImage(systemName: "pip", withConfiguration: cfg)
|
let Image = UIImage(systemName: "pip", withConfiguration: cfg)
|
||||||
|
|
@ -3625,7 +3609,7 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
|
||||||
|
|
||||||
pipButton.isHidden = !isPipButtonVisible
|
pipButton.isHidden = !isPipButtonVisible
|
||||||
|
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(startPipIfNeeded), name: UIApplication.willResignActiveNotification, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(startPipIfNeeded), name: UIApplication.didEnterBackgroundNotification, object: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateMarqueeConstraints() {
|
func updateMarqueeConstraints() {
|
||||||
|
|
|
||||||
|
|
@ -214,6 +214,14 @@ struct MediaInfoView: View {
|
||||||
selectedRange = ranges.first ?? 0..<episodeChunkSize
|
selectedRange = ranges.first ?? 0..<episodeChunkSize
|
||||||
}
|
}
|
||||||
UserDefaults.standard.set(newValue, forKey: selectedSeasonKey)
|
UserDefaults.standard.set(newValue, forKey: selectedSeasonKey)
|
||||||
|
|
||||||
|
if let provider = activeProvider {
|
||||||
|
if provider == "TMDB" {
|
||||||
|
fetchTMDBPosterImageAndSet()
|
||||||
|
} else if provider == "AniList" {
|
||||||
|
fetchAniListPosterImageAndSet()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.onChange(of: selectedChapterRange) { newValue in
|
.onChange(of: selectedChapterRange) { newValue in
|
||||||
UserDefaults.standard.set(newValue.lowerBound, forKey: selectedChapterRangeKey)
|
UserDefaults.standard.set(newValue.lowerBound, forKey: selectedChapterRangeKey)
|
||||||
|
|
@ -623,7 +631,7 @@ struct MediaInfoView: View {
|
||||||
sourceButton
|
sourceButton
|
||||||
menuButton
|
menuButton
|
||||||
}
|
}
|
||||||
if isGroupedBySeasons || episodeLinks.count > episodeChunkSize {
|
if isGroupedBySeasons || (!isGroupedBySeasons && episodeLinks.count > episodeChunkSize) {
|
||||||
HStack {
|
HStack {
|
||||||
if isGroupedBySeasons {
|
if isGroupedBySeasons {
|
||||||
seasonSelectorStyled
|
seasonSelectorStyled
|
||||||
|
|
@ -631,7 +639,7 @@ struct MediaInfoView: View {
|
||||||
Spacer(minLength: 0)
|
Spacer(minLength: 0)
|
||||||
}
|
}
|
||||||
Spacer()
|
Spacer()
|
||||||
if episodeLinks.count > episodeChunkSize {
|
if !isGroupedBySeasons && episodeLinks.count > episodeChunkSize {
|
||||||
rangeSelectorStyled
|
rangeSelectorStyled
|
||||||
.padding(.trailing, 4)
|
.padding(.trailing, 4)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue