Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
591 views
in Technique[技术] by (71.8m points)

ios - MPMoviePlayerController is playing YouTube video?

I found a method to play YouTube video on MPMoviePlayerController. For this simply need a right url. That url may be obtained after playing YouTube video in iframe. My UIWebView uses this html:

<html> 
<head> 
</head> 
<body style="margin:0"> 
    <iframe class="youtube-player" type="text/html" width="280" 
        height="200" src="http://www.youtube.com/embed/VJRKaQ52ImE" 
        frameborder="0"> 
    </iframe> 
</body> 

So after click on play in video rect, we can see msg in console like this:

YT_Player[1520:207] setting movie path: http://v12.lscache4.c.youtube.com/videoplayback?sparams=id%2Cexpire%2Cip%2Cipbits%2Citag%2Cratebypass%2Coc%3AU0hQR1NLVl9FSkNOMF9LRVpB&fexp=913518%2C904531%2C910211&itag=18&ip=0.0.0.0&signature=93772DDEDFE678D8EA1A2E4669B5634BD6D4E81E.58DEF5203DEF07FB75F762D6C9C39536C84DE59C&sver=3&ratebypass=yes&expire=1312308000&key=yt1&ipbits=0&id=54944a690e762261

So here the question is - how get YT_Player object or how to generate "right" url?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

There is no official API to get the "right" url, and likely there never will be. See the following link on the bottom.

http://groups.google.com/group/youtube-api-gdata/browse_thread/thread/394c41dda8b4745a

Note that your method based on UIWebView does not play the movie in MPMoviePlayerController, but rather in a custom class called YTMoviePlayer. You can confirm it by playing a movie and then dumping the subview hierarchy starting at [[UIApplication sharedApplication] keyWindow].


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...