我正在使用代码:
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"
}
]
答案 0 :(得分:0)
如果你无法播放youtube网址,那么你应该使用该视频的嵌入网址而不是youtube网址 普通的youtube网址:https://www.youtube.com/watch?v=9SdF_1OrN0Y 嵌入youtube网址:https://www.youtube.com/embed/9SdF_1OrN0Y
如果您不知道如何将youtube普通网址转换为嵌入网址,请参阅此网址Convert youtube url to iframe embed code
如果有任何疑问,请告诉我 快乐的编码:)