Search code examples
swiftavfoundationmedia-playeravkit

Black Screen when stream video with avkit


Hi I want to stream remote video on my app. URL is: http://test.ext/myvideo.mkv

I use AVKit with this code but screen and audio not works. I see only progress bar that go forward.

         let player = AVPlayer(url: url)

        // Create a new AVPlayerViewController and pass it a reference to the player.
        let controller = AVPlayerViewController()
        controller.player = player
        controller.player?.automaticallyWaitsToMinimizeStalling = false
        controller.player?.playImmediately(atRate: 1.0)


        // Modally present the player and call the player's play() method when complete.
        self.present(controller, animated: true) {
                player.play()
        }

Solution

  • AVPlayer don't support mkv video format.

    Anyone have a solution for playing all video format ?

    I've tested MobileVLCKit but it's too heavy (1,5Go)...