Javascript-播放视频

时间:2018-11-27 23:48:37

标签: javascript php html html5

我的问题是,当视频在10分钟内播放时,视频会从头开始重新播放。广告弹出时,如何连续播放视频而又不再次播放视频。请指导我谢谢

JavaScript代码

<script>

  var player = document.getElementById('player');
  var supposedCurrentTime = 0;

  player.addEventListener('timeupdate', function() {

    if (!player.seeking) {
      supposedCurrentTime = player.currentTime;
    }});

  // prevent user from seeking
  player.addEventListener('seeking', function() {
    // guard agains infinite recursion:
    // user seeks, seeking is fired, currentTime is modified, seeking is fired, current time is modified, ....
    var delta = player.currentTime - supposedCurrentTime;
    if (Math.abs(delta) > 0.01) {
      console.log("Seeking is disabled");
      player.currentTime = supposedCurrentTime;
    }
  });
  // delete the following event handler if rewind is not required
  player.addEventListener('ended', function() {
    // reset state in order to allow for rewind
    supposedCurrentTime = 0;
  });


</script>

我的广告

<video
  oncontextmenu="return false;"
  src="../inflightapp/storage/app/public/movie_videos/<?php echo ''.$row2['movie_video'].''; ?>" <?php } ?>
  id="player"
  width="1px"
  controls
  controlbar=”no”
  controlsList="nodownload"
  ads = '{  
    "servers": 
      [
        {
          "apiAddress": "ads.php"
        }
      ],
    "schedule": 
      [
        <?php
          $data3 = mysqli_query($con,"SELECT * FROM ads");
          while($row3 = mysqli_fetch_array($data3)) {  
            echo '
              {
                "position": "'.$row3['roll'] .'",
                "startTime": "'.$row3['time'] .'"
              },'; 
           }
        ?>
      ]
  }'>
</video>

0 个答案:

没有答案