getid3

getid3

public function videojob_detail_p(){
        $test_id = I('post.test_id');
        //测试的test_id 2857
        $where['test_id'] = $test_id;
        //判断试题作业和听读作业
        $info = M('PapersTest')->field('id,title,simg,job_demand,teacher_message,genre')->where(['id'=>$test_id])->find();
        if($info['genre'] != 4){
            return show(204,'错误的参数类型',[]);
        }
        
        require_once('ThinkPHP/Library/Vendor/getid3/getid3.php');
        $getID3 = new \getID3();  //实例化类
        // $_SERVER['DOCUMENT_ROOT'];//根目录
        $arr = str_ireplace('/', '\\', $info['teacher_message']); //整斜杠换成反斜杠
        $file_url = realpath($_SERVER['DOCUMENT_ROOT'].'\Uploads')."\\".$arr;
        $ThisFileInfo = $getID3->analyze($file_url);
        // $ThisFileInfo = $getID3->analyze('E:\phpStuday\PHPTutorial\WWW\Uploads\Content\2018-08-22\5b7cd1e91e108.wav'); //分析文件,$path为音频文件的地址
        $info['fileduration'] = $ThisFileInfo['playtime_seconds']; //这个获得的便是音频文件的时长
        $info['teacher_message'] = $this->url.$info['teacher_message'] ? :"";
        $info['simg'] = $this->url.$info['simg'] ? :"";
        $list = M('PapersTestQuestions')->field('id,title,options')->field('id,title,options')->where($where)->select();

        foreach ($list as &$v){
            $v['video'] = $this->url.$v['options'];
            unset($v['options']);
        }
        $info['questions'] = $list;
        return show(200,'success',$info);
    }

你可能感兴趣的:(getid3)