【发布时间】:2018-01-31 08:19:31
【问题描述】:
我正在使用代码:
moviePlayer = new MPMoviePlayerController(new NSUrl("https://www.youtube.com/watch?v=9SdF_1OrN0Y"));
moviePlayer.View.Frame = new RectangleF(10, 80, 300, 200);
moviePlayer.View.BackgroundColor = UIColor.Clear;
moviePlayer.SourceType = MPMovieSourceType.File;
//moviePlayer.SetFullscreen(true,true);
moviePlayer.Fullscreen = true;
// Set this property True if you want the video to be auto played on page load
moviePlayer.ShouldAutoplay = true;
// If you want to keep the Video player on-ready-to-play state, then enable this
// This will keep the video content loaded from the URL, untill you play it.
moviePlayer.PrepareToPlay();
// Enable the embeded video controls of the Video Player, this has several types of Embedded controls for you to choose
moviePlayer.ControlStyle = MPMovieControlStyle.Default;
View.AddSubview(moviePlayer.View);
添加代码后
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>clips.vorwaerts-gmbh.de</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
</dict>
</dict>
我可以使用以下网址播放视频: http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4
如何播放来自 API 响应的 YouTube 视频?
[
{
"VideoId": 1,
"VideoTitle": "Selena Gomez testimony hillsong conference 2017",
"VideoUrl": "https://www.youtube.com/watch?v=9SdF_1OrN0Y"
}
]
【问题讨论】:
-
Youtube 不支持“直接”嵌入流。有非官方的 3rd-party 库可用,但它们违反了 Google 的 TOS。您应该查看官方文档以了解如何在您的应用程序的嵌入式 Web 视图中播放 Youtube 视频:developers.google.com/youtube/v3/guides/ios_youtube_helper
-
@sushihangover 下面的链接提供了一种在 ios 应用程序中播放 youtube 视频的方法,所以我希望在 Xamarin.iOS 中使用类似的方法 stackoverflow.com/questions/1779511/…
-
是的,这些答案中的大多数都使用了违反 Google 服务条款的方法,如果这是您想要做的,请使用现有答案之一,而不是使用uiwebview 就像官方文档展示的一样
-
请阅读Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers? - 总结是这不是解决志愿者的理想方式,并且可能会适得其反。请不要将此添加到您的问题中。
标签: ios xamarin xamarin.ios