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
869 stars 184 forks source link

Player opens then instantly closes #728

Closed porter707 closed 5 months ago

porter707 commented 5 months ago

Hi,

I'm not sure what I'm missing. When trying to use the KSVideoPlayerView the view opens and then instantly closes.

I have these messages in the log:

warning KSPlayer: KSMEPlayer.swift:375 prepareToPlay() | prepareToPlay <KSPlayer.KSMEPlayer: 0x2836fec40>
warning KSPlayer: KSMEPlayer.swift:390 pause() | pause <KSPlayer.KSMEPlayer: 0x2836fec40>
warning KSPlayer: KSPlayerLayer.swift:141 state | playerStateDidChange - paused
[MRNowPlaying] Ignoring setPlaybackState because application does not contain entitlement com.apple.mediaremote.set-playback-state for platform

I'm using the following code:

struct PlayerView: View {

    var streamURL: URL

    let options = KSOptions()

    init(streamURL: URL) {
        self.streamURL = streamURL
        options.isAutoPlay = true
        options.videoAdaptable = true
    }

    var body: some View {
        ZStack {
            KSVideoPlayerView(url: streamURL, options: options)
        }
    }
}

I also have the following set:

KSOptions.logLevel = .debug
KSOptions.firstPlayerType = KSMEPlayer.self
KSOptions.secondPlayerType = KSMEPlayer.self

The stream I'm trying to play does work in the example SwiftUI demo.