0

i need some help with playing stream on really simple ios app which i've made but i can load the stream into the browser and there won't be any problem, but when i try to load it into the ios app its only loading and i don't know what i did wrong. url of the stream: https://tv1.cdn.netbadgers.com

ViewController.swift

import UIKit
import AVKit
import AVFoundation

class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
    }
    @IBAction func playBroadcastClicked(_ sender: Any) {
        let videoURL = URL(string: "https://tv1.cdn.netbadgers.com")
        let player = AVPlayer(url: videoURL!)
        let playerViewController = AVPlayerViewController()
        playerViewController.player = player
        self.present(playerViewController, animated:true) {
            playerViewController.player!.play()
        }
    }
}
Rumen
  • 57
  • 1
  • 11

1 Answers1

2

You url is not pointing to a video file, it is actually a HTML page with a video which will never play in the iOS AVPlayer.

Find the direct link to the video, also, make sure the video is in a supported format. If you want a quick solution, just add a WKWebView to your ViewController and then load your url.

  • Thanks for the answer i looked into the html and it is actually loading this url ```blob:https://tv1.cdn.netbadgers.com/77420244-ee7b-439d-a864-4eb748c920a7``` but it doesn't play on the app as well. no idea what i have to do – Rumen Jan 26 '20 at 19:02
  • 1
    @Rumen Read up on blob URLs and how to find the m3u8 URL here: https://stackoverflow.com/questions/42901942/how-do-we-download-a-blob-url-video . I was able to install [this Chrome extension](https://chrome.google.com/webstore/detail/hls-downloader/apomkbibleomoihlhhdbeghnfioffbej/related?hl=en) which allowed me to find the m3u8 URL for your video, which I believe is: https://tv1.cdn.netbadgers.com/bg060/bg061/bg061.m3u8 – TylerP Jan 27 '20 at 01:27