Page 1 of 1

Problem with Function to play midi files

Posted: Tue Jul 13, 2010 11:26 pm
by jotae
Well: in my Asp Web site for a long time I use this function to play a Midi file when the user click in the name of the Midi.This is line:

<A href="javascript:void(null)" onclick="tocar('http://www.prolatin.com/musica/' + '<%=rs.fields("ARCHIVO")%>',1,280,67)"><%= response.write(x.value) %></A>

This is the function:

function mp3(nombre,rpt,width,height){
CodeGen = ""
var mediaURL,rpt,width,height
nueva = window.open ("", "Crescendo", "toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizeable=no,copyhistory=no,width=300,height=300,top=120,left=0")
nueva.document.open()
nueva.document.write("<html><head><title>" + "Música original de Jorge Villamizar" + "</title>")
nueva.document.write("<center>")
nueva.document.write("<body bgcolor='#669999' text='#000000'></body>")
nueva.document.write("<table border='0' align='center'>")
nueva.document.write("<tr>")
nueva.document.write("<td valign='middle' align='center' bgcolor='oldlace' ")
CodeGen = '<object id=Player' + '\n' ;
CodeGen += 'codeBase=http://activex.microsoft.com/activex/co ... 6,0,02,902' + '\n' ;
CodeGen += 'type=application/x-oleobject height=' + height + ' width=' + width + '\n' ;
CodeGen += ' standby="Loading Microsoft® Windows® Media Player components..." ' + '\n' ;
CodeGen += 'classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"> ' + '\n' ;
CodeGen += '<param NAME="Filename" VALUE="' + nombre + '">' + '\n' ;
CodeGen += '<param NAME="ShowStatusBar" VALUE= "true">';
CodeGen += '<param NAME="autoStart" VALUE="true"><param NAME="Volume" VALUE="0">' + '\n' ;
CodeGen += '<param NAME="playCount" VALUE=' + rpt + '></object>'
nueva.document.write("</td>")
nueva.document.write("</tr>")
nueva.document.write("</table>")
nueva.document.write("</center>")
nueva.document.write(CodeGen)
nueva.document.close()
}

Working OK but in ASP!!!

But I change all my ASP sites to PHP. In PHP I use this line:

Code: Select all

<a href="javascript:void(null)" onclick="tocar('http://www.prolatin.com/musica/<?php echo $row["ARCHIVO"];?>,1,280,67')"><?php echo $row["TEMA"]; ?></a>
Don´t work. No error but not sound. ARCHIVO is the name of Midi file. Previous I convert this name to lower case like because in the MUSICA directory in my hosting server the midi names they are in lowercase. (In asp there is not difference among lower or upper case but in PHP I have many problems because I forget this.)

If somebody wants to verify what happens, this is the url:
http://sml.prolatin.com/to.php

The site is not still finished. Simply, click in the name of the song.

If somebody know how I can configure this function to work in PHP or if know a better system to play these Midi Files, I will appreciate your help a lot. Thx for you help. Very important to me.

Re: Problem with Function to play midi files

Posted: Wed Jul 14, 2010 1:00 am
by cpetercarter
In your post, you say that 'onclick' will call a Javascript function tocar(). However, on your website, it calls a function mp3(). I think this is wrong, because mp3() takes 4 arguments, and tocar() takes only one.

Re: Problem with Function to play midi files

Posted: Wed Jul 14, 2010 1:04 am
by jotae
Sorry. The correct is mp3. Tocar is another function I'm testing but neither work. The real problem is that the function doesn't find the midi file but the path is correct, the midi file exists in MUSICA directory and case is correct too. That's all verified.

See the source code:

<html><head><title>Música original de Jorge Villamizar</title><center><body bgcolor='#669999' text='#000000'></body><table border='0' align='center'><tr><td valign='middle' align='center' bgcolor='oldlace' </td></tr></table></center><embed type="application/x-mplayer2"
pluginspage="http://www.microsoft.com/Windows/MediaPlayer/"
Name="MediaPlayer" src="http://www.prolatin.com/musica/[b]buscapor.mid[/b],1,280,67"
autoStart=1 ShowStatusBar=1 playCount=undefined volume=0 HEIGHT=undefined WIDTH=undefined>

Now, read the midi file but don't play nothing.

Re: Problem with Function to play midi files

Posted: Wed Jul 14, 2010 2:39 am
by cpetercarter
Your mp3() function requires 4 parameters to be passed to it (nombre,rpt,width,heigth). Your page passes only one parameter. So it won't work.

Re: Problem with Function to play midi files

Posted: Wed Jul 14, 2010 3:54 am
by jotae
<html><head><title>Música original de Jorge Villamizar</title><center><body bgcolor='#669999' text='#000000'></body><table border='0' align='center'><tr><td valign='middle' align='center' bgcolor='oldlace' </td></tr></table></center><embed type="application/x-mplayer2"
pluginspage="http://www.microsoft.com/Windows/MediaPlayer/"
Name="MediaPlayer" src="http://www.prolatin.com/musica/[b]buscapor.mid,1,280,67"[/b]
autoStart=1 ShowStatusBar=1 playCount=undefined volume=0 HEIGHT=undefined WIDTH=undefined>

But, really pass the four parameters (See in bold) 1- Midi file, 2- PlayCount (1), 3- width (280) and 4- height (67).
Only read the midi name. Don't know what happen or how work this function in the server because is exactly the same function that work perfectly in ASP site.

Thx...

Re: Problem with Function to play midi files

Posted: Wed Jul 14, 2010 4:33 am
by cpetercarter
The problem is that the correct address of your file is http://www.prolatin.com/musica/buscapor.mid but the player is looking for a file http://www.prolatin.com/musica/buscapor.mid,1,280,67.

Try replacing:

Code: Select all

onclick="mp3('http://www.prolatin.com/musica/<?php echo $row["ARCHIVO"];?>,1,280,67')">
with this

Code: Select all

onclick="mp3('http://www.prolatin.com/musica/<?php echo $row["ARCHIVO"];?>',1,280,67)">

Re: Problem with Function to play midi files

Posted: Wed Jul 14, 2010 3:01 pm
by jotae
Working Nice!!!!! Thanks very much!!!! The habit of the asp syntax cause me many problems in php. Again, thx....