1

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 ?

Jopolaz
  • 402
  • 1
  • 3
  • 18
  • Do you know what's the video format you're trying to play? – Jorge Feb 10 '20 at 16:37
  • Format is mpegts. Video is h264 compressed. And http mime-type is mp2ts – Jopolaz Feb 10 '20 at 19:22
  • I'm not sure if that format is compatible with `AVPlayer` out of the box. You might need a custom parser for it. According to the `AVURLAsset` documentation, the audioVisualTypes method doesn't return the one you're trying to play. – Jorge Feb 10 '20 at 19:29
  • I saw this https://stackoverflow.com/questions/21879981/avfoundation-avplayer-supported-formats-no-vob-or-mpg-containers , but I just try on iphone and I think like you that’s It’s note supported. I don’t want to use third part lib to success but I’m confused. If you have a hint ? – Jopolaz Feb 10 '20 at 20:43
  • The step I’m missing is to fragment my mpeg-ts to HLS. – Jopolaz Feb 10 '20 at 20:50

1 Answers1

1

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.

Jopolaz
  • 402
  • 1
  • 3
  • 18