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