Say I have a path and filename pointing to an MP3 on a clients machine, and a path/filename pointing to their media player (eg Winamp or VLC). How can I play the MP3 using their player?
Is there any kind of Shell() functionality in Javascript? Googling for the likes of "javascript shell" provides results oriented towards an execution environment for js, not a system shell, and "javascript play mp3" (etc) finds instructions for inserting an <audio>
element. My googling skills are failing me...
Any help much appreciated!
Thanks to T.J. Crowder's advice I have found a (possible) solution: creating a protocol handler.
This is the registry file I created:
Windows Registry Editor Version 5.00
[-HKEY_CLASSES_ROOT\playmp3]
[HKEY_CLASSES_ROOT\playmp3]
@="URL:playmp3 Protocol"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\playmp3\shell]
[HKEY_CLASSES_ROOT\playmp3\shell\open]
[HKEY_CLASSES_ROOT\playmp3\shell\open\command]
@="C:\\Program Files (x86)\\PlayMP3\\playmp3.bat %1"
If a user imports this into their registry, then entering playmp3://E:\My Music\My Really Cool Song.mp3
into a browser address bar will trigger my batch file:
@ECHO OFF
SET "url=%1"
SET "player=C:\Program Files (x86)\Winamp\winamp.exe"
SETLOCAL EnableDelayedExpansion
SET url=!url:playmp3://=!
SET url=!url:/=!
"%player%" "%url%"
ENDLOCAL
...which strips the "playmp3://" (protocol) from the string and passes it to Winamp.exe :)
Doing this, I successfully created a link on a page that, when clicked, began playing a track in Winamp :)
Sure, it requires the user execute a registry script, specify a path to an executable in the batch file, then put it in a certain place... but it works! :)