Show stream opening status with AVPlayer

This commit is contained in:
Arkadiusz Fal
2023-05-21 12:09:18 +02:00
parent 2b7ccc4b03
commit c6798be167
6 changed files with 174 additions and 143 deletions

View File

@@ -38,9 +38,7 @@ final class AVPlayerBackend: PlayerBackend {
!avPlayer.currentItem.isNil
}
var isLoadingVideo: Bool {
model.currentItem == nil || model.time == nil || !model.time!.isValid
}
var isLoadingVideo = false
var isPlaying: Bool {
avPlayer.timeControlStatus == .playing
@@ -138,6 +136,8 @@ final class AVPlayerBackend: PlayerBackend {
preservingTime: Bool,
upgrading _: Bool
) {
isLoadingVideo = true
if let url = stream.singleAssetURL {
model.logger.info("playing stream with one asset\(stream.kind == .hls ? " (HLS)" : ""): \(url)")
@@ -475,6 +475,8 @@ final class AVPlayerBackend: PlayerBackend {
return
}
isLoadingVideo = false
switch playerItem.status {
case .readyToPlay:
if self.model.activeBackend == .appleAVPlayer,

View File

@@ -32,6 +32,17 @@ extension PlayerModel {
}
}
var playerItemEndTimeWithSegments: CMTime? {
if let duration = playerItemDuration,
let segment = sponsorBlock.segments.last,
segment.endTime.seconds >= duration.seconds - 3
{
return segment.endTime
}
return playerItemDuration
}
private func skip(_ segment: Segment, at time: CMTime) {
if let duration = playerItemDuration, segment.endTime.seconds >= duration.seconds - 3 {
logger.error("segment end time is: \(segment.end) when player item duration is: \(duration.seconds)")