UnKnown UnKnown - 2 months ago 8
jQuery Question

Unable to play the Video in HTML5

In my application i have a video tag for which i am appending src dynamically

this is my code

<video autobuffer controls autoplay>
<source id="howtovideoimg" src="" type="video/mp4">
</video>


$( document ).ready(function() {
$('#howtovideoimg').attr('src', 'http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4');
});


This is my fiddle

http://jsfiddle.net/cod7ceho/125/

Please let me know how to play the video

Answer

$( document ).ready(function() { 
  var player = document.getElementById('videoPlayer');
      var filepath = document.getElementById('videoPlayer');
      filepath.src = "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4";

});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<video autobuffer controls autoplay id="videoPlayer">
  <source id="howtovideoimg" src="" type="video/mp4">
</video>