第二次后的 Html5 视频播放列表触发事件

时间:2021-03-16 11:55:29

标签: javascript html video playlist

我需要在我的 Cordova/framework7 应用程序中连续循环播放许多视频。
第一个视频结束后,我需要开始第二个视频和视频 3,依此类推

我有这个代码:

    <video id="myVideo" muted width="100%" height="100%"></video>
    // PLAYLIST

    var videoNum = 0
    var videoCount = list_spot_file.length;
    var video = document.getElementById("myVideo")

    video.onended = function() {
      playSpot()
    };

    function playSpot() {
      console.log('4 videoNum', videoNum);
      if (videoNum == videoCount) {
        videoNum = 0
      }
      console.log('1', list_spot_file);
      console.log('2', list_spot_file[videoNum]['file']);
      console.log('3 videoCount', videoCount);
      if (list_spot_file[videoNum]['status'] == 1) {
        video.setAttribute("src", image_local_path + list_spot_file[videoNum]['file']);
        // video.load();
        // video.play();
      } else {
        videoNum++
        playSpot()
        return;
      }
      videoNum++
    }

    playSpot()

首先在我的页面开始播放视频,然后在结束时重新播放第一个视频。

在第一个视频的第二个结尾之后,javascript 会触发已结束的视频。视频 2、视频 3 等也是如此。

为什么?

我需要播放一次视频并连续循环播放。

谢谢。

0 个答案:

没有答案
相关问题