Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XAMARIN - add video from youtube

i search information how to add video from youtube, example: I want add video from some youtube link. I think that it should be in webview, but i need some details, because i can't find any information about my problem.

like image 456
cniak Avatar asked Oct 01 '22 10:10

cniak


1 Answers

You can use the webview to play youtube video.

    string html=@"<html><body><iframe width=""200"" height=""400"" src=""strUrl""></iframe></body></html>"; 
            var myWebView = ( WebView ) FindViewById ( Resource.Id.myWebView );  
            var settings=myWebView.Settings; 
            settings.JavaScriptEnabled=true;
            settings.UseWideViewPort=true;  
            settings.LoadWithOverviewMode=true;
            settings.JavaScriptCanOpenWindowsAutomatically=true; 
            settings.DomStorageEnabled=true;
            settings.SetRenderPriority(WebSettings.RenderPriority.High); 
            settings.BuiltInZoomControls = false; 
            settings.JavaScriptCanOpenWindowsAutomatically=true;
            myWebView.SetWebChromeClient(new WebChromeClient());
            settings.AllowFileAccess = true;
            settings.SetPluginState(WebSettings.PluginState.On);  

            myWebView.LoadDataWithBaseURL(null,html,"text/html","UTF-8",null); 

Add internet permission in manifest file and enable hardwareAccelerated="true". Follow this my blog entry for more detail : http://appliedcodelog.blogspot.in/2015/09/how-to-play-youtube-video-using-webview.html

like image 151
Suchith Avatar answered Oct 13 '22 10:10

Suchith