0

Please tell me how to fix this? When the page is loaded with audio player phantomjs returns the following error:

ReferenceError: Can't find variable: Audio

http://95.183.11.171/ph.php:9

Tried to search the Internet for a solution for its OS, but nothing found. OS: Debian 8.

My code (the part from the answer 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);
});
Community
  • 1
  • 1
ikerya
  • 129
  • 7

2 Answers2

0

There is a solution for setting global variables of the page:

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

ikerya
  • 129
  • 7
0

There's nothing to fix. PhantomJS simply has no support for media elements, sadly. You'll need another solution if you want to support audio.

Brad
  • 159,648
  • 54
  • 349
  • 530