İyinet'e Hoşgeldiniz!

Türkiye'nin En Eski Webmaster Forum'una Hemen Kayıt Olun!

Kayıt Ol!

Kuran mp3` dosyalaının tagını değiştirerek resim ekleme

XiechenG

0
İyinet Üyesi
Katılım
16 Ağustos 2009
Mesajlar
154
Reaction score
1
İyi günler.
Arkadaşlar kuran sitemdeki mp3`lerin taglarını kodla yeniliyorum.
Lakin mp3`lere resim ekleyemiyorum.
KUllandığım kod şudur:
PHP:
<?php 



 define(_Title,"TIT2"); 

 define(_Artist,"TPE1"); 

 define(_Group,"TPE2"); 

 define(_Album,"TALB"); 

 define(_Genre,"TCON"); 

 define(_TrackNo,"TRCK"); 

 define(_Year,"TYER"); 

 $frames = array(_Album=>"", 

  _TrackNo=>"1", 

  _Title=>"001 Al-Fatihah (The Opening)",

  _Artist=>"", 

  _Group=>"", 

  _Year=>"", 

  _Genre=>"Quran"); 



#.......................................... 

#       WRITE ID3 TAGS (Write MP3 [v1, v2] 

#.......................................... 

function writeTags($mp3) { 

    $fl = file_get_contents($mp3); 

    $Header = substr($fl,0,10); 

    $tagLen = calcDecTagLen(substr($Header,6,4),$tagLen); 

    $music = substr($fl,$tagLen+10,-128); 

    # Can use input Header for output but you may 

    # wish to change the output filename for testing 

        $tagLen = 1024; # or whatever you like >your actual 

        $Header = substr($Header,0,6).setHexTagLen($tagLen); 

        file_put_contents($mp3,mkV2Tag($Header,$tagLen).$music.mkV1Tag()); 

} 

#   Create the V2 tag 

function mkV2Tag($Hdr,$tagLen) { 

    Global $frames; 

    $lisanssız = chr(0); 

    $nl3 = $lisanssız.$lisanssız.$lisanssız;            # 0 bytes for flags and encoding 

    $out = ""; 

    foreach($frames as $ky=>$val) { 

        $n=strlen($val)+1; 

        $out.= $ky.mkFrmLen($n).$nl3.$val; 

        } 

    return $Hdr.str_pad($out,$tagLen,$lisanssız); 

    } 

#    Calculate Tag Length from bytes 6-10 of existing header 

function calcDecTagLen($word) { 

    $m = 1; 

    $int = 0; 

    for ($i=strlen($word)-1;$i>-1;$i--) { 

        $int +=$m*ord($word[$i]); 

        $m=$m*128; 

        } 

    return $int; 

    } 

#    Make the 4 byte frame length value for the V2tag 

function mkFrmLen($int) { 

    $hx = ""; 

    while ($int>0) { 

        $n = $int % 256; 

        $hx = chr($n).$hx; 

        $int=floor($int/256); 

        } 

    return str_pad($hx,4,chr(0),STR_PAD_LEFT); 

    } 

#    Create the 128 byte V1 tag 

function mkV1Tag() { 

    Global $frames; 

    $tagOut = "TAG". 

        adj($frames[_Title]). 

        adj($frames[_Artist]). 

        adj($frames[_Album]). 

        str_pad($frames[_Year],4). 

        str_pad(" ",29," "). 

        chr($frames[_TrackNo]). 

        chr($n); 

    return $tagOut; 

    } 

#    Pad the header to 30 characters 

function adj($str) { 

    return substr(str_pad($str,30,chr(0)),0,30); 

    } 

    

$papqa = "../../../Ahmad Al-Hawashi/";



#     This is a simple example for an mp3 in current folder    

    writeTags($papqa."001.MP3"); 



?> 





The setHexTagLen can be figured out from the calcDecTagLen but here's some sample code. 



<?php 

function setHexTagLen($int) { 

    $n = pow(128,3); 

    $intVar = $int; 

    $m = ""; 

    for ($i=0;$i<4;$i++) { 

        $m .= chr(floor($intVar/$n)); 

        $intVar = $intVar % $n; 

        $n=$n/128; 

        } 

header("Location: Set_Name_002.php");

    return $m; 

} 



?>
Yardımlarınızı bekliyorum.
 

Türkiye’nin ilk webmaster forum sitesi iyinet.com'da forum üyeleri tarafından yapılan tüm paylaşımlardan; Türk Ceza Kanunu’nun 20. Maddesinin, 5651 Sayılı Kanununun 4. maddesinin 2. fıkrasına göre, paylaşım yapan üyeler sorumludur.

Üst