Skip to content

Commit

Permalink
fix #586
Browse files Browse the repository at this point in the history
  • Loading branch information
kingslay committed Oct 15, 2023
1 parent 42fbf09 commit 2740f02
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
20 changes: 20 additions & 0 deletions Demo/SwiftUI/Shared/MovieModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,26 @@ class MEOptions: KSOptions {
}
}

override func updateVideo(refreshRate: Float, formatDescription: CMFormatDescription?) {
#if os(tvOS) || os(xrOS)
guard let displayManager = UIApplication.shared.windows.first?.avDisplayManager,
displayManager.isDisplayCriteriaMatchingEnabled,
!displayManager.isDisplayModeSwitchInProgress
else {
return
}
if let formatDescription {
if KSOptions.displayCriteriaFormatDescriptionEnabled, #available(tvOS 17.0, *) {
displayManager.preferredDisplayCriteria = AVDisplayCriteria(refreshRate: refreshRate, formatDescription: formatDescription)
} else {
let videoDynamicRange = formatDescription.dynamicRange {
displayManager.preferredDisplayCriteria = AVDisplayCriteria(refreshRate: refreshRate, videoDynamicRange: videoDynamicRange.rawValue)
}
}
}
#endif
}

override func isUseDisplayLayer() -> Bool {
MEOptions.isUseDisplayLayer && display == .plane
}
Expand Down
10 changes: 8 additions & 2 deletions Sources/KSPlayer/AVPlayer/KSOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,14 @@ open class KSOptions {
else {
return
}
if KSOptions.displayCriteriaFormatDescriptionEnabled, let formatDescription, #available(tvOS 17.0, *) {
displayManager.preferredDisplayCriteria = AVDisplayCriteria(refreshRate: refreshRate, formatDescription: formatDescription)
if let formatDescription {
if KSOptions.displayCriteriaFormatDescriptionEnabled, #available(tvOS 17.0, *) {
displayManager.preferredDisplayCriteria = AVDisplayCriteria(refreshRate: refreshRate, formatDescription: formatDescription)
} else {
// let videoDynamicRange = formatDescription.dynamicRange {
// displayManager.preferredDisplayCriteria = AVDisplayCriteria(refreshRate: refreshRate, videoDynamicRange: videoDynamicRange.rawValue)
// }
}
}
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/KSPlayer/AVPlayer/MediaPlayerProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public extension MediaPlayerTrack {
}
}

extension CMFormatDescription {
public extension CMFormatDescription {
var dynamicRange: DynamicRange {
let cotentRange: DynamicRange
if codecType.string == "dvhe" || codecType == kCMVideoCodecType_DolbyVisionHEVC {
Expand Down

0 comments on commit 2740f02

Please sign in to comment.