XAMPP (Windows) 上的 PECL 扩展安装 [英] PECL extension installation on XAMPP (Windows)

查看:53
本文介绍了XAMPP (Windows) 上的 PECL 扩展安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一些帮助,已经尝试过,但我什至没有想过要赢.

I need some help please, have tried but am not even close to thinking about winning.

我需要在 XAMPP(v7.4.5) for Windows 上运行 ID3 PECL.

I need to get the ID3 PECL running on XAMPP(v7.4.5) for Windows.

昨天我花了一整天的时间尝试阅读 PECL 文章 在 PHP.net 网站上,不幸的是,它对我来说没有多大意义,因为我的知识还没有达到那个水平.我也试过寻找 ID3 扩展名的 dll 文件,但找不到.ID3 PECL 页面只有源文件可供下载.

I have spent the day yesterday trying to work through the PECL articles on the PHP.net website and it unfortunately does not make much sense to me, as my knowledge is not on that level yet. I have also tried looking for a dll file for the ID3 extension, but cannot find any. Only the source files are available for download for the ID3 PECL page.

也许有足够耐心的人可以用更外行的术语来解释这个过程......对我来说就像是愚蠢的吗?

Is there perhaps someone with enough patience who can explain the process in more layman's terms... dumb it down for me as it were?

任何和所有帮助将不胜感激.

Any and all help would be greatly appreciated.

编辑

有人可以帮忙吗?

在 Lelio 的帮助下,我现在有一种从 MP3 中提取信息的方法,我添加了两行来访问 Genre 以及 Attached Picture 块.Genre 块有效.但是附加图片块没有.

With the help of Lelio I now have a way to extract info from an MP3, I have added two lines to access the Genre as well as Attached Picture blocks. The Genre block works. The Attached Picture block however, does not.

这是更新后的代码,它保存为一个名为 script-mp3-tag-reader.php 的单独 php 文件:

Here is the updated code which is saved as a separate php file called script-mp3-tag-reader.php:

<?php
    function tagReader($file)
    {
        $id3v23 = array("TIT2","TALB","TPE1","TRCK","TDRC","TLEN","USLT","TCON","APIC");
        $id3v22 = array("TT2","TAL","TP1","TRK","TYE","TLE","ULT","TCO");
        $fsize = filesize($file);
        $fd = fopen($file,"r");
        $tag = fread($fd,$fsize);
        $tmp = "";
        fclose($fd);
        if (substr($tag,0,3) == "ID3")
        {
            $result['FileName'] = $file;
            $result['TAG'] = substr($tag,0,3);
            $result['Version'] = hexdec(bin2hex(substr($tag,3,1))).".".hexdec(bin2hex(substr($tag,4,1)));
        }
        if($result['Version'] == "4.0" || $result['Version'] == "3.0")
        {
            for ($i=0;$i<count($id3v23);$i++)
            {
                if (strpos($tag,$id3v23[$i].chr(0))!= FALSE)
                {
                    $pos = strpos($tag, $id3v23[$i].chr(0));
                    $len = hexdec(bin2hex(substr($tag,($pos+5),3)));
                    $data = substr($tag, $pos, 9+$len);
                    for ($a=0;$a<strlen($data);$a++)
                    {
                        $char = substr($data,$a,1);
                        if($char >= " " && $char <= "~")
                        {
                            $tmp.=$char;
                        }
                    }
                    if(substr($tmp,0,4) == "TIT2") $result['Title'] = substr($tmp,4);
                    if(substr($tmp,0,4) == "TALB") $result['Album'] = substr($tmp,4);
                    if(substr($tmp,0,4) == "TPE1") $result['Artist'] = substr($tmp,4);
                    if(substr($tmp,0,4) == "TRCK") $result['TrackNo'] = substr($tmp,4);
                    if(substr($tmp,0,4) == "TDRC") $result['Year'] = substr($tmp,4);
                    if(substr($tmp,0,4) == "TLEN") $result['Lenght'] = substr($tmp,4);
                    if(substr($tmp,0,4) == "USLT") $result['Lyric'] = substr($tmp,7);
                    if(substr($tmp,0,4) == "TCON") $result['Genre'] = substr($tmp,4);
                    if(substr($tmp,0,4) == "APIC") $result['AttachedPicture'] = substr($tmp,4);
                    $tmp = "";
                }
            }
        }
        if($result['Version'] == "2.0")
        {
            for ($i=0;$i<count($id3v22);$i++)
            {
                if (strpos($tag,$id3v22[$i].chr(0))!= FALSE)
                {
                    $pos = strpos($tag, $id3v22[$i].chr(0));
                    $len = hexdec(bin2hex(substr($tag,($pos+3),3)));
                    $data = substr($tag, $pos, 6+$len);
                    for ($a=0;$a<strlen($data);$a++)
                    {
                        $char = substr($data,$a,1);
                        if($char >= " " && $char <= "~")
                        {
                            $tmp.=$char;
                        }
                    }
                    if(substr($tmp,0,3) == "TT2") $result['Title'] = substr($tmp,3);
                    if(substr($tmp,0,3) == "TAL") $result['Album'] = substr($tmp,3);
                    if(substr($tmp,0,3) == "TP1") $result['Artist'] = substr($tmp,3);
                    if(substr($tmp,0,3) == "TRK") $result['TrackNo'] = substr($tmp,3);
                    if(substr($tmp,0,3) == "TYE") $result['Year'] = substr($tmp,3);
                    if(substr($tmp,0,3) == "TLE") $result['Lenght'] = substr($tmp,3);
                    if(substr($tmp,0,3) == "ULT") $result['Lyric'] = substr($tmp,6);
                    if(substr($tmp,0,3) == "TCO") $result['Genre'] = substr($tmp,3);
                    if(substr($tmp,0,3) == "PIC") $result['AttachedPicture'] = base64_encode(substr($tmp,3));
                    $tmp = "";
                }
            }
        }
        return $result;
    }
?>

在我的 index.php 文件中,我加载并使用上述 PHP 脚本,如下所示:

In my index.php file I then load and use the above PHP script as follows:

<?php
    require_once($_SERVER['DOCUMENT_ROOT'].'/script/php/script-mp3-tag-reader.php');
    $mp3 = $_SERVER['DOCUMENT_ROOT'].'/media/audio/mp3/test_audio.mp3';
    $myResult = tagReader($mp3);
    print_r($myResult);
?>

当查看 print_r($myresult); 时,可以看到信息确实存在并且正确......只是不是附加图像部分.我似乎提取的内容远远超出了需要,并且不知道如何只访问我需要的内容.

When looking at print_r($myresult); one can see that the information is indeed there and correct... just not the Attached Image part. I seem to be extracting far more than is needed and do not know how to access only what I need.

推荐答案

这样的事情应该可以解决问题.它最近没有经过测试,但应该可以从 mp3 文件中读取您要查找的数据.

Something like this should do the trick. It is not recently tested but should work to read the data you are looking for from a mp3 file.

function tagReader($file){
    $id3v23 = array("TIT2","TALB","TPE1","TRCK","TDRC","TLEN","USLT");
    $id3v22 = array("TT2","TAL","TP1","TRK","TYE","TLE","ULT");
    $fsize = filesize($file);
    $fd = fopen($file,"r");
    $tag = fread($fd,$fsize);
    $tmp = "";
    fclose($fd);
    if (substr($tag,0,3) == "ID3") {
        $result['FileName'] = $file;
        $result['TAG'] = substr($tag,0,3);
        $result['Version'] = hexdec(bin2hex(substr($tag,3,1))).".".hexdec(bin2hex(substr($tag,4,1)));
    }
    if($result['Version'] == "4.0" || $result['Version'] == "3.0"){
        for ($i=0;$i<count($id3v23);$i++){
            if (strpos($tag,$id3v23[$i].chr(0))!= FALSE){
                $pos = strpos($tag, $id3v23[$i].chr(0));
                $len = hexdec(bin2hex(substr($tag,($pos+5),3)));
                $data = substr($tag, $pos, 9+$len);
                for ($a=0;$a<strlen($data);$a++){
                    $char = substr($data,$a,1);
                    if($char >= " " && $char <= "~") $tmp.=$char;
                }
                if(substr($tmp,0,4) == "TIT2") $result['Title'] = substr($tmp,4);
                if(substr($tmp,0,4) == "TALB") $result['Album'] = substr($tmp,4);
                if(substr($tmp,0,4) == "TPE1") $result['Author'] = substr($tmp,4);
                if(substr($tmp,0,4) == "TRCK") $result['Track'] = substr($tmp,4);
                if(substr($tmp,0,4) == "TDRC") $result['Year'] = substr($tmp,4);
                if(substr($tmp,0,4) == "TLEN") $result['Lenght'] = substr($tmp,4);
                if(substr($tmp,0,4) == "USLT") $result['Lyric'] = substr($tmp,7);
                $tmp = "";
            }
        }
    }
    if($result['Version'] == "2.0"){
        for ($i=0;$i<count($id3v22);$i++){
            if (strpos($tag,$id3v22[$i].chr(0))!= FALSE){
                $pos = strpos($tag, $id3v22[$i].chr(0));
                $len = hexdec(bin2hex(substr($tag,($pos+3),3)));
                $data = substr($tag, $pos, 6+$len);
                for ($a=0;$a<strlen($data);$a++){
                    $char = substr($data,$a,1);
                    if($char >= " " && $char <= "~") $tmp.=$char;
                }
                if(substr($tmp,0,3) == "TT2") $result['Title'] = substr($tmp,3);
                if(substr($tmp,0,3) == "TAL") $result['Album'] = substr($tmp,3);
                if(substr($tmp,0,3) == "TP1") $result['Author'] = substr($tmp,3);
                if(substr($tmp,0,3) == "TRK") $result['Track'] = substr($tmp,3);
                if(substr($tmp,0,3) == "TYE") $result['Year'] = substr($tmp,3);
                if(substr($tmp,0,3) == "TLE") $result['Lenght'] = substr($tmp,3);
                if(substr($tmp,0,3) == "ULT") $result['Lyric'] = substr($tmp,6);
                $tmp = "";
            }
        }   
    }
    return $result;
}

这篇关于XAMPP (Windows) 上的 PECL 扩展安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆