Search code examples
phpmp3mediagetid3

getId3: Undefined index: playtime_string


I am trying to retrieve the duration of some songs in my project. I integrated getID3 in my app using the phansys bundle - it works fine but for some of my songs I get an error:

Undefined index: playtime_string.

Here is my source code:

        $getID3 = new getID3;
        $ThisFileInfo = $getID3->analyze($this->getFullpath());
        if (isset($ThisFileInfo['playtime_string'])){
           $len= $ThisFileInfo['playtime_string']; 
        }
        else{
            /*
            * Here i wonder what i have to do in this case
            */
        }

I am really stuck now I am in real need of getting the songs duration. In fact I must get this information in my mobile application.
Is there any other way to get mp3s duration in php?


Solution

  • The problem was caused by the fact that the mp3s were broken.i tried reading them using ffmpeg but it fails and it shows that these mp3s have 0 Ko as size