mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 21:43:41 +00:00
Merge pull request #676 from stonerl/fix-pip-broken-with-mpv
fix PiP Mode Not Working Using MPV
This commit is contained in:
commit
959fb0d1fc
@ -683,10 +683,11 @@ final class PlayerModel: ObservableObject {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
guard let video = currentVideo else { return }
|
// First, we need to create an array with supported formats.
|
||||||
guard let stream = backend.bestPlayable(availableStreams, maxResolution: .hd720p30, formatOrder: qualityProfile!.formats) else { return }
|
let formatOrderPiP: [QualityProfile.Format] = [.hls, .stream, .mp4]
|
||||||
|
|
||||||
exitFullScreen()
|
guard let video = currentVideo else { return }
|
||||||
|
guard let stream = avPlayerBackend.bestPlayable(availableStreams, maxResolution: .hd720p30, formatOrder: formatOrderPiP) else { return }
|
||||||
|
|
||||||
if avPlayerBackend.video == video {
|
if avPlayerBackend.video == video {
|
||||||
if activeBackend != .appleAVPlayer {
|
if activeBackend != .appleAVPlayer {
|
||||||
@ -698,7 +699,19 @@ final class PlayerModel: ObservableObject {
|
|||||||
playStream(stream, of: video, preservingTime: true, upgrading: true, withBackend: avPlayerBackend)
|
playStream(stream, of: video, preservingTime: true, upgrading: true, withBackend: avPlayerBackend)
|
||||||
}
|
}
|
||||||
|
|
||||||
controls.objectWillChange.send()
|
var retryCount = 0
|
||||||
|
_ = Timer.scheduledTimer(withTimeInterval: 0.5, repeats: true) { [weak self] timer in
|
||||||
|
if let pipController = self?.pipController, pipController.isPictureInPictureActive, self?.avPlayerBackend.isPlaying == true {
|
||||||
|
self?.exitFullScreen()
|
||||||
|
self?.controls.objectWillChange.send()
|
||||||
|
timer.invalidate()
|
||||||
|
} else if retryCount < 3, self?.activeBackend == .appleAVPlayer, self?.avPlayerBackend.startPictureInPictureOnSwitch == false {
|
||||||
|
// If PiP didn't start, try starting it again up to 3 times,
|
||||||
|
self?.avPlayerBackend.startPictureInPictureOnSwitch = true
|
||||||
|
self?.avPlayerBackend.tryStartingPictureInPicture()
|
||||||
|
retryCount += 1
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var transitioningToPiP: Bool {
|
var transitioningToPiP: Bool {
|
||||||
@ -726,14 +739,21 @@ final class PlayerModel: ObservableObject {
|
|||||||
show()
|
show()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
backend.closePiP()
|
|
||||||
if previousActiveBackend == .mpv {
|
if previousActiveBackend == .mpv {
|
||||||
saveTime {
|
saveTime {
|
||||||
self.changeActiveBackend(from: self.activeBackend, to: .mpv, isInClosePip: true)
|
self.changeActiveBackend(from: self.activeBackend, to: .mpv, isInClosePip: true)
|
||||||
self.controls.resetTimer()
|
_ = Timer.scheduledTimer(withTimeInterval: 0.5, repeats: true) { [weak self] timer in
|
||||||
|
if self?.activeBackend == .mpv, self?.mpvBackend.isPlaying == true {
|
||||||
|
self?.backend.closePiP()
|
||||||
|
self?.controls.resetTimer()
|
||||||
|
timer.invalidate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
backend.closePiP()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var pipImage: String {
|
var pipImage: String {
|
||||||
transitioningToPiP ? "pip.fill" : pipController?.isPictureInPictureActive ?? false ? "pip.exit" : "pip.enter"
|
transitioningToPiP ? "pip.fill" : pipController?.isPictureInPictureActive ?? false ? "pip.exit" : "pip.enter"
|
||||||
|
@ -170,7 +170,7 @@ extension Defaults.Keys {
|
|||||||
static let hd2160pMPVProfile = QualityProfile(id: "hd2160pMPVProfile", backend: .mpv, resolution: .hd2160p60, formats: QualityProfile.Format.allCases, order: Array(QualityProfile.Format.allCases.indices))
|
static let hd2160pMPVProfile = QualityProfile(id: "hd2160pMPVProfile", backend: .mpv, resolution: .hd2160p60, formats: QualityProfile.Format.allCases, order: Array(QualityProfile.Format.allCases.indices))
|
||||||
static let hd1080pMPVProfile = QualityProfile(id: "hd1080pMPVProfile", backend: .mpv, resolution: .hd1080p60, formats: QualityProfile.Format.allCases, order: Array(QualityProfile.Format.allCases.indices))
|
static let hd1080pMPVProfile = QualityProfile(id: "hd1080pMPVProfile", backend: .mpv, resolution: .hd1080p60, formats: QualityProfile.Format.allCases, order: Array(QualityProfile.Format.allCases.indices))
|
||||||
static let hd720pMPVProfile = QualityProfile(id: "hd720pMPVProfile", backend: .mpv, resolution: .hd720p60, formats: QualityProfile.Format.allCases, order: Array(QualityProfile.Format.allCases.indices))
|
static let hd720pMPVProfile = QualityProfile(id: "hd720pMPVProfile", backend: .mpv, resolution: .hd720p60, formats: QualityProfile.Format.allCases, order: Array(QualityProfile.Format.allCases.indices))
|
||||||
static let hd720pAVPlayerProfile = QualityProfile(id: "hd720pAVPlayerProfile", backend: .appleAVPlayer, resolution: .hd720p60, formats: [.hls, .stream], order: Array(QualityProfile.Format.allCases.indices))
|
static let hd720pAVPlayerProfile = QualityProfile(id: "hd720pAVPlayerProfile", backend: .appleAVPlayer, resolution: .hd720p30, formats: [.hls, .stream], order: Array(QualityProfile.Format.allCases.indices))
|
||||||
static let sd360pAVPlayerProfile = QualityProfile(id: "sd360pAVPlayerProfile", backend: .appleAVPlayer, resolution: .sd360p30, formats: [.hls, .stream], order: Array(QualityProfile.Format.allCases.indices))
|
static let sd360pAVPlayerProfile = QualityProfile(id: "sd360pAVPlayerProfile", backend: .appleAVPlayer, resolution: .sd360p30, formats: [.hls, .stream], order: Array(QualityProfile.Format.allCases.indices))
|
||||||
|
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
|
@ -315,7 +315,7 @@ struct QualityProfileForm: View {
|
|||||||
func isResolutionDisabled(_ resolution: ResolutionSetting) -> Bool {
|
func isResolutionDisabled(_ resolution: ResolutionSetting) -> Bool {
|
||||||
guard backend == .appleAVPlayer else { return false }
|
guard backend == .appleAVPlayer else { return false }
|
||||||
|
|
||||||
return resolution.value > .hd1080p60
|
return resolution.value > .hd720p30
|
||||||
}
|
}
|
||||||
|
|
||||||
func initializeForm() {
|
func initializeForm() {
|
||||||
|
Loading…
Reference in New Issue
Block a user