我用JavaScript编写了一个firefox插件,以自动在一个流媒体网站上加载电视连续剧的下一集并自动播放。
var video = document.getElementsByTagName('video')[0];
video.addEventListener('canplaythrough', function () {
setTimeout(function () {
if (video.currentTime == 0)
video.play();
}, 2000)
});
video.addEventListener('ended', function () {
var next = document.querySelector('[title="next episode"]').click();
});
视频结束后,下一个视频的页面已正确加载,但新视频无法播放。
NotAllowedError: The play method is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.
有什么解决办法吗?