Got a little problem with Javascript.
HTML Code:<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Habbox</title> <SCRIPT> <!-- var WMState = new Array(); WMState[0] = "Undefined"; WMState[1] = "Stopped"; WMState[2] = "Paused"; WMState[3] = "Playing"; WMState[4] = "Scan Forward"; WMState[5] = "Scan Reverse"; WMState[6] = "Buffering"; WMState[7] = "Waiting"; WMState[8] = "Media Ended"; WMState[9] = "Buffering"; WMState[10] = "Ready"; WMState[11] = "Reconnecting"; function Status () { x = Player.playState; alert(WMState[x]); } function Play () { x = Player.playState; if (x == 2) { Player.controls.play(); } else { Player.URL = "http://www.emapdigitalradio.com/emapdigitalradio/metafiles/key103.asx"; } } function Pause () { Player.controls.pause(); } function Stop () { Player.controls.stop(); } function MuteMe () { x = Player.settings.mute; if (x == 0) { Player.settings.mute = "1"; } else { Player.settings.mute = "0"; } } function UnMuteMe () { Player.settings.mute = "0"; } function VolumeUp () { X = Player.settings.volume; Player.settings.volume = X + 10; } function VolumeDown () { X = Player.settings.volume; Player.settings.volume = X - 10; } --> </SCRIPT> </head> <body> <object classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" name="Player" width="0" height="0" standby="Loading" codebase="http:/activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715"> <param name="url" value="http://www.emapdigitalradio.com/emapdigitalradio/metafiles/key103.asx" ref /> <param name="autostart" value="-1" /> <param name="Volume" value="50"> <param name="uimode" value="invisible" /> <param name="rate" value="1"> <param name="balance" value="0"> <param name="currentPosition" value="0"> <param name="defaultFrame" value> <param name="playCount" value="1"> <param name="currentMarker" value="0"> <param name="invokeURLs" value="-1"> <param name="baseURL" value> <param name="mute" value="0"> <param name="stretchToFit" value="0"> <param name="windowlessVideo" value="0"> <param name="enabled" value="-1"> <param name="enableContextMenu" value="-1"> <param name="fullScreen" value="0"> <param name="SAMIStyle" value> <param name="SAMILang" value> <param name="SAMIFilename" value> <param name="captioningID" value> <param name="enableErrorDialogs" value="0"> <embed src="http://www.emapdigitalradio.com/emapdigitalradio/metafiles/key103.asx" width="145" name="Player" height="40" autostart="True" controls="playbutton" showstatusbar="false" url="http://www.emapdigitalradio.com/emapdigitalradio/metafiles/key103.asx" autoplay="true" uimode="invisible"> </embed></object> <INPUT TYPE="BUTTON" NAME="BtnPlay" VALUE="Play" accesskey=p OnClick="Play()"> <INPUT TYPE="BUTTON" NAME="BtnStop" VALUE="Stop" accesskey=s OnClick="Stop()"> <INPUT TYPE="BUTTON" NAME="BtnMute" VALUE="Mute" accesskey=m OnClick="MuteMe()"> <INPUT TYPE="BUTTON" NAME="BtnUnMute" VALUE="UnMute" accesskey=m OnClick="UnMuteMe()"> <INPUT TYPE="BUTTON" NAME="BtnVolUp" VALUE="VolUp" accesskey=u OnClick="VolumeUp()"> <INPUT TYPE="BUTTON" NAME="BtnVolDown" VALUE="VolDown" accesskey=z OnClick="VolumeDown()"> <INPUT TYPE="BUTTON" NAME="BtnStatus" VALUE="Status" OnClick="Status()"> </body> </html>
Thats my code its to use buttons to control windows media player instead of the media player that is invisible in the background.
Example:
http://faroveryonder.com/hx/test.htm
Note: it only works in IE (for the moment)
Im having 2 problems with it.
1. I want the status to show in a text box not an alert box. So when someone clicks pause it says pause in a text box.
I know that the button has to be changed to text:
From:
To:Code:<INPUT TYPE="BUTTON" NAME="BtnStatus" VALUE="Status" OnClick="Status()">
(taking out the onClick to because it wont be needed)Code:<INPUT TYPE="TEXT" NAME="BtnStatus" VALUE="Status">
However it wont work because of:
It is an alert command.Code:function Status () { x = Player.playState; alert(WMState[x]); }
So my problem is what command could be there to solve my problem of showing the current status (ie playing, stopped, buffering).
I have tried messing wtih the document.write command but javascript isnt my strongest area.
2. Getting it to work in Firefox (and other browsers). Im pretty sure Firefox reads it in a different way by using the getElement command but once again javascript isnt my strongest area.
I would appreciate the help!





Reply With Quote