My script does not detect the redirection URL

this is the case : Needed a responsive html5 audio player and the best I found was one made by a person called Osvalds .

The first problem I found was that the " autoplay " attribute reproduced the same song twice in Firefox. I could fix this by adding a few lines of javascript (though the play button does not change the song to be played ) .

The second problem (and this is where I need help) is that the javascript does not detect or failure with URL redirect but it does work with the final URL.

I mean, my php variable to return a URL like:

" http://www.goear.com/action/sound/get/104fc33 "

But this in turn redirects me to a final URL:

"http://live1.goear.com/listen/d6a9757a390b5d49b8584288d5589318/52eac3f1/sst2/mp3files/10102006/450929654ac4765a83324119603d02d6.mp3"

Ok , when I used a flash-based player , there was no problem . And when I use the "audio" tag without the script there is no problem .

I tried to fix this by passing php variable to " CURL " and it worked! But it turned out that my host does not support the " CURLOPT_FOLLOWLOCATION " .

That was another option to look at the javascript source code audio player .

This is my html:

          <audio  id="audiobox" preload="auto" controls loop>
            <source src="http://live1.goear.com/listen/d941195f4a5f477381d8a95ba666a0cb/52eac666/sst2/mp3files/10102006/450929654ac4765a83324119603d02d6.mp3">

            <script type="text/javascript">
              function play() {
              document.getElementById('audiobox').play();
              }
                play();
            </script>

          </audio>

        <script src="jquery-1.11.0.min.js"></script>
        <script src="audioplayer.js"></script>

In this direction is the code javascript audio player: I'm no expert in javascript but I think the problem must be in line 56: "this.attr AudioFile = $ ('src')." I think if I could define the php variable directly in the script it could run. But do not know if there's another way:

http://pastebin.com/WxnTQmXa

This left a jsFiddle example, in this case the "src" attribute is calling the final URL that ends in MP3 and as you can see, the music plays and the player works.:

http://jsfiddle.net/aEXsL/2/

And here is the example with the problem, the same code just labeled "source" points to the URL that returns me the variable (remember that this only fails using this script):

http://jsfiddle.net/aEXsL/3/

It appears only one button (it means the player is failing).

Hope you can help me. Thanks in advance.

Edit: Here is the link to the script author: http://tympanus.net/Development/AudioPlayer/AudioPlayer.zip

Answers


Use this code

<script type="text/javascript">
var song=new Audio('http://live1.goear.com/listen/d941195f4a5f477381d8a95ba666a0cb/52eac666/sst2/mp3files/10102006/450929654ac4765a83324119603d02d6.mp3');
song.play();
</script>

but your link not contain any MP3 i think now


Need Your Help

Android same layout different data

android eclipse string layout

I'm creating a local android application and am trying the following:

Quick blox android SDk

android push-notification quickblox

I am facing a problem in quickblox android sdk