you will need to supply a custom file provider:
In a .NET Maui Blazor application, can you play a video (using the video HTML5 element) by pointing the source attribute directly to the path of a video file on the user's file system?
I have a .NET Maui Blazor application and want to play an mp4 video within a razor page of the application by pointing the source of the HTML5 video element directly to the path of the video file on the user's file system, but can't get it to work. Is this possible?
When I include the mp4 video file in the actual .NET Maui Blazor project (under wwwroot/videos) and then point the HTML5 video element to it then the video plays. But this is not my requirement. I want the user to select the video file (using FilePicker) and then play the video inside the .NET Maui Blazor application.
This works (where the testvideo.mp4 file is included in the project under wwwroot/videos):
<video controls="controls" width="800px" height="462px">
<source src="videos/testvideo.mp4" type="video/mp4">
</video>
This does not work:
<video controls="controls" width="800px" height="462px">
<source src="C:\videos\testvideo.mp4" type="video/mp4">
</video>
This does not work either:
<video controls="controls" width="800px" height="462px">
<source src="C:/videos/testvideo.mp4" type="video/mp4">
</video>
2 answers
Sort by: Most helpful
-
-
Mahdi Rastegari 0 Reputation points
2023-10-23T20:52:13.37+00:00 The answer is simple by the general rules of the browser, they don't have access to file storage directly. it would help if you used the input (HTML element) to select the file rather than the machine or robot. it does make sense as I don't want browser access to my data.
but the question is, should BlazorWebView also have this policy? is there any way to bypass it?