PDA

View Full Version : Song duration in midi files


balltom
01-28-2003, 05:06 AM
Folks

I have been browsing quite a while now the MSDN library and this forum and could not find what I wanted.

Anyone knows you to get the duration of a midi song (I want to be able to do it on IE. So no EMBED tag!)?

Might be possible with some Server script methods?

Thanks for your help.

Tom:D

zoobie
01-28-2003, 07:33 AM
You mean display the duration? Some little players do that. If it's changing the duration, it must be edited with a sound editor. :D

balltom
01-28-2003, 01:42 PM
No, I just want to know how long will be the song in order to set a time out to go to a next song.
Tom;)

balltom
01-28-2003, 07:09 PM
Finally, I ended up finding what I wanted in the MSDN libary.
There is a CLASS that we can use that gest all the data about sounds and video files.

Here what I have tried:
<HTML>

<Script language=javascript>

function how_long(){
var duration;
duration=document.audio.SelectionEnd;
alert(duration + ' seconds');
}

function play(){
document.audio.run();
}
</script>
<HEAD>
</HEAD>
<BODY>


<OBJECT ID="audio" WIDTH=0 HEIGHT=0 CLASSID="CLSID:05589FA1-C356-11CE-BF01-00AA0055595A">
<PARAM NAME="Filename" VALUE="Angie.mid">
</OBJECT>

<a href="javascript:play()">Click here to start</a>
<p>
<a href="javascript:how_long()">Click here to know the duration (in seconds)</a>
</p>
</body>
</html>

This is going to tell you tha Angie is 289 seconds (I attached the midi file if you want to try it). Pretty easy to use and you don' t have any more to get the file duration manually and song by song when you write the HTML plage to set the timer out.

Though that might help:D

balltom
01-28-2003, 07:25 PM
Can't load the attachment. .mid is not a valid expention. :( Anyways, try it with some midi file of your own and let me know.
Tom

Mr J
01-31-2003, 06:28 PM
put the midi in a zip file and post that

balltom
01-31-2003, 07:12 PM
Duh.... good point here. Can't beleive I did not think about it... See attached :thumbsup: