Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Single Youtube Video Embedding in Xamarin Forms but Not Youtube list

I want to integrate a Youtube Video in a Xamarin.forms Application.

Currently i have googled and found the following links:

https://www.thewissen.io/embedding-youtube-feed-xamarin-forms/

XAMARIN - add video from youtube

but they deal with only Youtube lists , but not a single Youtube video.

I would like a single Video which isn't played in a WebView

How can i tackle this?


2 Answers

HtmlWebViewSource personHtmlSource = new HtmlWebViewSource();
personHtmlSource.SetBinding(HtmlWebViewSource.HtmlProperty, "HTMLDesc");
personHtmlSource.Html = @"<html><body>  <div style=' position: relative; padding-bottom: 56.25%; padding-top: 25px;'> <iframe style='position: absolute; top: 0; left: 0; width: 100%; height: 100%;'  src='https://www.youtube.com/embed/bVdfj7HXuXE' frameborder='0' allowfullscreen></iframe></div> </body></html>";
var browser = new WebView();
browser.Source = personHtmlSource;
Content = browser;
like image 157
Mridul Malviya Avatar answered Jan 23 '26 15:01

Mridul Malviya


Just do this!!

<WebView VerticalOptions="FillAndExpand"
        HorizontalOptions="FillAndExpand"
        Source="https://www.youtube.com/embed/8azMAqsuHs0"
        WidthRequest="500"
        HeightRequest="500"
        IsVisible="true"/>

Remember setting width and height is necessary, otherwise it will not show!

Best Regards

like image 30
MarchalPT Avatar answered Jan 23 '26 15:01

MarchalPT



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!