question about php and music files

Discussion in 'PHP' started by JEET, May 20, 2007.

  1. #1
    Hi,
    Is there any way to know the "music play length" (track time) from an mp3, or wav file using "php"?
    What I want to do is play a file, and "as soon as it stops", play another one... Possible? :)
    Any code is extremely appreciated.

    Thanks :)
     
    JEET, May 20, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    nico_swd, May 20, 2007 IP
  3. markhanrry

    markhanrry Well-Known Member

    Messages:
    229
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    120
    #3
    Go to phpclasses.org I have seen one class for this one.

    Thanx.
     
    markhanrry, May 20, 2007 IP
  4. greenrob

    greenrob Peon

    Messages:
    58
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Yeah that's what I've been using for my previous project -- phpclasses.org
     
    greenrob, May 20, 2007 IP
  5. JEET

    JEET Notable Member

    Messages:
    3,832
    Likes Received:
    502
    Best Answers:
    19
    Trophy Points:
    265
    #5
    Hi,
    I tried your class, but it seems to return no output on php5.
    Here's what I did:
    <?php
    //Full code from your class is here
    ?>
    <?php
    $path = $_SERVER['DOCUMENT_ROOT']."dir/";
    echo '<h3>'. $path. '</h3>';
    $file = "red.mp3";
    $tags = new mp3Tags($path, $file);
    echo "<pre>";
    print_r($tags);
    echo "</pre>";
    ?>


    The script seems to end at the "echo <h3>" line.
    The echo "<pre>" is never printed on webpage...

    Am I doing something wrong here?
    Thanks :)


     
    JEET, May 20, 2007 IP
  6. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #6
    Try setting this on top of your page:
    
    error_reporting(E_ALL);
    ini_set('display_errors', '1');
    
    PHP:
    And try removing the $_SERVER['DOCUMENT_ROOT'], like this:
    
    <?php
    $path = "dir/";
    echo '<h3>'. $path. '</h3>';
    $file = "red.mp3";
    $tags = new mp3Tags($path, $file);
    echo "<pre>";
    print_r($tags);
    echo "</pre>";
    ?>
    
    PHP:
    I've used it, and it worked for me.
     
    nico_swd, May 20, 2007 IP
  7. JEET

    JEET Notable Member

    Messages:
    3,832
    Likes Received:
    502
    Best Answers:
    19
    Trophy Points:
    265
    #7
    Hi,
    It's giving the following error:
    Notice: Use of undefined constant bool - assumed 'bool' on line 243

    Line 243 is the call to function line:
    $tags= new mp3Tags($path, $file);
     
    JEET, May 20, 2007 IP
  8. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #8
    In the first lines of the code, replace this:
    
    private $id3v1 = bool;
    private $id3v2 = bool; 
    
    PHP:
    With:
    
    private $id3v1l;
    private $id3v2;
    
    PHP:
     
    nico_swd, May 20, 2007 IP
    JEET likes this.
  9. JEET

    JEET Notable Member

    Messages:
    3,832
    Likes Received:
    502
    Best Answers:
    19
    Trophy Points:
    265
    #9
    Hi,
    I can't seem to get your class working, however you did give me an idea of what is to be done. I found a class in google search and it returns an array with playtimeseconds. I think this will do. Now all I need to do is make a loop at set time intervals.

    Thank you so much for helping me and also for taking time trouble shooting with me. :)
    Green reps added.

    regards
    jeet :)
     
    JEET, May 20, 2007 IP