1 Replies - 1038 Views - Last Post: 06 December 2010 - 05:49 PM Rate Topic: -----

#1 d.buckner  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 73
  • Joined: 04-December 08

How do you queue audio files to play in a given order?

Posted 06 December 2010 - 05:45 PM

I am working on a personal project utilizing sound files. Right now, I have a directory of sound clips, the program selects a group of five of these and is supposed to play them back in a specific order, however, it is playing it all back at the same time. All five sound at once. How do you get it to play the first, then second, etc. with maybe a slight pause in between?

<?php
    
    $first = rand(0,12);
    $second = rand(0,12);
    $answer = $first * $second;
    
    $sounds = "./sounds/";
    $answer_audio = array();
    $times = "./sounds/times.wav";
    $equals = "./sounds/equals.wav";
    $first_sound = $sounds . $first . ".wav";     
    $second_sound = $sounds . $second . ".wav";
    $answer_sound = $sounds . $answer . ".wav";  

    $audio1 = "<embed hidden = 'true' src='".$first_sound."'>";
    $audio2 = "<embed hidden = 'true' src='".$times."'>";
    $audio3 = "<embed hidden = 'true' src='".$second_sound."'>";
    $audio4 = "<embed hidden = 'true' src='".$equals."'>";
    $audio5 = "<embed hidden = 'true' src='".$answer_sound."'>";
    
    echo $audio1;
    echo $audio2;
    echo $audio3;
    echo $audio4;
    echo $audio5;    
?>



Is This A Good Question/Topic? 0
  • +

Replies To: How do you queue audio files to play in a given order?

#2 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10568
  • View blog
  • Posts: 39,127
  • Joined: 27-December 08

Re: How do you queue audio files to play in a given order?

Posted 06 December 2010 - 05:49 PM

PHP treats HTML as a normal String. Once the PHP script finishes, then the HTML is displayed on the browser. You'll probably want to use something client-side like Javascript to queue the sounds.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1