Did you check the comment of the CreateFileProvider
method? It is used to call into the platform-specific code to get that platform's asset file provider not the local storage file.
Actually, for the android webview, the scr for the loacl stroage file usually is such as file:\\\xxx\xxx\xxx
and so on. But this is not work for the blazor webview. You can report this as a new issue on the repo.
And for a workaround, you can set the source for the video by the JS function on the android platform.
Give an id
to the video:
<video id="video" controls="" style="width:100%;" controlslist="nodownload"><source src="/VideoContent/MyVideo.mp4"></video>
Declare the js function in the index.html:
<script> async function playvideo(videoId, videoStream) { const arrayBuffer = await videoStream.arrayBuffer(); const blob = new Blob([arrayBuffer]); const url = URL.createObjectURL(blob); document.getElementById(videoId).src = url; }</script>
Override the OnInitializedAsync()
method:
@inject IJSRuntime js;...protected override async Task OnInitializedAsync() { #if ANDROID using(var steam = new FileStream("/data/user/0/com.mypackage.whatever/files/Content/VideoContent/MyVideo.mp4", FileMode.Open, FileAccess.Read, FileShare.None)) { var dotnetstream = new DotNetStreamReference(steam); await js.InvokeVoidAsync("playvideo", "video", dotnetstream); } #endif }