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, SwiftUI, support subtitles.
https://apps.apple.com/app/tracyplayer/id6450770064
GNU General Public License v3.0
984 stars 197 forks source link

Can set video, audio and subtitles track before playing #661

Closed skrew closed 10 months ago

skrew commented 10 months ago

Is your feature request related to a problem? Please describe.

User can select a track (eg, audio track) and want to have it selected immediately when playing the same file again. Setting the selected tracks after file loading make a freeze because the track are changed 1,2 or 3 times (for audio, sub or video).

Describe the solution you'd like

Like MEOoptions.startPlayTime, an option the set the wanted track number at start, instead of default one. As the file can change over the time, you have to check if the track exists before forcing it (to avoid crashs)

kingslay commented 10 months ago

音频和视频可以通过这个来选择,


    ///  wanted video stream index, or nil for automatic selection
    /// - Parameter : video bitRate
    /// - Returns: The index of the bitRates
    open func wantedVideo(bitRates _: [Int64]) -> Int? {
        nil
    }

    /// wanted audio stream index, or nil for automatic selection
    /// - Parameter :  audio bitRate and language
    /// - Returns: The index of the infos
    open func wantedAudio(infos _: [(bitRate: Int64, language: String?)]) -> Int? {
        nil
    }

字幕的话,你可以在 player(layer: KSPlayerLayer, state: KSPlayerState) 这个方法进行选择

nazar-41 commented 10 months ago

@kingslay how to switch video track to auto while video is playing in (swiftUI)