How to automatically play a local MP4 file using WebView2 in Windows 10?

john zyd 421 Reputation points
2021-12-16T10:42:36.057+00:00

Hello:
I have a number of MP4 files in my local hard drive. I want to play them automatically in WebView2.
How I can do this?
For example, I have one MP4 file: C:\Video2\1.mp4.
I can launch ME Edge, and press Ctrl-O to open this mp4 file and play it in Edge.
I want to do the same in a WinForm app. I can add one button (Button1), and if I click on Button1, then I want to launch WebView2 and begin to play the MP4 file. I can use both VS 2019 and VS 2022.
Please advise!

Developer technologies | C#
Developer technologies | C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
0 comments No comments
{count} votes

Answer accepted by question author
  1. Castorix31 91,506 Reputation points
    2021-12-16T10:52:17.91+00:00

    This simple test plays a .mp4 file :

     webView2.Source = new Uri(@"E:\Gravity - 2K Trailer.mp4");
    
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.