The new SwiftUI VideoPlayer

WWDC 2020 just happend and with it iOS 14 was announced, bringing new features such as the update of AVKit framework (The AVKit framework provides a high-level interface for playing video content).

At the current time, it’s not advised to switch to iOS14 and should wait for a few months for adoption, today the VidePlayer does not work correctly in the Simulator of XCode 11.5, the latest version available at the time of writing.

VideoPlayer(
  player: AVPlayer(
    url:  URL(string: "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4")
  )
)

Alternatively, to load a local file you’d do:

VideoPlayer(
  player: AVPlayer(
    url:  Bundle.main.url(forResource: "BigBuckBunny", withExtension: "mp4")
  )
)
comments powered by Disqus