Solved

Embedded Windows Media Player 9 not responding to controls

Posted on 2004-08-14
8
539 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
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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

773 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