Playing sound files in all major browsers...

hi,
this code works fine in IE and NN, but not in Mozilla, FireFox or Opera, I was wondering is this a global issue or just something is wrong with my code or my browsers? please copy and paste this code in order to check and provide correct sollution. (this sound files are from some random website which I found somehow... if they're not working try yours)

thanks
 dave

<html>
<head>

<script language=Javascript>

var current=1,tmr=null;

function Load_(){

   if(document.getElementById("snd"+current).ReadyState==4)  
        current++;  
   if(current==4){
        current=1;      
        document.getElementById("snd"+current).play();
        setTimeout('Play_()',10)
        return
   }
   setTimeout('Load_()',10);
}

function Play_(){

   if(current==4){
         current=1;
         Load_();
         return
   }  
   if(document.getElementById("snd"+current).PlayState==0){
         current++;  
         if(current==4){
               current=1;
               Load_();
               return
         }    
         document.getElementById("snd"+current).play();          
   }
   setTimeout('Play_()', 250)
}
</script>

</head>
<body topmargin="5" leftmargin="5" rightmargin="5" bottommargin="5" onload="Load_()">

<object id="snd1" CLASSID="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95">
   <param name="FileName"  value="http://www.readplease.com/common/sounds/crystal.mp3">
   <param name="AutoStart"                 value="false">
   <param name="SendPlayStateChangeEvents" value="true">
   <param name="ShowAudioControls"         value="false">
</object>

<object id="snd2" CLASSID="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95">
   <param name="FileName"  value="http://www.readplease.com/common/sounds/julia.mp3">
   <param name="AutoStart"                 value="false">
   <param name="SendPlayStateChangeEvents" value="true">
   <param name="ShowAudioControls"         value="false">
</object>

<object id="snd3" CLASSID="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95">
   <param name="FileName"  value="http://www.readplease.com/common/sounds/lauren.mp3">
   <param name="AutoStart"                 value="false">
   <param name="SendPlayStateChangeEvents" value="true">
   <param name="ShowAudioControls"         value="false">
</object>


</body>
</html>
LVL 13
davidlars99Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
ZDevilConnect With a Mentor Commented:
You're using "OBJECT"-tag to include the music files on the page, Mike is wondering if Mozilla still supports this. I'm not sure, but try to change it to EMBED, see if it works.

Plus, you're trying to play MP3-files, which cannot be played back using a browser alone, it needs to have some sort of media player plug in. IE has it by default, I'm not sure which one you should install for Mozillla.

Also, have you thought about using Flash? That way anyone with a Flash-plug in could play the movie and hear the sounds.

Z
0
 
frugleConnect With a Mentor Commented:
Does Mozilla, ff and opera have full access to the object tag now? Last time I inflicted music on a website I used the embed tag too.

Mike
0
 
davidlars99Author Commented:
sorry Mike, I didn't get you... come again please
0
Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

 
frugleCommented:
What I mean is although most browsers can use the object tag, it's not always fully supported.

Read Drew's article at http://www.alistapart.com/articles/flashsatay/ [alistapart.com] which, whilst not being completely relevant to playing music will give you a better insight into embedding other source within it.

Mike
0
 
RedLavaConnect With a Mentor Commented:
Hi,

Have you thought about writting a Flash app to play sounds?

This will save many of the headaches of browser compatability as long as the user has the flash plugin installed.

This also allows buffering and pre-configured controls etc.

If you need a hand let me know.

Good luck

RedLava
0
 
davidlars99Author Commented:
thanks to you all, the reason I needed this help is there was a article in some topic here and I provided this code, when I realized It was not working in mozilla, FF and opera. and I was kinda heartbroken that's all.
btw, I tryied <embed> but no luck problem remains the same.

and RedLava thanks for you advice, I will need help with flash soon I'm still not so far away from flash, btw I'm looking for a good flash book to start working on it.
there is a website who has whole MX Studio for $69.00 here see for yourself. is this right I mean whole thing for so cheap?

http://www.ibackups.net/index.php?main=products&sub=showcateg&id=5

cheers!
 dave
0
 
RedLavaCommented:
It seems a bit too good to be true doesn't it.

As for books one of the best I have found is the Flash MX Bible ISBN: 0764536567. They also do an Actionscript version too.

The best option is to get a developer online to write an app for you, it means you don't need the software, and if it is done correctly in the case of a sound player it would work very much like any media player and use external files loaded dynamically, like winamp, which means you may never need to change the player... well short term at least.

If you need any pointers on writing the app yourself let me know or if you need the app written it's one way is to break it into tasks and allow developers to supply and add the code for the specific task to the project, this would probaby mean you don't even need to buy Flash but can watch the project grow and learn as you go. The other option is to commission a developer to design it for you to your specs, this will probably get you the most professional dedicated package but may cost you.

Hope this help, please let me know if I can help you with this project.

RedLava
0
 
ZDevilCommented:
Not to be picky, but I think I suggested Flash almost a day before RedLava...

And yes, I think it's the best way.

Z
0
 
davidlars99Author Commented:
ZDevil, you're not picky. you're right it's my fault, but since no comment makes my problem go away it doesn't matter. here is why I needed to solve this problem or at least find the answer why it's not plaiyng in those browsers.
here's another chalenge boys...

http://www.experts-exchange.com/Web/Q_21093792.html

cheers!
 dave
0
 
davidlars99Author Commented:
ok, since nobody is able to solve my issue I will do it to myself. here' how to incorporate in all browsers:

WINDOWS MEDIA:

<object id="wm"
classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"
width="320" height="50"
TYPE="application/x-oleobject"
CODEBASE="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715"
standby="Loading Microsoft¨ Windows¨ Media Player components..."  VIEWASTEXT>
<PARAM name="src" value="file1.wma">
<PARAM name="CONSOLE" value="one">
<PARAM name="ShowControls" value="True">
<PARAM name="ShowStatusBar" value="True">
<PARAM name="ShowDisplay" value="no">
<PARAM name="autostart" value="true">
<PARAM name="AnimationAtStart" value="false">
<PARAM name="BACKGROUNDCOLOR" value="#ffffff">
<PARAM name="CENTER" value="true">
<PARAM name="autoSize" value="false">
<PARAM NAME="displaySize" value="0">
      <Embed      src="file1.wma"
            TYPE="application/x-mplayer2"
            pluginspage="http://www.microsoft.com/Windows/MediaPlayer/"
            Name="wm"
            Width="320"
            autoSize="false"
            showdisplay="no"
            displaySize="0"
            Height="46"
            center="true"
            AutoStart="True">
      </embed>
</object>





REAL PLAYER:

<OBJECT ID="rp" CLASSID="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" WIDTH=320 HEIGHT=50>
<PARAM NAME="SRC" VALUE="file1.rm">
<PARAM NAME="CONTROLS" VALUE="All">
<PARAM NAME="CONSOLE" VALUE="one">
<PARAM NAME="AUTOSTART" VALUE="true">
<EMBED name="rp" SRC="file1.rm" WIDTH=320 HEIGHT=50 NOJAVA=true CONTROLS=All CONSOLE=one AUTOSTART="true">
</OBJECT>




QUICK TIME:

<object ID="qt" WIDTH=300 HEIGHT=26 CLASSID="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95">
   <param name="FileName"  value="file1.m4p">
   <param name="AutoStart"                 value="true">
   <param name="volume"                    value="0">
   <param name="loop"                      value="false">
   <param name="hidden"                    value="false">
   <embed name="qt" qtsrc="file1.m4p" autoplay="true" controller="true" loop="false" pluginspage="http://www.apple.com/quicktime/download/"></embed>
</object>


cheers!
 dave
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.