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.

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

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

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.

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

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.