Link to home
Start Free TrialLog in
Avatar of davidlars99
davidlars99Flag for United States of America

asked on

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>
SOLUTION
Avatar of frugle
frugle

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of davidlars99

ASKER

sorry Mike, I didn't get you... come again please
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of frugle
frugle

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
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
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
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
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...

https://www.experts-exchange.com/questions/21093792/Play-different-sound-files-sequential-in-a-row.html

cheers!
 dave
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