Jump to content

Play Mp3


Javi

Recommended Posts

Hi

 

I have seen play WAV

 

<script>
 var audio2 = document.createElement('audio');
 audio2.setAttribute('src', 'files/Inicio.wav');
 audio2.play();
</script>

 

But how I can plays back MP3?

 

Thanks

Link to comment
Share on other sites

Thanks Farshad

 

But I need to play sound in IE 8. I need to control the sound from the program: play and stop.

 

Can you help me please. JavaScript world is completely unknown to me.

 

Thank you very much.

Javi

Link to comment
Share on other sites

Thanks Anders Andersen.

 

But how I can control the player from UniGui?

I had a bit of a look and this player seems to be very easy to use.

 

From the documentation all you do is use this html code:

 

<object type="application/x-shockwave-flash" data="player_mp3_mini.swf" width="200" height="20">
    <param name="movie" value="player_mp3_mini.swf" />
    <param name="bgcolor" value="#ff0000" />
    <param name="FlashVars" value="mp3=test.mp3" />
</object>

 

Just put the flash file somewhere in the files folder and put the code above in a UniHTMLFrame. Should be pretty easy.

Link to comment
Share on other sites

Hello again.

 

I managed to run the code in Firefox, but not IE8.

 

Can you help again? Thank you very much.

Javi

 

TUniHTMLFrame.Html

 

<object class="playerpreview" id="myFlash" type="application/x-shockwave-flash" data="/files/player_mp3_js.swf" width="200" height="20">
   <param name="movie" value="player_mp3_js.swf" />
   <param name="bgcolor" value="#ff0000" />
   <param name="FlashVars" value="mp3=/files/TresCerditos.mp3" />       
</object>

 

procedure TMainForm.UniButtonPlayClick(Sender: TObject);
begin
 WebForm.JSCode('document.getElementById("myFlash").SetVariable("method:play", "");');
end;

procedure TMainForm.UniButtonStopClick(Sender: TObject);
begin
 WebForm.JSCode('document.getElementById("myFlash").SetVariable("method:stop", "");');
end;

Link to comment
Share on other sites

Finally works!!

 

TUniHTMLFrame.Html

 

<object class="playerpreview" id="myFlash" type="application/x-shockwave-flash" data="/files/player_mp3_js.swf" 
width="200" height="20">
   <param name="movie" value="/files/player_mp3_js.swf" />
   <param name="bgcolor" value="#ff0000" />
   <param name="FlashVars" value="mp3=/files/TresCerditos.mp3" />       
</object>

 

 

This was the error

 

<param name="movie" value="/files/player_mp3_js.swf" />

 

 

Thank you very much Anders Andersen.

Link to comment
Share on other sites

  • 2 weeks later...

I folks,

 

 

I have used something like:

 

//

// Set TextConversion property at TUniLabel component to txtHTML

//

lbURL.TextConversion := txtHTML

lbURL.Caption := '<object type="application/x-shockwave-flash" data="./mp3player.swf" width="200" height="20">' +

'<param name="movie" value="./mp3player.swf" />' +

'<param name="FlashVars" value="mp3=./temp/music.mp3&showslider=1&width=200&height=20&autoplay=0&showinfo=0" />' +

'</object>';

 

As you can see I just used a block of code inside a TUniLabel Component.

 

The player I use is found in http://flash-mp3-player.net/medias/

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...