Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

87 users online



Play a MIDI file when you click on an icon

Play a MIDI file when you click on an icon

Currently viewing this thread: 1 (0 members and 1 guests)


Page 1 out of 2
hamidrizvi

hamidrizvi

Status: Offline!

Play a MIDI file when you click on an icon

Im building a ring tone site and Im kinda stuck at this one place

I want it so that the user can preview the ringtone before they download it, and to do that I want them to clcik on a speaker icon.However, I dont want anythign ti pop up and the ringtone should play.

To get an idea of what im talkin bout, go to www.mrtones.com and check it out. When you click on the icon, the ringtone plays

Whats the code for it? I cant seem to figure it out :confused:

thanks

___________________

http://www.nauhay.com/images/sig1.jpg

fredmv

fredmv

Status: Offline!

No problem - I know exactly how this is done. I'll write the script right now...

___________________

http://home.comcast.net/~fredv4/tf/firefox.gif

hamidrizvi

hamidrizvi

Status: Offline!

yay Grin

lol..thx..ur a life saver...mmmm...life saver Smile lol

___________________

http://www.nauhay.com/images/sig1.jpg

fredmv

fredmv

Status: Offline!

Alright, I'm done. I tried to make it cross-browser compatiable as well -- If their browser doesn't support it, it will tell the user. You just call the function like this in your links:

Code:


<a href = "#" onclcik = "playMidi('filename.mid');">Play filename.mid!</a>

Where "filename.mid" is the name of the MIDI file.

I uploaded a demo which you can find here:

http://home.comcast.net/~fredv4/tf/midi.html

I have some NIRVANA MIDIs which use the script I wrote to play them.Grin

Here's the function:

Code:


<script type = "text/javascript">
document.writeln("<div id = 'player' style = 'visibility: hidden; top: 0px; left: 0px; position: absolute;'><\/div>");

function playMidi(f)
{

if(document.getElementById)
{
document.getElementById("player").innerHTML = "<embed src = '" + f + "' autostart = 'true' height = '0' width = '0' hidden = 'true'><\/embed>";
}

else if(document.all)
{
document.all.player.innerHTML = "<embed src = '" + f + "' autostart = 'true' height = '0' width = '0' hidden = 'true'><\/embed>";
}

else if(document.layers)
{
with(document.layers["player"].document)
{
open();
write("<embed src = '" + f + "' autostart = 'true' height = '0' width = '0' hidden = 'true'><\/embed>");
close();
}
}

else
{
window.alert("Your browser does not support this function.\n");
return false;
}

return;
}
</script>

Well - Hope that helps you out! Grin

___________________

http://home.comcast.net/~fredv4/tf/firefox.gif

Last edited by fredmv, August 3rd, 2003 09:44 PM (Edited 1 times)

hamidrizvi

hamidrizvi

Status: Offline!

hmm..your preview doesnt work for me. I mean it dosnt play the files when I click on them.

And i tried it on my site too, same thing, it appears but once u click on it, nothing happens

If it works for you, I dunno why it doesnt work for me Sad

___________________

http://www.nauhay.com/images/sig1.jpg

fredmv

fredmv

Status: Offline!

What browser are you running? If you're running Netscape/Mozilla it's probably because you don't have the plug-in properly configured.

And you might need to wait a little for the MIDI to download...

___________________

http://home.comcast.net/~fredv4/tf/firefox.gif

hamidrizvi

hamidrizvi

Status: Offline!

im using IE 6....with windows XP

i kno my speakers are on..lol..and i waited for a while.....still not playin...Sad

shyt..and i gotta go take my mom to wal mart now...i'll be back later...see if you can figure out wha the problem is

___________________

http://www.nauhay.com/images/sig1.jpg

fredmv

fredmv

Status: Offline!

Ah, stupid *** IE6... I'll test it out and find out what's wrong.

*** EDIT ***

I think I may have fixed it:

http://home.comcast.net/~fredv4/tf/midi.html

___________________

http://home.comcast.net/~fredv4/tf/firefox.gif

Last edited by fredmv, August 3rd, 2003 10:13 PM (Edited 1 times)

hamidrizvi

hamidrizvi

Status: Offline!

GOOD JOB Grin lol..thx man...your demo works..now to plug it into my thing and hope for the same

___________________

http://www.nauhay.com/images/sig1.jpg

fredmv

fredmv

Status: Offline!

Alright, great! Happy that worked out...

Seems like IE6 wants you to use <bgsound> rather than <embed> -- Kind of weird.

Also just to let you know, the script at MrTones.com sucks, it will only work with IE since they're using document.all to access objects in the document, the script I wrote for you should work in IE, Netscape, Mozilla, etc.Wink

___________________

http://home.comcast.net/~fredv4/tf/firefox.gif

Page 1 out of 2
Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0085 seconds.