Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 89864

Local html file as webview.source

$
0
0

Hello still learning here, I have a local html file it's already placed in the assets folder inside another foler called webview, I'm following the guide provided at https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/webview, basically I'm using it to show a background video since I couldn't find a better way to do so in android.

The example as I understand, provides a way to fill the WebView with an HtmlWebViewSource

        var browser = new WebView();
        var htmlSource = new HtmlWebViewSource();

        htmlSource.Html = @"<html>
                            <head>
                            <link rel=""stylesheet"" href=""default.css"">
                            </head>
                            <body>
                            <h1>Xamarin.Forms</h1>
                            <p>The CSS and image are loaded from local files!</p>
                            <img src='XamarinLogo.png'/>
                            <p><a href=""local.html"">next page</a></p>
                            </body>
                            </html>";

        htmlSource.BaseUrl = DependencyService.Get<IBaseUrl>().Get();
        browser.Source = htmlSource;
        Content = browser;

But I just need to do something like WebVideo.Source = Url + "rain" + ".html";
The url is just string Url = "webview/";

The BaseUrl_Android class is already at the android folder and if I use the url in such way it appears like a blank page, all assets are set as androidasset in it's properties
it seems I don't know how to use these lines:

    htmlSource.BaseUrl = DependencyService.Get<IBaseUrl>().Get();
        browser.Source = htmlSource;

Any pointer here will be reatly appreciatted, thanks.


Viewing all articles
Browse latest Browse all 89864

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>