mirror of
https://github.com/yattee/yattee.git
synced 2025-08-06 10:44:06 +00:00
Extend available streams formats list to AVPlayer
This commit is contained in:
@@ -83,13 +83,18 @@ final class AVPlayerBackend: PlayerBackend {
|
||||
playerLayer.player = avPlayer
|
||||
}
|
||||
|
||||
func bestPlayable(_ streams: [Stream], maxResolution _: ResolutionSetting) -> Stream? {
|
||||
streams.first { $0.kind == .hls } ??
|
||||
streams.max { $0.resolution < $1.resolution }
|
||||
func bestPlayable(_ streams: [Stream], maxResolution: ResolutionSetting) -> Stream? {
|
||||
let sortedByResolution = streams
|
||||
.filter { ($0.kind == .adaptive || $0.kind == .stream) && $0.resolution <= maxResolution.value }
|
||||
.sorted { $0.resolution > $1.resolution }
|
||||
|
||||
return streams.first { $0.kind == .hls } ??
|
||||
sortedByResolution.first { $0.kind == .stream } ??
|
||||
sortedByResolution.first
|
||||
}
|
||||
|
||||
func canPlay(_ stream: Stream) -> Bool {
|
||||
stream.kind == .hls || (stream.kind == .stream && stream.resolution.height <= 720)
|
||||
stream.kind == .hls || stream.kind == .stream || (stream.kind == .adaptive && stream.format == .mp4)
|
||||
}
|
||||
|
||||
func playStream(
|
||||
|
Reference in New Issue
Block a user