有些youtube视频正在运行,有些还没有正常工作。所有在youtube上工作正常,但在我的应用中发生问题。 这是我的代码:
string url = "https://www.youtube.com/watch?v=" + AppSettings.YoutubeUri;
AppSettings.LinkUrl = url;
AppSettings.LinkUrl=AppSettings.LinkUrl.Replace("&hl=en&fs=1&rel=0", "").Replace("http://www.youtube.com/v/", "http://www.youtube.com/watch?v=");
System.Net.WebClient wc = new System.Net.WebClient ();
string _html = wc.DownloadString(AppSettings.LinkUrl);
AppSettings.YoutubeUri=DownloadManagerHelper.GetYotubeUrl(_html);
webView.MediaPlaybackRequiresUserAction = false;
webView.MediaPlaybackAllowsAirPlay = true;
webView.ScalesPageToFit=true;
webView = new UIWebView (View.Bounds);
webView.LoadRequest (new NSUrlRequest (new NSUrl (AppSettings.YoutubeUri)));
View.AddSubview (webView);
所以如何解决这个问题请帮助解决这个问题。
答案 0 :(得分:0)
YTPlayer是我在iOS中用于播放YouTube视频的控件。您可以尝试this for Xamarin。
希望有所帮助!
修改强>
// Youtube video ID
NSString *videoId = @"M7lc1UVf-VE";
// For a full list of player parameters, see the documentation for the HTML5 player
// at: https://developers.google.com/youtube/player_parameters?playerVersion=HTML5
NSDictionary *playerVars = @{
@"controls" : @0,
@"playsinline" : @1,
@"autohide" : @1,
@"showinfo" : @0,
@"modestbranding" : @1
};
// Pass video id to YTPlayerView object, and pass parameters to it
[self.playerView loadWithVideoId:videoId playerVars:playerVars];