i have code with youtube auto play , but now requirement is to play Vimeo videos in autoplay. I used to write code in objective c can u give any example codes fit to this requirement? note:i used third party tool name as "MPMoviePlayerViewController"
Asked
Active
Viewed 558 times
1 Answers
1
The MPMoviePLayerViewController class has been deprecated in iOS 9. Apple recommend using AVPLayerViewController instead - it works well with local and remote URLs.
Here's how you can use it in Objective-C:
// grab your remote URL
NSURL *videoURL = [NSURL URLWithString:@"http://domain.com/video.mp4"];
// create an AVPlayer
AVPlayer *player = [AVPlayer playerWithURL:videoURL];
// create a player view controller
AVPlayerViewController *controller = [[AVPlayerViewController alloc]init];
controller.player = player;
[player play];
// show the view controller
[self addChildViewController:controller];
[self.view addSubview:controller.view];
controller.view.frame = self.view.frame;
You must import AVFoundation and AVKit into your class for this to be successful.

Jay Versluis
- 2,062
- 1
- 19
- 18