AVPlayer for server live content not working without extension

62 Views Asked by At

Thanks for taking your time to help others.

Problem description:

I would like to play LIVE content from server link, without an extension in native SwiftUI player. Server link follows this pattern:

http://****flix.com:8080/username/password/channel

I can't play an IPTV server link on SwiftUI

What I have checked?

Simple implementation of AVPlayer with link. (Not real data as involves credentials)

import SwiftUI
import AVKit

struct ContentView: View {
    let liveContentOK = URL(string: "https://ztnr.rtve.es/ztnr/1688877.m3u8")!
    let liveContentNotWorking = URL(string: "http://****flix.com:8080/username/password/channel")!

    var body: some View {
        VideoPlayer(player: AVPlayer(url: liveContent))
    }
}

#Preview {
    ContentView()
}
  • I didn't forget to allow arbitrary loads, as is the only way to handle http content.

As well, I tried on this VLC implementation, and it works with my IPTV link. BUT, the idea was to include this on a companies App so license is not valid. That's why I want to use something native, as AVPlayer.

In this repo you can find m3u8 links that currently works on AVPlayer too. But those are the easy ones, no authentication, has extension, etc.

Just in case, I also did tried to play the link appending .m3u8 and .ts extensions, with no result.

A comparison working - not working

So, this link does NOT work: http://****flix.com:8080/username/password/channel

And this other link do work: https://ztnr.rtve.es/ztnr/1688877.m3u8

Differences I see?

  • Is https (should be covered with arbitrary loads)
  • Has an extension (I think that's not the problem)
  • Non working link has a port 8080, that... I might handle?
  • Has user authentication? Maybe that's the problem?

Questions

  1. Why is AVPlayer not able to play content? Do I have to handle decoding?
  2. Is the port 8080 important? Should I attend that separately on AVPlayer?
  3. Do I have to handle authentication? How?
0

There are 0 best solutions below