mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 21:43:41 +00:00
parent
d1cf45c6a1
commit
0d5a907517
@ -134,7 +134,7 @@ final class AVPlayerBackend: PlayerBackend {
|
|||||||
_ stream: Stream,
|
_ stream: Stream,
|
||||||
of video: Video,
|
of video: Video,
|
||||||
preservingTime: Bool,
|
preservingTime: Bool,
|
||||||
upgrading _: Bool
|
upgrading: Bool
|
||||||
) {
|
) {
|
||||||
isLoadingVideo = true
|
isLoadingVideo = true
|
||||||
|
|
||||||
@ -145,7 +145,7 @@ final class AVPlayerBackend: PlayerBackend {
|
|||||||
_ = url.startAccessingSecurityScopedResource()
|
_ = url.startAccessingSecurityScopedResource()
|
||||||
}
|
}
|
||||||
|
|
||||||
loadSingleAsset(url, stream: stream, of: video, preservingTime: preservingTime)
|
loadSingleAsset(url, stream: stream, of: video, preservingTime: preservingTime, upgrading: upgrading)
|
||||||
} else {
|
} else {
|
||||||
model.logger.info("playing stream with many assets:")
|
model.logger.info("playing stream with many assets:")
|
||||||
model.logger.info("composition audio asset: \(stream.audioAsset.url)")
|
model.logger.info("composition audio asset: \(stream.audioAsset.url)")
|
||||||
@ -219,7 +219,8 @@ final class AVPlayerBackend: PlayerBackend {
|
|||||||
_ url: URL,
|
_ url: URL,
|
||||||
stream: Stream,
|
stream: Stream,
|
||||||
of video: Video,
|
of video: Video,
|
||||||
preservingTime: Bool = false
|
preservingTime: Bool = false,
|
||||||
|
upgrading: Bool = false
|
||||||
) {
|
) {
|
||||||
asset?.cancelLoading()
|
asset?.cancelLoading()
|
||||||
asset = AVURLAsset(url: url)
|
asset = AVURLAsset(url: url)
|
||||||
@ -228,7 +229,7 @@ final class AVPlayerBackend: PlayerBackend {
|
|||||||
switch self?.asset?.statusOfValue(forKey: "duration", error: &error) {
|
switch self?.asset?.statusOfValue(forKey: "duration", error: &error) {
|
||||||
case .loaded:
|
case .loaded:
|
||||||
DispatchQueue.main.async { [weak self] in
|
DispatchQueue.main.async { [weak self] in
|
||||||
self?.insertPlayerItem(stream, for: video, preservingTime: preservingTime)
|
self?.insertPlayerItem(stream, for: video, preservingTime: preservingTime, upgrading: upgrading)
|
||||||
}
|
}
|
||||||
case .failed:
|
case .failed:
|
||||||
DispatchQueue.main.async { [weak self] in
|
DispatchQueue.main.async { [weak self] in
|
||||||
@ -303,7 +304,8 @@ final class AVPlayerBackend: PlayerBackend {
|
|||||||
private func insertPlayerItem(
|
private func insertPlayerItem(
|
||||||
_ stream: Stream,
|
_ stream: Stream,
|
||||||
for video: Video,
|
for video: Video,
|
||||||
preservingTime: Bool = false
|
preservingTime: Bool = false,
|
||||||
|
upgrading: Bool = false
|
||||||
) {
|
) {
|
||||||
removeItemDidPlayToEndTimeObserver()
|
removeItemDidPlayToEndTimeObserver()
|
||||||
|
|
||||||
@ -387,7 +389,7 @@ final class AVPlayerBackend: PlayerBackend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if preservingTime {
|
if preservingTime {
|
||||||
if model.preservedTime.isNil {
|
if model.preservedTime.isNil || upgrading {
|
||||||
model.saveTime {
|
model.saveTime {
|
||||||
replaceItemAndSeek()
|
replaceItemAndSeek()
|
||||||
startPlaying()
|
startPlaying()
|
||||||
|
@ -330,7 +330,7 @@ final class MPVBackend: PlayerBackend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if preservingTime {
|
if preservingTime {
|
||||||
if model.preservedTime.isNil {
|
if model.preservedTime.isNil || upgrading {
|
||||||
model.saveTime {
|
model.saveTime {
|
||||||
replaceItem(self.model.preservedTime)
|
replaceItem(self.model.preservedTime)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user