Example of how to use the TVJS Player object

I've been experimenting with creating an app using TVML, and have pretty good success creating templates and navigating between them. Now I am trying to play a video when clicking on a button. I am trying to use the Player class, but have not had any luck. I read that all video must be done via HLS, so I tried using the sampe .m3u8 provided by apple (https://developer.apple.com/streaming/examples/). When trying to call present() or play() on the player I am getting a slew of NSLayoutConstraint errors, followed by:


objc[86101]: Cannot form weak reference to instance (0x7fe3c2aeecd0) of class AVAssetMediaSelectionGroup. It is possible that this object was over-released, or is in the process of deallocation.


As a side note, the app is swift based, so I *think* this is something buggy in the framework...?

Answered by dbireta in 53728022

Oh, wow. Fantastic tip! I had been trying some other Apple samples (http://stackoverflow.com/questions/10104301/hls-streaming-video-url-need-for-testing) and wasn't having any luck! Thanks so much!

Hmm. This doesn't look right. Could you file a bug at bugreport.apple.com against tvOS SDK?


Include your syslogs and if you have a project (sounds like you do), add it too!

Do you any templates on stack prior to presenting the player?

Are you using local files with python?

python -m SimpleHTTPServer 8000


If you want to view videos make sure they are linked to another server, it looks like video playback requires that the server supports, among other things, byte-range requests.

http://stackoverflow.com/questions/32518673/setting-up-apple-tv-video-javascript

Accepted Answer

Oh, wow. Fantastic tip! I had been trying some other Apple samples (http://stackoverflow.com/questions/10104301/hls-streaming-video-url-need-for-testing) and wasn't having any luck! Thanks so much!

Can't take the credit, but I'm glad I found it on SO. Was wondering why it was working for a while.

has anyone had any luck getting HLS assets to play throught the javascript handler? The below example works for mp4 files but kills the TVOS app when attempting to load valid HLS m3u8 manafests.


  
var player = new Player();
var playlist = new Playlist();
var mediaItem = new MediaItem("type", "video");
var mediaItem = new MediaItem("url", "http://<url>");
player.playlist = playlist;
player.playlist.push(mediaItem);
player.present();

It's a known issue, it crashes the sim https://forums.developer.apple.com/message/53063#53063 ( Have you tried .play() instead of .present() )

Thanks Alex for the link to the bug report, good thing my ATV Developer Kit will be here today! I did indeed also try play() but it ***** as well.


Sean

Confirming that calling a HLS using the above javascript code works fine when running on an ATV and not through the simulator

Example of how to use the TVJS Player object
 
 
Q