Solved

Embedded Windows Media Player 9 not responding to controls

Posted on 2004-08-14
8
561 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
Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

 
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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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 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…

695 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