So I'd like to play a Video in an Apple TV App.
I need to look into Player from the TVJS Lib.
Forum
https://forums.developer.apple.com/thread/17338?sr=stream&ru=377
https://forums.developer.apple.com/message/52011#52011
https://forums.developer.apple.com/message/53126#53126 I can play a Video using AVPlayer but need to look into the controls
[gist dac53c99670daddebd72 /]
application.js
function launchPlayer() {
var player = new Player();
var playlist = new Playlist();
var mediaItem = new MediaItem(
"video",
"http://trailers.apple.com/movies/focus_features/9/9-clip_480p.mov"
);
player.playlist = playlist;
player.playlist.push(mediaItem);
player.present();
}
//in application.js
App.onLaunch = function (options) {
launchPlayer();
};
PlayerViewController.m
NSString *filepath = [[NSBundle mainBundle] pathForResource:@"FILENAME" ofType:@"mp4"];
NSURL *fileURL = [NSURL fileURLWithPath:filepath];
self.avPlayer = [AVPlayer playerWithURL:fileURL];
AVPlayerLayer *layer = [AVPlayerLayer playerLayerWithPlayer:self.avPlayer];
self.avPlayer.actionAtItemEnd = AVPlayerActionAtItemEndNone;
layer.frame = CGRectMake(0, 0, 1024, 768);
[self.view.layer addSublayer: layer];
[self.avPlayer play];
I'd prefer to create the view using the TVML as the 'Compilation.xml' seems to be the perfect fit for it.
Trying out an idea for Apple TV with @599CD
— Alex Hedley (@AlexHedley) September 12, 2015
How would the Registration Seminar look?https://t.co/A8eFsx29Th pic.twitter.com/5jVGuGF22b
https://twitter.com/AlexHedley/status/642737644309487616/photo/1
Finally found out that the videos files can't be running under python.
If you change the URL to a file on the web it works fine.
http://stackoverflow.com/questions/32518673/setting-up-apple-tv-video-javascript
I think you're using the Python SimpleHTTPServer for your test, it did not worked for video streaming, but if you use Apache or for example this file directly from apple "http://trailers.apple.com/movies/focus_features/9/9-clip_480p.mov" it will work. user2418630
This is correct. I think video playback requires that the server supports, among other things, byte-range requests. – lemnar
Blogs
http://martinnormark.com/playing-video-on-apple-tv-with-tvos/