I am trying to play HLS feed in my app using MPMoviePlayerController using Swift.
I am using this below code to play the stream
var url:NSURL = NSURL(string: "streamurl")!
self.moviePlayer = MPMoviePlayerController()
self.moviePlayer.movieSourceType = MPMovieSourceType.Streaming
self.moviePlayer = MPMoviePlayerController(contentURL: url)
self.moviePlayer.prepareToPlay()
self.moviePlayer.shouldAutoplay = true
self.moviePlayer.stop()
self.moviePlayer.view.frame = self.view.bounds
self.view.addSubview(self.moviePlayer.view)
self.moviePlayer.fullscreen = true
self.moviePlayer.setFullscreen(true, animated: true)
self.moviePlayer.controlStyle = MPMovieControlStyle.Embedded
self.moviePlayer.scalingMode = MPMovieScalingMode.AspectFit
self.moviePlayer.play()
My concern is how do I know if live stream is on air or not so that I would inform the user that its not available now.
Hi you can use media server's api to check the stream online status or you can read the content of the m3u8 file is should contain video bit rate and audio bit rate details if the stream is online. i prefer to use the media server api by sending a web request before playing the url.
there is one media server (nimble) offering a service called dispersa
(https://wmspanel.com/dispersa)
which give api access to check the stream status