Managing Media Player object

Posted on 2008-10-30
Last Modified: 2013-11-05

i have a php page. in this page i check a value taken from a text file. If the value is bigger than a threshold number, i want to make a sound( an alarm). Now i add an media player object.

<OBJECT ID="WinMedia" width=160 height=120
mplayer/en/,1,52,701" standby=
"Loading Microsoft® Windows® Media Player components..."
<PARAM NAME="AutoStart" Value="False">
<PARAM NAME="FileName" VALUE="_page/alarm_2.wav">
<EMBED type="application/x-mplayer2"
MediaPlayer/" SRC="_page/alarm_2.wav" name="WinMedia"
autostart=0 width=160 height=120 ShowStatusBar=true

then in php block i check the value and trigger play

if ($value > $threshold)
echo <script> document.getElementById('WinMedia').Play();</script>";

but it doesn't play and sound.
What's the problem.

Question by:kenanerdey
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

Accepted Solution

bluV11t earned 250 total points
ID: 22843451
I added a js function for making the sound play
(in head tag):

          <script language=javascript>
          function fnPlaySound(){

Then I did the check and added a timeout to the onLoad event of the body for playing the sound

(in onLoad event on body tag):
if ($value > $threshold)
echo "window.setTimeout('fnPlaySound();', 1000);";


Author Closing Comment

ID: 31511710
thanks a lot.

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
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…

733 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