mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 21:43:41 +00:00
Merge pull request #641 from stonerl/switch-to-previous-backend
switch to previous backend when leaving PiP
This commit is contained in:
commit
094461d359
@ -76,6 +76,8 @@ final class PlayerModel: ObservableObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var previousActiveBackend: PlayerBackendType?
|
||||||
|
|
||||||
lazy var playerBackendView = PlayerBackendView()
|
lazy var playerBackendView = PlayerBackendView()
|
||||||
|
|
||||||
@Published var playerSize: CGSize = .zero { didSet {
|
@Published var playerSize: CGSize = .zero { didSet {
|
||||||
@ -532,7 +534,7 @@ final class PlayerModel: ObservableObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func changeActiveBackend(from: PlayerBackendType, to: PlayerBackendType, changingStream: Bool = true) {
|
func changeActiveBackend(from: PlayerBackendType, to: PlayerBackendType, changingStream: Bool = true, isInClosePip: Bool = false) {
|
||||||
guard activeBackend != to else {
|
guard activeBackend != to else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -541,7 +543,7 @@ final class PlayerModel: ObservableObject {
|
|||||||
|
|
||||||
let wasPlaying = isPlaying
|
let wasPlaying = isPlaying
|
||||||
|
|
||||||
if to == .mpv {
|
if to == .mpv && !isInClosePip {
|
||||||
closePiP()
|
closePiP()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -664,6 +666,7 @@ final class PlayerModel: ObservableObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func startPiP() {
|
func startPiP() {
|
||||||
|
previousActiveBackend = activeBackend
|
||||||
avPlayerBackend.startPictureInPictureOnPlay = false
|
avPlayerBackend.startPictureInPictureOnPlay = false
|
||||||
avPlayerBackend.startPictureInPictureOnSwitch = false
|
avPlayerBackend.startPictureInPictureOnSwitch = false
|
||||||
|
|
||||||
@ -716,6 +719,12 @@ final class PlayerModel: ObservableObject {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
backend.closePiP()
|
backend.closePiP()
|
||||||
|
if previousActiveBackend == .mpv {
|
||||||
|
saveTime {
|
||||||
|
self.changeActiveBackend(from: self.activeBackend, to: .mpv, isInClosePip: true)
|
||||||
|
self.controls.resetTimer()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var pipImage: String {
|
var pipImage: String {
|
||||||
|
Loading…
Reference in New Issue
Block a user