Skip to content

Commit

Permalink
增加开关 preferredFrame
Browse files Browse the repository at this point in the history
  • Loading branch information
kingslay committed Jan 7, 2024
1 parent 150207b commit 6646ed9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions Sources/KSPlayer/AVPlayer/KSOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ public extension KSOptions {
static var asynchronousDecompression = false
static var isPipPopViewController = false
static var canStartPictureInPictureAutomaticallyFromInline = true
static var preferredFrame = true
static var displayCriteriaFormatDescriptionEnabled = false
/// 日志级别
static var logLevel = LogLevel.warning
Expand Down
12 changes: 7 additions & 5 deletions Sources/KSPlayer/MEPlayer/MetalPlayView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ public final class MetalPlayView: UIView, VideoOutput {
private var fps = Float(60) {
didSet {
if fps != oldValue {
let preferredFramesPerSecond = ceil(fps)
if #available(iOS 15.0, tvOS 15.0, macOS 14.0, *) {
displayLink.preferredFrameRateRange = CAFrameRateRange(minimum: preferredFramesPerSecond, maximum: 2 * preferredFramesPerSecond, __preferred: preferredFramesPerSecond)
} else {
displayLink.preferredFramesPerSecond = Int(preferredFramesPerSecond) << 1
if KSOptions.preferredFrame {
let preferredFramesPerSecond = ceil(fps)
if #available(iOS 15.0, tvOS 15.0, macOS 14.0, *) {
displayLink.preferredFrameRateRange = CAFrameRateRange(minimum: preferredFramesPerSecond, maximum: 2 * preferredFramesPerSecond, __preferred: preferredFramesPerSecond)
} else {
displayLink.preferredFramesPerSecond = Int(preferredFramesPerSecond) << 1
}
}
options.updateVideo(refreshRate: fps, isDovi: isDovi, formatDescription: formatDescription)
}
Expand Down

0 comments on commit 6646ed9

Please sign in to comment.