Playing youtube videos on iOS

2019-02-17 03:29发布

问题:

I was wondering how are apps like McTube (https://itunes.apple.com/us/app/mctube-for-youtube/id559618284?mt=8) playing youtube videos. It looks like a custom MPMoviePlayerController but is that allowed?

BTW I need autoplay which I couldn't achieve with UIWebView, that's why i was wondering.

回答1:

Some YouTube videos can be played back in a MPMoviePlayerController - some cannot. When you query a video through the YouTube Data API (link here) you'll get back all the content types available for a particular videos, including the Flash player, 3GPP, MP4 (if available), etc. You can use these URLs to load up a MPMoviePlayerController.

This is perfectly fine, but as I've said - not all videos are available to embed this way. Some videos (mainly ones that require adverts to be displayed) can't be put into native controllers.