I have an html5 video streaming and I need to change it source* after some click action. So what i'm doing works, but only in html, i can see source change but it no changing on my display, can you help me? What is wrong? *The source is appending frome xml file.
HTML
<video autoplay loop width="960" height="540" id="video">
<source src="video/movie_01.mp4" id="tv_main_channel">
</video>
JS
btn.on('click', function(){
var tv_main_channel = $('#tv_main_channel'),
d_program_source_mp4 = $(program_self).find("program_source_mp4").text();
tv_main_channel.attr('src', d_program_source_mp4);
}
also i try it with append
but it still not work
var video_block = $('#video');
video_block.empty();
video_block.append(
'<source src="'+ d_program_source_mp4 +'">'
);
Thx for help.
See this fiddle: http://jsfiddle.net/qGbzb/2/
To dynamically load videos you need to run
var video_block = $('#video');
video_block.load();
Then you should also see a change in the display too, and not only in the html.
It's simple, just do this:
btn.on("click", function(){
var src = "new_video_src.mp4";
$("#video").find("#tv_main_channel").attr("src", src)
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With