javascript - PhantomJS不支持音频标签

标签 javascript audio phantomjs debian

请告诉我该如何解决?当页面加载了音频播放器phantomjs时,将返回以下错误:

ReferenceError: Can't find variable: Audio

http://95.183.11.171/ph.php:9


试图在Internet上搜索其OS的解决方案,但未找到任何结果。操作系统:Debian 8。
我的代码(来自答案https://stackoverflow.com/a/35511597/3359390的部分):
var page = require("webpage").create();

page.open("http://95.183.11.171/ph.php", function(status) {
    page.evaluate(function() {
        if (!window.Audio) {
            window.Audio = function() {
                return {
                    play: function() {},
                    pause: function() {}
                };
            };
        }
    });

    setTimeout(function() {
        phantom.exit();
    }, 1000);
});

最佳答案

有一种用于设置页面全局变量的解决方案:

https://github.com/ariya/phantomjs/blob/master/examples/unrandomize.js

关于javascript - PhantomJS不支持音频标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47369109/

相关文章:

xcode - 无法以XCode 6 Swift播放音频

google-app-engine - 在 Travis-CI 上运行 Google App Engine 并使用 PhantomJS 进行测试

javascript - Mac OS X 上的性能缓慢

javascript - 模块构建失败 : Error: ENOENT: no such file or directory - React

javascript - 在 javascript 中向 olleh dlrow 返回 hello world

javascript - 是否可以在没有插件(没有 Flash 或 Quicktime)的情况下在网站上播放快速提示音?

python - 奇异果和游戏中的声音:游戏更新循环等待声音完成,然后继续[奇异果中使用SoundLoader的FPS问题]

python - PhantomJS 随机不退出(使用 Selenium 和 Python)

javascript - 如果选中输入单选,则更改父级的颜色 : can't make it work with jQuery

javascript - Vanilla Js : Start a while loop in one event, 用第二个事件打破它? ('mouseover'开始, 'mouseout'设置循环条件为假)