Using getID3 to parse ID3

980 Views Asked by At

////////////////////// Solution //////////////////////

There was a problem with my syntax, I was using + instead of . to concatenate Music/ and $file.

require ('getid3/getid3.php');


         $getID3 = new getID3;


            if ($handle = opendir('Music/')) {
            while (false !== ($file = readdir($handle))) {
                if ($file != "." && $file != "..") {


                //echo $file;



                $ThisFileInfo = $getID3->analyze("Music/".$file);

                // Delete temporary file

                echo '<li><a href=" Music/'.$file.'">'.$file.'</a>  <br>';
                print_r ($ThisFileInfo);
                echo   '</li>' ;
                }
            }
closedir($handle);



            }

///////////////////////// Problem ////////////////////////

The short explanation is this loop is supposed to extract meta data and print it to the page with the download link. It will do this as many times as there are files in the listed directory. The loop works perfectly, however the array is not extracting the meta data. I have it running locally on an xampp server.

        require ('getid3/getid3.php');


         $getID3 = new getID3;


            if ($handle = opendir('Music/')) {
            while (false !== ($file = readdir($handle))) {
                if ($file != "." && $file != "..") {

                //echo $file;


                $ThisFileInfo = $getID3->analyze("Music/ " + $file);

                // Delete temporary file

                echo '<li><a href=" Music/'.$file.'">'.$file.'</a>  <br>';
                print_r ($ThisFileInfo);
                echo   '</li>' ;
                }
            }
closedir($handle);

    }

This is what I get on the page.

Lunar_2_Blue_Star_Prayer_OC_ReMix.mp3 Array ( [GETID3_VERSION] => 1.9.12-201602240818 [error] => Array ( [0] => Could not open "0" (!is_readable; !is_file; !file_exists) ) ) Retro_City_Rampage_Retrohead_Five_OC_ReMix.mp3 Array ( [GETID3_VERSION] => 1.9.12-201602240818 [error] => Array ( [0] => Could not open "0" (!is_readable; !is_file; !file_exists) ) ) Super_Mario_RPG_The_Usurper_Queen_OC_ReMix.mp3 Array ( [GETID3_VERSION] => 1.9.12-201602240818 [error] => Array ( [0] => Could not open "0" (!is_readable; !is_file; !file_exists) ) )

file structure more structure

1

There are 1 best solutions below

0
jackthemayor On

////////////////////// Solution //////////////////////

There was a problem with my syntax, I was using + instead of . to concatenate Music/ and $file.

require ('getid3/getid3.php');

     $getID3 = new getID3;


        if ($handle = opendir('Music/')) {
        while (false !== ($file = readdir($handle))) {
            if ($file != "." && $file != "..") {


            //echo $file;



            $ThisFileInfo = $getID3->analyze("Music/".$file);

            // Delete temporary file

            echo '<li><a href=" Music/'.$file.'">'.$file.'</a>  <br>';
            print_r ($ThisFileInfo);
            echo   '</li>' ;
            }
        }

closedir($handle);

        }