Mp3 meta data Error fixing

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Mp3 meta data Error fixing

    PHP Code:
    <?
    include('db.php');

    function scanID3($file)
    {
    require_once 'system/getid3/getid3.php'; //change to getid3 location
    $res = false;
    $getID3 = new getID3();
    $id3 = $getID3->analyze($file);
    if (isset($id3["fileformat"]) && $id3["fileformat"] == "mp3") {
    $res = array();
    $res["file"] = $file;
    $res["album"] = $id3["tags"]["id3v2"]["album"][0];
    $res["title"] = $id3["tags"]["id3v2"]["title"][0];
    if (isset($id3["tags"]["id3v2"]["artist"][0])) {
    $res["artist"] = $id3["tags"]["id3v2"]["artist"][0];
    } else {
    $res["artist"] = "Unknown";
    }
    $res["trackNumber"] = $id3["tags"]["id3v2"]["track_number"][0];
    $res["link"] = str_replace(["_aaID_", "_trackID_"], [md5($res["artist"] . "_" . $res["album"]), $res["trackNumber"]], $this->config["link"]);
    if (strpos($res["trackNumber"], "/")) {
    $res["trackNumber"] = substr($res["trackNumber"], 0, strpos($res["trackNumber"], "/"));
    }
    $res["trackNumber"] = sprintf("d", $res["trackNumber"]);
    if(isset($id3['comments']['picture'][0])){
    $res['image'] = 'data:'.$id3['comments']['picture'][0]['image_mime'].';charset=utf-8;base64,'.base64_encode($id3['comments']['picture'][0]['data']);
    }
    else
    {
    $res['image'] = 'unknown';
    }
    } else {
    //var_dump($file);
    }

    return $res;
    }

    $id=$_REQUEST['id'];
    $query = "update files SET views = views+1 where id ='".$id."'";
    $update = mysqli_query($con,$query) or die(mysql_error());
    $query = "SELECT * from files where id='".$id."'";
    $result = mysqli_query($con,$query) or die(mysql_error());
    $row = mysqli_fetch_assoc($result);

    $url = $row['mp3path'];
    $mp3data = scanID3($url);
    echo 'Album: '.$mp3data['album'].'<br/>';
    echo 'Title: '.$mp3data['title'].'<br/>';
    echo 'Artist: '.$mp3data['artist'].'<br/>';
    echo 'Track number: '.$mp3data['trackNumber'].'<br/>';
    if($mp3data['image']!='unknown')
    {
    echo '<img src="'.$mp3data['image'].'" alt=""/><br/>';
    }
    ?>
    When Run this php following error is coming please anyone can help me on this??

    Notice: Undefined index: title in /home/mysong/public_html/file2.php on line 14

    Notice: Trying to access array offset on value of type null in /home/sample/public_html/file2.php on line 14

    Notice: Undefined index: track_number in /home/sample/public_html/file2.php on line 20

    Notice: Trying to access array offset on value of type null in /home/sample/public_html/file2.php on line 20

    Fatal error: Uncaught Error: Using $this when not in object context in /home/mysong/public_html/file2.php:21 Stack trace: #0 /home/sample/public_html/file2.php(4: scanID3('system/files/Wa...') #1 {main} thrown in /home/sample/public_html/file2.php on line 21

    #2
    undefined index are not that important, but $this->config["link"] should be removed or replaced, or remove the thole line:
    HTML Code:
    $res["link"] = str_replace(["_aaID_", "_trackID_"], [md5($res["artist"] . "_" . $res["album"]), $res["trackNumber"]], $this->config["link"]);
    Advertise your mobile site for FREE with AdTwirl

    Comment


      #3
      Worked 100% Gum Slone Thank You very much.. Is the any way to edit same mp3metadata from php??

      Comment

      Working...
      X