HTML video continuous playback questions

Asked 6 days ago, Updated 6 days ago, 1 views

I want to play a locally stored video through a video tag and automatically play the next video after that video is played.

There was something called onended, so I tried it, but it didn't work like this.

I can show you the first video well, but I can't bring the second one.

    <video id="videoPlay" width="300" height="200" controls autoplay muted>      
        <source type="video/mp4" src="/test/test1.mp4" type="video/mp4" onended="nextPlay()" />
    <input type="button" id="btn1" value="click">

function nextPlay() {
    $("#videoPlay").attr("src", "/test/test2.mp4");

Do I have to use something else instead of onended?

html html5 video

2022-09-20 16:26

1 Answers

It came out after I googled a bit more.

$("#videoPlay").on("ended", function() {
    $("#videoPlay").attr("src", "/test/test2.mp4");

We successfully modified the script part like this.

2022-09-20 16:26

If you have any answers or tips

© 2022 pinfo. All rights reserved.