mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 21:43:41 +00:00
apply best resolution from non HLS to HLS stream
This makes sure that HLS Streams can be compared with non HLS streams, otherwise HLS would have been the first selected since the maxResolution.value might have been higher then what could actually be the highest resolution served.
This commit is contained in:
parent
d8c8f8084b
commit
fba01e35a3
@ -131,9 +131,17 @@ extension PlayerBackend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func bestPlayable(_ streams: [Stream], maxResolution: ResolutionSetting, formatOrder: [QualityProfile.Format]) -> Stream? {
|
func bestPlayable(_ streams: [Stream], maxResolution: ResolutionSetting, formatOrder: [QualityProfile.Format]) -> Stream? {
|
||||||
|
// filter out non HLS streams
|
||||||
|
let nonHLSStreams = streams.filter { $0.kind != .hls }
|
||||||
|
|
||||||
|
// find max resolution from non HLS streams
|
||||||
|
let bestResolution = nonHLSStreams
|
||||||
|
.filter { $0.resolution <= maxResolution.value }
|
||||||
|
.max { $0.resolution < $1.resolution }?.resolution
|
||||||
|
|
||||||
return streams.map { stream in
|
return streams.map { stream in
|
||||||
if stream.kind == .hls {
|
if stream.kind == .hls {
|
||||||
stream.resolution = maxResolution.value
|
stream.resolution = bestResolution ?? maxResolution.value
|
||||||
stream.format = .hls
|
stream.format = .hls
|
||||||
} else if stream.kind == .stream {
|
} else if stream.kind == .stream {
|
||||||
stream.format = .stream
|
stream.format = .stream
|
||||||
|
Loading…
Reference in New Issue
Block a user