Solved

Embedded Windows Media Player 9 not responding to controls

Posted on 2004-08-14
8
554 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
8 Comments
 
LVL 15

Expert Comment

by:Colosseo
ID: 11799183
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
ID: 11799871
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
ID: 11802104
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 15

Expert Comment

by:Colosseo
ID: 11805379
Your welcome majnun glad to help

Scott
0
 
LVL 15

Expert Comment

by:Colosseo
ID: 11808921
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
ID: 11921677
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
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…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

738 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