Solved

Playing sound files in all major browsers...

Posted on 2004-08-16
10
1,452 Views
Last Modified: 2011-10-03
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>
0
Comment
Question by:davidlars99
  • 4
  • 2
  • 2
  • +1
10 Comments
 
LVL 10

Assisted Solution

by:frugle
frugle earned 167 total points
ID: 11815147
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
 
LVL 13

Author Comment

by:davidlars99
ID: 11815441
sorry Mike, I didn't get you... come again please
0
 
LVL 1

Accepted Solution

by:
ZDevil earned 167 total points
ID: 11817928
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
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 
LVL 10

Expert Comment

by:frugle
ID: 11817959
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
 
LVL 4

Assisted Solution

by:RedLava
RedLava earned 166 total points
ID: 11826615
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
 
LVL 13

Author Comment

by:davidlars99
ID: 11826670
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
 
LVL 4

Expert Comment

by:RedLava
ID: 11826877
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
 
LVL 1

Expert Comment

by:ZDevil
ID: 11827650
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
 
LVL 13

Author Comment

by:davidlars99
ID: 11830325
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
 
LVL 13

Author Comment

by:davidlars99
ID: 11851550
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

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

827 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