How to play youtube video without UIWebView or det

2020-07-10 11:42发布

I need to play youtube video in my iOS application and while video is playing I need to add an overlay on video.

1.Now how can i run youtube video in native player?

2.if I play video in UIWebview then how can i detect that video is playing and how to add overlay on the video?

2条回答
【Aperson】
2楼-- · 2020-07-10 11:52

MPMoviePlayerViewController cannot directly play youtube video urls.You need to extract the url before loading MPMoviePlayerViewController with the url.

you can see a working demo in my github repo:

Try this:: https://github.com/DpzAtMicRO/IOSYoutubePlayer

LBYoutubeExtractor extracts the youtube Url with JSON.
Please do read the README.md before you use this in your application.

Regards

查看更多
太酷不给撩
3楼-- · 2020-07-10 12:03

MPMoviePlayerViewController is a good one but last commit is years ago. I found another solution called 'XCDYouTubeKit' which supports iPhone/iPad and iOS7 onwards with full screen YouTube video.

You can access github page at here and fully documented tutorial at here

This is what official developer says in his page:

The only official way of playing a YouTube video inside an app is with a web view and the iframe player API. Unfortunately, this is very slow and quite ugly, so I wrote this player to give users a better viewing experience.

查看更多
登录 后发表回答