即使在自动播放=“假”预加载=“无”之后,视频也会在不单击播放按钮的情况下启动

Even after autoplay="false" preload="none", Video is starting without clicking on play button

本文关键字:单击 播放 启动 情况下 按钮 之后 自动播放 加载 视频      更新时间:2023-09-26

在下面的代码中,自动播放="false" 预加载="无"设置,但视频仍然自动播放。

问题出在哪里?

我错过了什么?

new_video = document.createElement('video');
new_video.setAttribute('controls','true');
//new_video.setAttribute('autoBuffering','true');
new_video.setAttribute('preload','none');//autoPlay: false, 'preload':'auto'
new_video.setAttribute('autoPlay','false');
//new_video.setAttribute('type','video/mp4;codecs="vp8, vorbis"');
video = document.getElementById('RIZfC358yRk').appendChild(new_video);
source = document.createElement('source');  
source.setAttribute('src','https://dl.dropboxusercontent.com/u/87532981/Ella%20May%20and%20the%20Wishing%20Stone%20By%20Cary%20Fagan.mp4');
video.appendChild(source);
video.load();
video.play();

尝试使用"autostart"属性而不是"autoPlay":

new_video.setAttribute('autostart','false');

并删除最后一行,

video.play();