I've encountered this problem: I've just started to learn ASP.NET, created a simple application, and I need to play a video on one of the pages, here is a code in cshtml:
@{
ViewBag.Title = "Player";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<video width="1020" height="780" controls="controls">
<source src="file:///E:/Video/ActCAM/test2.mp4" type="video/mp4"/>
</video>
<h2>Player</h2>
And, unfortunately, I see just a black box with a few controls on it which don't work, instead of a video. (I found a similar question html5 video is not playing mp4 error "Invalid Source"? , but that didn't work for me) I've specified a file on the local PC just for testing, web-application is also running on a local machine. However, if I change "file:///E:/Video/ActCAM/test2.mp4" type="video/mp4"
to something like this: http://techslides.com/demos/sample-videos/small.mp4
(it's just a sample free video found on the internet), it works fine. Also, if I create just a simple HTML file with the following code:
<video width="1020" height="780" controls="controls">
<source src="file:///E:/Video/ActCAM/test2.mp4" type="video/mp4"/>
</video>
it works fine. Please, help me!
I guess it is running perfectly on local because in that case your browser and the server are in the same machine. So, the path file:///E:/Video/ActCAM/test2.mp4 works fine.
However, when you publish the application in a real Web server, this path should be accessible by the browser. So, the video file should have a valid URL using http or https protocol.
So, once the application is published, that path in the frontend for the video (and other media types) should be not a physical path, but a virtual one (mydomain.com/video/myVideo.mp4)
I've figured out what was a reason of my problem, thank you very much @Dai and @Alexandre F. Malavasi Cardoso ! The only thing I need to do, was to change file:///E:/Video/ActCAM/test2.mp4
to ~/Content/Video/test2.mp4
and transfer file to that directory
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.