I want to add a video player in as.net Mvc for playing videos. I have already tried JW Player, FlowPlayer, Video.js and JPlayer. The problem is no player shown video in chrome, firefox, and safari just playing audio with a blank screen. I have checked that video in IE and it work great and if i download video from chrome and play in vlc or window media player then it run perfectly. So, please let me know which player is best? I have also unchecked disable hardware acceleration option in chrome but no improvement shown in behavior. My video type is strictly mp4. So, please help .
Thanks.
I suggest you to use the HTML5 video element.
<video width="400" controls>
<source src="mov_bbb.mp4" type="video/mp4">
<source src="mov_bbb.ogg" type="video/ogg">
Your browser does not support HTML5 video.
</video>
Here for documentation and exaple
I suggest you use Video.js. It is simple to inject into your asp.net application. Here is how:
Using Bower, install Video.js into your application
Reference the video.js javascript file and style sheet
<link rel="stylesheet" href="~/lib/video-js/video-js.css"/>
<script src="~/lib/video-js/video.min.js"></script>
In your site.js file you can add this code so that every video tag will have the video.js player
var VideoElements = document.getElementsByTagName('video');
for (var i = 0; i < VideoElements.length; i++){
videojs(VideoElements[i]).ready(function () {
var myPlayer = this;
});
}
Related
Only certain video files in tag are played on a white screen.
Other files with the same extension work well.
It plays when you convert the file to another extension. (ex. mov -> mp4)
<video controls autoPlay width="100%" height="100%">
<source src={videoUrl} />
</video>
I think it has something to do with the HEVC codec.
my electron version 18.0.4
Add meta to html
http-equiv="Content-Security-Policy" content="media-src *;">
The video url works well if you do it on Chrome.
I share my solution.
Just a chromium version problem.
update v100 -> v110
Make sure electron >= 22 (chromium 107 add hevc hw decoding support) will solve your problem.
I have an mp3 file saved in my assets/audio folder and want to play it using the html 5 player. However, when I load my page I always get a 404 not found error for that resource. Wondering if I am doing this wrong.
In view.html.erb
<audio src="app/assets/audio/bensound-acousticbreeze.mp3" type="audio/mpeg" controls>
Your browser does not support the audio element.
</audio>
I have verified multiple times that the full path is correct. Any help would be appreciated
UPDATE:
Found this while looking up a few things to answer the question. Better than any other solution here is to use the built-in audio_tag. This does remove the alternate text option though, so there's that. Still, here's the doc page.
Have your tried audio_path or asset_path?
That would look like this:
<audio src="<%= audio_path 'audio/bensound-acousticbreeze.mp3'%>" type="audio/mpeg" controls>
Your browser does not support the audio element.
</audio>
or
<audio src="<%= asset_path 'audio/bensound-acousticbreeze.mp3'%>" type="audio/mpeg" controls>
Your browser does not support the audio element.
</audio>
You should simplify by keeping your audio in the audios dir as seen in the docs. Then it would just be:
audio_path "bensound-acousticbreeze.mp3"
All together with the html:
<audio src="<%= audio_path 'bensound-acousticbreeze.mp3'%>" type="audio/mpeg" controls>
Your browser does not support the audio element.
</audio>
Apparently all rails assets get collapsed down into the assets directory, even if they are in sub-directories. The correct path was just "assets/bensound-acousticbreeze.mp3."
To anyone having trouble like this, it helped me to compare the path of the missing asset with the one I wanted to load to see what the difference was.
I have tried everything I possibly could, but I was not able to solve this. I am trying to display an mp4 video using an HTML5 video element in IE9 and IE10. In IE9 I get a blank square where the video is supposed to show and in IE10 it says "Invalid Source". It plays fine in Chrome.
The video displays fine within a simple HTML file, but not in my ASP.net MVC project, whether run locally or on a web server. I have the file placed in my root folder (same folder as the web.config)
Here is my code in my ASP.NET MVC index.cshtml:
<video controls style="position:inherit" >
<source src="ExplainerVideo.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' />
</video>
Any ideas?
Thanks.
Try taking away the codec and letting the browser decide for itself whether it can play it or not.
e.g. <source src="ExplainerVideo.mp4" type='video/mp4' />
Failing that, try an absolute URL for the video as I've noticed this causing issues on IE before.
My HTML5 video syntax is nearly the same as this guy:
<video height="270" width="480"
src="media/bbb.ogv"
poster="media/bbb.jpg"
durationHint="0:4:44">
</video>
On iPhone (iOS 5.0) and desktop Firefox, I can see the poster:
But on iPad (iOS 5.0.1) it does not appear. I recall that it used to work on iPads with iOS less than 5.
Try the same code using absolute instead of relative paths:
<video height="270" width="480"
src="http://cdn.kaltura.org/apis/html5lib/kplayer-examples/media/bbb_trailer_iphone.m4v"
poster="http://cdn.kaltura.org/apis/html5lib/kplayer-examples/media/bbb480.jpg"
durationHint="00:04:44">
</video>
If that doesn't work, their CDN might be blocking external referrers so try to save the files to your own local server and use absolute paths to them.
NOTE: you don't have to use absolute paths but it definitely helps when troubleshooting.
Another solution if that fails is to use an absolute-positioned image overlay that when clicked, uses JavaScript to activate the tag below; but this is an older hack and shouldn't be required for iOS 5+.
iOS 3 definitely has a known problem with the poster attribute on video tags:
http://videojs.com/2010/09/ipad-iphone-video-poster-fix-bonus-javascript-placement-fix/
I am new to MVC I want to know how to add Video in MVC 2.0 using Html5. when I try to add video in Mvc like this
Video src="http://stelllent/Videos/Mvc"
It display error Video tag is not defined.
The first prerequisite is to have a browser which supports the <video> tag (IE 9.0+, FireFox 3.5+, Safari 3.0+, Chrome 3.0+, Opera 10.5+, iPhone 1.0+, Android 2.0+, ...). Then you could use it like this:
<video src="/videos/movie.avi" controls="controls">
Your browser does not support the video tag
</video>
Or if you have a controller action which is streaming the video you could also point the src attribute to it.