These forums are currently read-only due to receiving more spam than actual discussion. Sorry.

It is currently Sat Dec 02, 2017 4:04 pm Advanced search

[HTML5]Is it Possible? ON/OFF Button in One

Here you can discuss things related to HTML and the Web in general that do not fit in to other categories.

[HTML5]Is it Possible? ON/OFF Button in One

Postby Fabian95qw » Fri Feb 03, 2012 9:29 am

Hello my name is Fabian and i'm a newbie at HTML5.

I'm writing on a Site on which 30 Different Streams are running but i have a problem by Programming the Codes for the Buttons of the Players. When i Press one Button the music starts playing. When i press another button, both streams are active.

I need a piece of Javascript, which automaticel Stops other streams, when the stream i pressed on is ready to play.

Code for now:

Code: Select all
<body background="background.jpg"></body>

<script>
function EvalSound(soundobj)
{
var thissound=document.getElementById(soundobj);

thissound.play();
}
</script>

<h1>
   <html>
      <audio ID="APlayer1" STYLE="position:absolute;TOP:500px;"src="[IP]" preload="auto" autobuffer></audio>

      <audio ID="APlayer4" STYLE="position:absolute;TOP:500px;"src="[IP]" preload="auto" autobuffer></audio>

      <audio ID="APlayer9" STYLE="position:absolute;TOP:500px;"src="[IP]" preload="auto" autobuffer></audio>

      <audio ID="APlayer14" STYLE="position:absolute;TOP:500px;"src="[IP]" preload="auto" autobuffer></audio>

      <button STYLE="position:absolute; TOP:35px;left:35px;width:100px; height:100px;" type="button" onClick="EvalSound('APlayer1');"><img STYLE="width:75px; height:75px" src="ButtonPlayer1.jpg"/></button>

      <button STYLE="position:absolute; TOP:35px;left:170px;width:100px; height:100px;" type="button" onClick="EvalSound('APlayer4');"><img STYLE="width:75px; height:75px" src="ButtonPlayer4.jpg"/></button>

      <button STYLE="position:absolute; TOP:35px;left:305px;width:100px; height:100px;" type="button" onClick="EvalSound('APlayer9');"><img STYLE="width:75px; height:75px" src="ButtonPlayer9.jpg"/></button>

      <button STYLE="position:absolute; TOP:35px;left:440px;width:100px; height:100px;" type="button" onClick="EvalSound('APlayer14');"><img STYLE="width:75px; height:75px" src="ButtonPlayer14.jpg"/></button>

      <button STYLE="position:absolute; TOP:35px;left:845px;width:100px; height:100px;" type="button" onClick="EvalSound('');"><img STYLE="width:75px; height:75px" src="All_Player_Button.jpg"/></button>
   
      <img STYLE="position:absolute; TOP:175px; LEFT:35px; width:100px; height:100px" src="S-Button1.jpg"/>
      <img STYLE="position:absolute; TOP:175px; LEFT:170px; width:100px; height:100px" src="S-Button2.jpg"/>
      <img STYLE="position:absolute; TOP:175px; LEFT:305px; width:100px; height:100px" src="S-Button3.jpg"/>
      <img STYLE="position:absolute; TOP:175px; LEFT:440px; width:100px; height:100px" src="S-Button4.jpg"/>
      <img STYLE="position:absolute; TOP:175px; LEFT:575px; width:100px; height:100px" src="S-Button5.jpg"/>

      <img STYLE="position:absolute; TOP:350px; LEFT:440px; width:100px; height:100px" src="Swiss_Jazz_Button.jpg"/>
      <img STYLE="position:absolute; TOP:350px; LEFT:575px; width:100px; height:100px" src="Swiss_POP_Button.jpg"/>

      <DIV style="position:absolute; top:135px; left:52px; width:100px; height:35px; font-size: 14pt; color:#FFFFFF;"> Player1 </DIV>
      <DIV style="position:absolute; top:135px; left:185px; width:100px; height:35px; font-size: 14pt; color:#FFFFFF;"> Player4 </DIV>
      <DIV style="position:absolute; top:135px; left:322px; width:100px; height:35px; font-size: 14pt; color:#FFFFFF;"> Player9 </DIV>
      <DIV style="position:absolute; top:135px; left:457px; width:100px; height:35px; font-size: 14pt; color:#FFFFFF;"> Player14 </DIV>
      <DIV style="position:absolute; top:135px; left:845px; width:100px; height:35px; font-size: 14pt; color:#FFFFFF;"> All Players </DIV>

      <DIV style="position:absolute; top:275px; left:35px; width:100px; height:35px; font-size: 14pt; color:#FFFFFF;"> RnB/SOUL </DIV>
      <DIV style="position:absolute; top:275px; left:175px; width:100px; height:35px; font-size: 14pt; color:#FFFFFF;"> Alternativ </DIV>
      <DIV style="position:absolute; top:275px; left:320px; width:100px; height:35px; font-size: 14pt; color:#FFFFFF;"> Smooth Jazz </DIV>
      <DIV style="position:absolute; top:275px; left:448px; width:100px; height:35px; font-size: 14pt; color:#FFFFFF;"> Mash Up </DIV>
      <DIV style="position:absolute; top:275px; left:592px; width:100px; height:35px; font-size: 14pt; color:#FFFFFF;"> Classic Rock </DIV>

      <DIV style="position:absolute; top:450px; left:445px; width:100px; height:35px; font-size: 14pt; color:#FFFFFF;"> Swiss Jazz </DIV>
      <DIV style="position:absolute; top:450px; left:582px; width:100px; height:35px; font-size: 14pt; color:#FFFFFF;"> Swiss POP </DIV>


      
   <br>
   <br>
   </html>
</h1>


These are only a few of the 30 Streams.

I hope someone can help.
Fabian95qw
<h6>
 
Posts: 1
Joined: Fri Feb 03, 2012 8:40 am

Re: [HTML5]Is it Possible? ON/OFF Button in One

Postby zcorpan » Mon Feb 20, 2012 10:41 am

Code: Select all
<script>
var lastSound;
function EvalSound(soundobj)
{
var thissound=document.getElementById(soundobj);
if (lastSound) {
  lastSound.pause();
  lastSound.currentTime = 0;
}
thissound.play();
lastSound = thissound;
}
</script>
zcorpan
<article>
 
Posts: 807
Joined: Tue Feb 06, 2007 8:29 pm
Location: Sweden


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest