Solved

Managing Media Player object

Posted on 2008-10-30
2
263 Views
Last Modified: 2013-11-05
Hi,

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
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="AutoStart" Value="False">
<PARAM NAME="FileName" VALUE="_page/alarm_2.wav">
<EMBED type="application/x-mplayer2"
pluginspage="http://www.microsoft.com/Windows/
MediaPlayer/" SRC="_page/alarm_2.wav" name="WinMedia"
autostart=0 width=160 height=120 ShowStatusBar=true
ShowControls=false>
</EMBED>
</OBJECT>


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.
thanks.

0
Comment
Question by:kenanerdey
2 Comments
 
LVL 7

Accepted Solution

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

          <script language=javascript>
          function fnPlaySound(){
              document.getElementById('WinMedia').Play();
              }</script>

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);";
}



0
 

Author Closing Comment

by:kenanerdey
ID: 31511710
thanks a lot.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
React or Angular? 6 51
Angular- another way of coding hide and display 3 36
alert before form submission 6 27
Check if Object property exists? 3 18
This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
This article discusses how to create an extensible mechanism for linked drop downs.
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…

914 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now