javascript - Play sound files one by one according to current number -


i understand question similar have been asked before, none of answer problem.

i working on queue system customer ticket kiosk , wait counter call number, example 1023. have sound files of each number in .mp3 format. btw, project developed using php.

the 2 requirements sound files must play according number example if current number 1023, need play 1.mp3, 0.mp3, etc.

another problem these files need played 1 after previous ends. managed 1st part sounds play together. please me, below of code 1st part.

soundmanager.inc

public function getsound($in_value) {     $value = $in_value;      switch ($value){     case "0":         $path = "sounds/0.mp3";         echo "<audio autoplay>";         echo "<source src=".$path." >";         echo "</audio>";         break;     case "1":         $path = "sounds/1.mp3";         echo "<audio autoplay>";         echo "<source src=".$path." >";         echo "</audio>";         break;     case "2":         $path = "sounds/2.mp3";         echo "<audio autoplay>";         echo "<source src=".$path." >";         echo "</audio>";         break; //and more 

getsound.php

$word = isset($_post['no']) ? $_post['no'] : ''; $array = str_split($word); $one = $array[0]; $two = $array[1]; $three = $array[2]; $four = $array[3];  $um = soundmanager::getinstance();  $um->getsound($one); $um->getsound($two); $um->getsound($three); $um->getsound($four); 

here go.

var audiofiles = ["http://www.magnac.com/sounds/onlyroadlarge.mp3", "http://www.magnac.com/sounds/paradiserowlarge.mp3", "http://www.magnac.com/sounds/lordslarge.mp3"]; var audio = document.createelement("audio"); var audioidx = 0; audio.addeventlistener('ended', function () {   audioidx++;   if (audioidx >= audiofiles.length) audioidx = 0;   this.src = audiofiles[audioidx];   this.play(); }); audio.src = audiofiles[audioidx]; audio.play(); 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -