Fatal error if no filename passed to Analyze

Locked
vollmerk
User
Posts: 18
Joined: Wed Jun 14, 2006 9:42 pm

Fatal error if no filename passed to Analyze

Post by vollmerk » Thu Jul 05, 2007 3:00 am

This resulted from a bug in my code, however if getid3() couldn't find the file it should return gracefully not cause a fatal error *sniff*

Code: Select all

Fatal error: Uncaught exception 'getid3_exception' with message 'Could not open file ""' in /data/ampache/modules/getid3/getid3.php:153 Stack trace: #0 /data/ampache/lib/class/vainfo.class.php(91): getid3->Analyze(NULL) #1
getid3 2.0.0-b4 with mp3 id3tag last char missing patch applied.

Allan Hansen
getID3() v2 developer
Posts: 445
Joined: Sun May 04, 2003 2:22 pm
Location: Holmegaard, Denmark

Post by Allan Hansen » Thu Jul 05, 2007 5:46 am

From basic demo:

Code: Select all

// Initialize getID3 engine
$getid3 = new getID3;

// Analyze file 
try {

    $getid3->Analyze($filename);

    // Show audio bitrate and length
    echo 'Bitrate:  ' . @$getid3->info['audio']['bitrate'] . '<br>'; 
    echo 'Playtime: ' . @$getid3->info['playtime_string']  . '<br>';

}
catch (Exception $e) {
    
    echo 'An error occured: ' .  $e->message;
}

Locked