Unsafe content, JS audio

Asked

Viewed 66 times

1

I am finishing a Javascript and only an audio execution is missing when a given event occurs. I am testing the following code:

console.log('sobre audio');
        var a = new Audio("https://mdn.mozillademos.org/files/2587/AudioTest%20%281%29.ogg");
      a.play();

The above code works, but when I change the link to an audio link of my choice it generates the following error in the console (in bold, the link that has been replaced):

Loading mixed content (insecure) "http://www.picosong.com/6b4L/#" on a secure page[Learn more] game.php GET http://www.picosong.com/6b4L/#

Although you report that you are loading, the content is never loaded, probably because you were alerted as insecure.

Which domain can I upload this file directly so that my browser (Mozilla) recognizes it and runs it? Or the problem is not this?

  • Here the audio loaded in Firefox and Google Chrome, even using the protocol file:/// and http:// at the url of localhost. In googlechorme the same problem occurs to you?

  • I don’t have Chrome here :/ Have you tested with this link? " http://www.picosong.com/6b4L/#"

  • Yes I tested, this page is yours? So there worked normal, had a rap song, but had nothing to https://mdn.mozillademos.org/files/2587/AudioTest%20%281%29.ogg there. I tested the rap music and it worked on Firefox and Chrome.

  • So, this link from the mozillademos I took, along with this code, from a Mozilla audio site. The only thing that should be done to my mind was to replace this Mozilla link with a direct audio one, but the rap link I gave you is not played here :/

  • But on which page did you inject this code? Is the site picosong then not yours? How did you inject the code into the site picosong?

  • No, I am using Mozilla’s scratchpad(shift+ F4) to run a function on a particular site, to detect a change in an x element. If that x element is changed at any time, this sound script will be run.

  • picosong is not my no haha, I found on google just now and upei the rap there to make a test. When I solve this problem, upo a more suitable kk song

  • With scratchpad worked normal, is Linux or Windows? At least in Windows worked.

  • Friend I can be honest, I think you are wrapping me, I read in the body of your question the term "game.php", this gives to understand that you ran the code in a php page and not in picosong, if this game.php is your page, then the problem can be ae (or in your Apache). If you don’t give details it’s very difficult to help.

  • I’m using the page https://us21.tribalwars.us/game.php?village=5044&screen=market&mode=exchange , that’s where the game.php. As I said, I am monitoring a field of this page, when it undergoes change (coming from the server, which updates the field every y seconds), the sound is played. I’m using Windows yes.

  • I understand, it seems that the problem is not well with your Firefox so.

  • Follow the code I’m using in scratchpad: var target = Document.querySelector('div.premium-exchange-Sep'); var Observer = new Mutationobserver(Function (mutations) { mutations.foreach(Function (Mutation) { if (target.innerHTML >= '500') { console.log('about audio'); var a = new Audio("http://www.picosong.com/6b4L/"); a. play(); Observer.Disconnect(); } }); }); var config = { Attributes: true, childList: true, characterData: true }; Observer.observe(target, config);

  • 1

    picosong.com/6b4L/ is not an audio file is an html page, never will you be able to run like this: new Audio("picosong.com/6b4L/"); a.play(); and I don’t see what MutationObserver has to do with https://us21.tribalwars.us/game.php?village=5044&screen=market&mode=exchange - Friend I can be honest, I think it’s some confusion of yours.

  • I understand, I thought that both links work by the same principle, since the Mozilla one worked. Is there any alternative for me to use an audio of my own, either through link (where upar?) or by reading a file . mp3 directly from my system?

  • 1

    I don’t know if it will work, but click download, will generate a link, copy the link and use with new Audio, the link should look something like: new Audio('http://picosong.com/cdn/94d52b94c03237d18c72c400e7b7e284.mp3')

  • So simple, vlw by patience and enterprise, problem solved :)

Show 11 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.