jquery - How to change a children type using Javascript -


i using video.js , want play both youtube , mp4 videos. have following code player

<video id="my-video" class="video-js vjs-big-play-centered" data-setup='{ "controls": true, "autoplay": true, "preload": "auto" }' width="1250" height="900" poster="" data-setup='{" techorder ": ["youtube "]}'> <source src="https://www.youtube.com/watch?v=_z_se7ejnim" type='video/youtube'> <p class="vjs-no-js">   view video please enable javascript, , consider upgrading web browser   <a href="http://videojs.com/html5-video-support/" target="_blank">supports html5 video</a> </p> 

here code used change source whenever link id (source_one) clicked:

  var = document.getelementbyid('source_one');    a.addeventlistener('click', function() {         document.getelementbyid("my-video").children[0].src = "http://example.com/video.mp4";   }) 

the problem cannot find way change source type video/mp4, using src changes source of video not change type.

i found out solution! answers far.

 var = document.getelementbyid('source_one');     a.addeventlistener('click', function(e) {         e.preventdefault();         var player = window.player = videojs('my-video');          var vidlink = $(this).attr('href');          player.src({             src: 'http://example.com/test.mp4',             type: 'video/mp4'         });     }) 

Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -