Start playback when stream is accessible
I'm trying to develop an app for tvOS for my organization that tunes into a multicast RTP stream (via a SDP file) and plays it back. The Apple TVs that this app will be installed on are not easily accessible (mounted behind TVs on the wall) and will be used as digital signage devices. I'm trying to make this application completely foolproof. I'll lock the Apple TVs into this app on single app mode, and I'm trying to configure my app to auto-recover if the network, stream, or power to the device goes down.
As my code currently stands, if the stream or network goes down, the Apple TVs will reestablish the connection as soon as it comes back up. If the Apple TV loses power, it will automatically go back into the app and start streaming when power is applied. The only issue I am continuing to have is that if the stream or network is down upon app launch, when it comes back up, playback does not start. The Apple TV continues to display a black screen. In debugging, I've discovered that VLC reports that it is playing, but the media has no video output.
I've tried launching VLC with the loop argument, which works for the same application on a Windows PC. I've also tried adding these arguments and it has still not fixed this issue:
--rtp-timeout=-1 --rtsp-session-timeout=-1 --repeat --http-reconnect
I'm not sure why this is behaving differently on the Apple TVs than it is on Windows. If I launch VLC with the loop argument on Windows, VLC will continuously try to start the stream until it works. Is there a way I can duplicate this in my app with VLCkit?
Here is a nice chunk of the code in case I made an error here, or if this helps at all.
` import UIKit
class ViewController: UIViewController {
var videoView: UIView!
private var mediaPlayer: VLCMediaPlayer!
override func viewDidLoad() {
super.viewDidLoad()
/* defines sdp.sdp as file source for 'urlpath'*/
let urlpath = Bundle.main.path(forResource: "sdp", ofType: "sdp")
let initOptions: NSArray = ["--loop", "--rtp-timeout=0"]
videoView = UIView(frame: view.bounds)
mediaPlayer = VLCMediaPlayer(options : (initOptions as! [Any]))
mediaPlayer.drawable = view
mediaPlayer.media = VLCMedia(url: URL(fileURLWithPath: urlpath!))
/* comment the line above to disable local SDP file */
/* and uncomment below line to use file at specified URL */
/* begins playback and calls nightly restart function after 30s */
let launchDelay = 1.0
DispatchQueue.main.asyncAfter(deadline: .now() + launchDelay) {
self.mediaPlayer.play()
self.autoRestart()
}
}
`