Search code examples
swiftavfoundationhttp-live-streamingiptv

HTTP Live streaming is not readable and not work in AVPlayer Swift


I am just trying to play network stream in AVPlayer. I can't share the link but this is some informations about :

stream infos

And the code :

let asset = AVAsset(url: inUrl)
let playerItem = AVPlayerItem(asset: asset)
let playern = AVPlayer(playerItem: playerItem)

print("playable = \(asset.isReadable)") // => false

playern.allowsExternalPlayback = true
playern.play()

Is there something that I'm missing ?


Solution

  • The step I’m missing was to fragment my mpeg-ts to HLS because AVPlayer can't read my stream.

    I finally chose to use MobileVLCKit (https://code.videolan.org/videolan/VLCKit) which provide VLCMediaPlayer natively play my network stream.