Javi Posted May 5, 2011 Posted May 5, 2011 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 Quote
Administrators Farshad Mohajeri Posted May 6, 2011 Administrators Posted May 6, 2011 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 http://html5doctor.com/native-audio-in-the-browser/ Quote
Javi Posted May 9, 2011 Author Posted May 9, 2011 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 Quote
andersa@ellenshoej.dk Posted May 9, 2011 Posted May 9, 2011 I would try something like a flash player and embed that in an iframe (TUniURLFrame). Maybe this player would work: http://www.flashmp3player.org/ Quote
Javi Posted May 9, 2011 Author Posted May 9, 2011 Thanks Anders Andersen. But how I can control the player from UniGui? Quote
andersa@ellenshoej.dk Posted May 9, 2011 Posted May 9, 2011 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. Quote
Javi Posted May 9, 2011 Author Posted May 9, 2011 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; Quote
Javi Posted May 9, 2011 Author Posted May 9, 2011 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. Quote
acbarbosa Posted May 18, 2011 Posted May 18, 2011 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/ Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.