I was wondering... if you have a mp3 file, is it possible to get the length of the file? Like in Windows Media Player it displays the length of the song. Is this possible through javascript or any other web programming? If not straight from the file itself, what about if Windows Media Player was embedded in the website, can it be obtained through the player? Thanks
You can do it with a server-side language. What kind of box are you on? (Microsoft, *Nix, etc...) Otherwise you could build a "pre-loader" for the mp3 file in Flash, - then have Flash communicate to your javascript with the size of the Preloaded mp3 file.
I'm running Microsoft Windows Server 2003. I can use any server-side language, such as PHP? How would I do that using PHP?
<?php // outputs e.g. somefile.txt: 1024 bytes $filename = 'somefile.txt'; echo $filename . ': ' . filesize($filename) . ' bytes'; ?> for more examples, check out php.net: http://us3.php.net/filesize
Thank you, this is good. But also I was wondering if it is possible to get the length, in time, of a media file. For example, take a mp3 file and output something like "3:45" for 3 minutes and 45 seconds long
their might be some classes built out there to handle media types like mp3's - i would just google it
If you use IIS with Windows 2003 Server, you can also do it with ASP (since it comes with it). Enabling by doing start/run/inetmgr and the going into Web Service Extension and enable Active Server Page. The simply make a file. asp with this <% dim fs,f set fs=Server.CreateObject("Scripting.FileSystemObject") set f=fs.GetFile("c:\mycoolmp3.mp3") Response.Write(f.Size & " bytes.") set f=nothing set fs=nothing %> Hope this helps, getting php to work on windows 2003 is a bit more complex, you should read a step by step guide if you wish to use php rather than asp.