how set width and height youtube video when we have open video and then full screen or portrait mode

Answers

  • ColeXColeX Member, Xamarin Team Xamurai
    edited August 21

    If i understand correctly , do you mean you want to set width and height in landscape mode but full screen in portrait mode ?

    BTW , what's the videoplayer are you using now ? Custom video player implement by yourself or some third-party package ?

  • sandy3080sandy3080 Member ✭✭
    Colex sir, which nuget package for playing video in xamrin form
  • sandy3080sandy3080 Member ✭✭
    Now I am use webview and embedded YouTube link
  • sandy3080sandy3080 Member ✭✭
    I have set width 300 and height 600 but when we rotate mobile then this time not change width and height any solution???any nuget package for YouTube embedded?or how to open YouTube video full screen
  • sandy3080sandy3080 Member ✭✭

    private void PlayVideo(LiveMatch liveMatch)
    {

                HtmlWebViewSource htmlWebViewSource = new HtmlWebViewSource();
                htmlWebViewSource.Html = BuildFinalHtml(liveMatch.Link, width:300, height:700 );
                webView.Source = htmlWebViewSource;
    
        }
    
        private string BuildFinalHtml(string embedUrl, double width, double height)
        {
            //var width = Application.Current.MainPage.Width;
            //var height = Application.Current.MainPage.Height;
            var iframeURL = string.Format("<iframe style=\"position:fixed; top: 50%; left: 50%;" +
          " width:"+" {1}px; height: {2}px; margin-left: {3}px; margin-top: {4}px;\"" +" src =\"{0}\" frameborder=\"0\" " + "allow=\"accelerometer;" +
          " autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen></iframe>",
                embedUrl, width, height, -width / 2, -height / 2);
            string finalUrl = string.Format("<html><body>{0}</body></html>", iframeURL);
            return finalUrl;
        }
    
  • sandy3080sandy3080 Member ✭✭

    sir this is video player it cant take youtube video embeded link ,it access only resourse. i want to -----when i open my project list of youtube links any link click open youtube lint this app and full screen

  • sandy3080sandy3080 Member ✭✭

    now use webview but it not able to full screen and portrate mode and landscape mode

  • ColeXColeX Member, Xamarin Team Xamurai
    edited August 28

    If you are developing on android platform , check the solution :https://stackoverflow.com/a/50103945/8187800 .

    Use custom renderer for webview ,and set custom WebChromeClient on Webview , detailed code refer : https://github.com/mhaggag/XFAndroidFullScreenWebView

Sign In or Register to comment.