I'm using the tags in HTML5 to play a video on a web browser... (and I'm very impressed with this new feature)
Is there the functionality to change the video being played through Javascript? Say when I select another video from a list, a Javascript function would be called which would contain something on the lines of MyVideo.VideoLocation = //location of new video to be played
. Is this possible please?
Thanks and regards, Krt_Malta
Try autoplay="autoplay" instead of the "true" value. That's the documented way to enable autoplay.
To change source on HTML5 video tag with JavaScript, we an set the src property of the video element. const changeSource = (url) => { const video = document. getElementById("video"); video. src = url; video.
Webkit requires that you call "load()" after changing the source:
videoTag.src = "newVideo";
videoTag.load();
videoTag.play();
Apple has a useful tutorial.
Here is the solution, tested on Ipad/Iphone/Webkit/Firefox
<script>
function playNext(path,target)
{
target[0].src=path;
target[0].load();
target[0].play();
}
playNext("pathToMovie",$('#video_1'));
</script>
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