Solved

Embedded Windows Media Player 9 not responding to controls

Posted on 2004-08-14
8
514 Views
Last Modified: 2008-02-01
The player starts playing fine.

It also "restarts" when i click my play button (meaning the wmpPlay() function) but I can't seem to get the stop button to work (
wmpStop())

When i click my stop button IE (v6) gives me an "Error(s) on Page" message in the status bar.

Here is the code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<SCRIPT>
<!--
function wmpPlay()
{
    Player.filename = "./media/test.mp3";
}

function wmpStop()
{
    Player.controls.stop();
}
-->
</SCRIPT>
<OBJECT ID="Player" height="0" width="0"
       CLASSID="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"
      CODEBASE="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"
      STANDBY="Loading Microsoft Windows Media Player components..."
      TYPE="application/x-oleobject">
      <PARAM name="filename" value="./media/test.mp3">
  <PARAM name="autoStart" value="True">
  <PARAM name="volume" value="100">
  <PARAM name="uiMode" value="invisible">
</OBJECT>
<INPUT TYPE="BUTTON" NAME="BtnPlay" VALUE="Play" OnClick="wmpPlay()">
<INPUT TYPE="BUTTON" NAME="BtnStop" VALUE="Stop" OnClick="wmpStop()">
</body>
</html>
0
Comment
Question by:majnun
  • 3
  • 2
8 Comments
 
LVL 15

Expert Comment

by:Colosseo
Comment Utility
Hi

I copied your code and tried it out... I get an error when I press Play... dont know why but you dont so thats ok :)

For Stop try

Player.stop()

that works ok for me

You said When i click my stop button IE (v6) gives me an "Error(s) on Page" message in the status bar.

To be able to tell what the error is. In internet explorer click Tools > Internet Options

Then on the Advanced tab make sure Display a notification about ever script error is checked

The error that will be displayed is how I worked out what to try for the stop code

Hope that helps

Regards

Scott
0
 
LVL 31

Expert Comment

by:seanpowell
Comment Utility
Hi majnun,

Actually you don't need the script at all, as we can reference the player directly throguh the DOM, like this:

<FORM NAME="myButtons">
   <INPUT NAME="btnPlay" TYPE="Button" VALUE="Play" onclick="document.Player.Play();">
   <INPUT NAME="btnStop" TYPE="Button" VALUE="Stop" onclick="document.Player.Stop();">
</FORM>

So, get rid of the script, and make sure that "document.Player.Play" uses the same name as the ID you use for the player, in this case, "Player"

Thanks,
Sean
0
 

Author Comment

by:majnun
Comment Utility
Scott thanks for the error reporting tip!

Sean that works great, my follow-up question is this, will that work for windows media player plugins for non-ie browsers too?

Thanks!
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 15

Expert Comment

by:Colosseo
Comment Utility
Your welcome majnun glad to help

Scott
0
 
LVL 15

Expert Comment

by:Colosseo
Comment Utility
majnun,

Just so you know I tried this code at work today in Mozilla Firefox and it didnt work as it is

Perhaps with some changes to the way the player is referenced it might be made to work

Regards

Scott
0
 
LVL 31

Accepted Solution

by:
seanpowell earned 500 total points
Comment Utility
Oh dear - somehow I missed the comments on this question, I'm really sorry manjun.

You've probably long since figured this out, but FWIW...

You need to use an alternate method for perfect cross-browser support. Since different version of Netscape and Mozilla handle scripting events differently, it becomes very difficult to get everyone to (play) together happily. You end up either with a song that wont start, or one that won't stop (which can be a good thing - depending on the song...)

So, what we do is simply use some CSS to hide the player for IE, and let every other browser use the embedded player controls instead.

Like this:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<style type="text/css">

/* hides the controls for non-IE browsers */

body > #controls
{
      display:none;
}

</style>

</head>

<body>

<object id="player" height="0" width="0" classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"
codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"
standby="Loading Microsoft Windows Media Player components..."
type="application/x-oleobject">

<param name="filename" value="./media/test.mp3">
<param name="autoStart" value="True">
<param name="volume" value="100">

<embed src="./media/test.mp3" width="366" height="142" type="application/x-mplayer2" pluginspage = "http://www.microsoft.com/Windows/MediaPlayer/" name="mysong">
</embed>

</object>

<div id="controls">
<form name="myButtons">
   <input name="btnPlay" type="Button" value="Play" onclick="document.player.Play();">
   <input name="btnStop" type="Button" value="Stop" onclick="document.player.Stop();">
</form>

</body>
</html>


Thanks, and my apologies again...
Sean
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Do you want to insert HTML5 video into your site? This is the tutorial how to do so. What are the main advantages of HTML5 video? 1) Have good compression, good image quality, and low decode processor use. 2) It is royalty-free 3) It is easi…
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now