?
Solved

Embedded Windows Media Player 9 not responding to controls

Posted on 2004-08-14
8
Medium Priority
?
566 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
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!

 
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 2000 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

741 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