Can anyone help me with code for setting up and playing local videofile, using AVPlayer in Xcode? (using AVPlayerLayer, and AVPlayerViewController) All done programmatically and with standard/system videoskin?
Regards Henning
AVPlayer *player = [AVPlayer playerWithURL:"YOUR URL"];
// create a player view controller
AVPlayerViewController *controller = [[AVPlayerViewController alloc] init];
[self presentViewController:controller animated:YES completion:nil];
controller.player = player;
[player play];
hope this help for you.....
// remote file from server:
NSURL *url = [[NSURL alloc] initWithString:@"https://s3-eu-west-1.amazonaws.com/alf-proeysen/Bakvendtland-MASTER.mp4"];
// create a player view controller
player = [AVPlayer playerWithURL:url];
AVPlayerViewController *controller = [[AVPlayerViewController alloc] init];
[self addChildViewController:controller];
[self.view addSubview:controller.view];
controller.view.frame = CGRectMake(50,50,500,300);
controller.player = player;
controller.showsPlaybackControls = YES;
player.closedCaptionDisplayEnabled = NO;
[player pause];
[player play];
This is all done in viewDidLoad
and its working fine now. I made a subview to present the player.
The only thing that is not working now is player.closedCaptionDisplayEnabled = NO;
this is ignored. The video has soft subtitles embedded, and I am able to toggle the subtitles with cc button that is showing. But I am not able to toggle it/control it programmatically?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With