kingslay / KSPlayer

A video player for iOS、macOS、tvOS、visionOS , based on AVPlayer and FFmpeg, support the horizontal, vertical screen. support adjust volume, brightness and seek by slide, support subtitles.
GNU General Public License v3.0
886 stars 184 forks source link

A small Frame Rate Matching bug #642

Closed chillout23 closed 8 months ago

chillout23 commented 8 months ago

tvOS:

In Tracy Player and other apps where KSPlayer is used, frame rate matching is working fine but;

If you open stream = frame rate matches. If you exit stream = frame rate goes back to default. If you open same stream again in 1-2 second (quickly) = framerate does not match. Note: It works again if I wait 5-10 seconds or more.

Frame rate matching in KSPlayer is sensitive to how quickly you exit / enter stream.

Sounds maybe like a quick fix @kingslay if you can look into it.

kingslay commented 8 months ago

有这么奇怪的问题啊。你可以看下第二次快速进入的时候,有没有调用
displayManager.preferredDisplayCriteria = AVDisplayCriteria(refreshRate: refreshRate, videoDynamicRange: dynamicRange.rawValue) 这个方法。并且看下是不是 下面这个方法太晚调用了。导致设置的值被清空了。这个方法是在deinit的时候调用的。所以无法控制时间点。

open func playerLayerDeinit() {
        #if os(tvOS) || os(xrOS)
        UIApplication.shared.windows.first?.avDisplayManager.preferredDisplayCriteria = nil
        #endif
    }
chillout23 commented 8 months ago

Thanks @kingslay, were you able to reproduce this yourself by doing the steps?

chillout23 commented 8 months ago

@kingslay very elegant way to fix this, now it's 100% stable - well done!