MPMoviePlayerController 正在播放 YouTube 视频吗?
我找到了一种在 MPMoviePlayerController 上播放 YouTube 视频的方法。为此只需要一个正确的网址。在 iframe 中播放 YouTube 视频后可以获取该 url。我的 UIWebView 使用 这个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>
因此,在视频矩形中单击“播放”后,我们可以在控制台中看到如下消息:
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
所以这里的问题是 - 如何获取 YT_Player 对象或如何生成“正确”的 url?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
没有官方 API 可以获取“正确”的 URL,而且很可能永远不会有。请参阅底部的以下链接。
http://groups.google.com/group/youtube-api -gdata/browse_thread/thread/394c41dda8b4745a
请注意,您基于 UIWebView 的方法不会播放电影MPMoviePlayerController,而是在名为 YTMoviePlayer 的自定义类中。您可以通过播放电影然后转储从 [[UIApplication sharedApplication] keyWindow] 开始的子视图层次结构来确认这一点。
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].
对我来说这个图书馆确实工作得很好!
https://github.com/hellozimi/HCYoutubeParser
For me this library did work perfectly!
https://github.com/hellozimi/HCYoutubeParser