当前位置: 首页>>代码示例>>PHP>>正文


PHP getID3::Analyze方法代码示例

本文整理汇总了PHP中getID3::Analyze方法的典型用法代码示例。如果您正苦于以下问题:PHP getID3::Analyze方法的具体用法?PHP getID3::Analyze怎么用?PHP getID3::Analyze使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在getID3的用法示例。


在下文中一共展示了getID3::Analyze方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getFLVDuration

function getFLVDuration($flv_path)
{
    $getid3 = new getID3();
    $getid3->encoding = 'UTF-8';
    try {
        $getid3->Analyze($flv_path);
        return $getid3->info['playtime_seconds'];
    } catch (Exception $e) {
        return 0;
    }
}
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:11,代码来源:audiorecorder.inc.php

示例2: extract

 function extract($full_name)
 {
     $getid3 = new getID3();
     $getid3->encoding = 'UTF-8';
     if (!is_file($full_name)) {
         return "ERROR: file ({$full_name}) does not exists";
     }
     //$g = new xml_gen;
     try {
         $time = getmicrotime();
         $getid3->Analyze($full_name);
         //die;
         $time = getmicrotime() - $time;
         $this->result['filename'] = basename($getid3->filename);
         $this->result['filesize'] = @$getid3->info['filesize'];
         $this->result['fileformat'] = @$getid3->info['fileformat'];
         if (@$getid3->info['audio']['dataformat'] && $getid3->info['audio']['dataformat'] != $getid3->info['fileformat']) {
             $this->result['audio']['dataformat'] = @$getid3->info['fileformat'];
         }
         if (@$getid3->info['video']['dataformat'] && $getid3->info['video']['dataformat'] != $getid3->info['fileformat'] && $getid3->info['video']['dataformat'] != @$getid3->info['audio']['dataformat']) {
             $this->result['video']['dataformat'] = @$getid3->info['fileformat'];
         }
         $this->result['length'] = @$getid3->info['playtime_string'];
         $this->result['bitrate'] = @$getid3->info['bitrate'] ? number_format($getid3->info['bitrate'] / 1000) . 'k' : '';
         $this->result['audio']['sample_rate'] = @$getid3->info['audio']['sample_rate'] ? number_format($getid3->info['audio']['sample_rate']) . '/' . (@$getid3->info['audio']['bits_per_sample'] ? $getid3->info['audio']['bits_per_sample'] . '/' : '') . @$getid3->info['audio']['channels'] : '';
         $this->result['artist'] = $this->result['title'] = $this->result['album'] = '';
         if (@$getid3->info['tags']) {
             foreach ($getid3->info['tags'] as $tag => $tag_info) {
                 if (@$getid3->info['tags'][$tag]['artist'] || @$getid3->info['tags'][$tag]['title'] || @$getid3->info['tags'][$tag]['album'] || @$getid3->info['tags'][$tag]['genre']) {
                     $this->result['artist'] = @implode('', @$getid3->info['tags'][$tag]['artist']);
                     $this->result['title'] = @implode('', @$getid3->info['tags'][$tag]['title']);
                     $this->result['album'] = @implode('', @$getid3->info['tags'][$tag]['album']);
                     $this->result['genre'] = @implode('', @$getid3->info['tags'][$tag]['genre']);
                     break;
                 }
             }
         }
         $this->result['tags'] = @implode(", ", @array_keys(@$getid3->info['tags']));
         $this->result['warning'] = @implode("", @$getid3->info['warning']);
         return $this->result;
     } catch (Exception $e) {
         return 'ERROR: ' . $e->message;
     }
 }
开发者ID:BallStateCBER,项目名称:muncieMusicFest,代码行数:44,代码来源:getid3data.php

示例3: detect

 public function detect($file)
 {
     if (!extension_loaded('exif')) {
         // The getid3 library requires the exif extension.
         return false;
     }
     require_once 'getid3/getid3.php';
     $id3 = new getID3();
     $id3->encoding = 'UTF-8';
     try {
         $id3->Analyze($file);
     } catch (getid3_exception $e) {
         return false;
     }
     if (isset($id3->info['mime_type'])) {
         return $id3->info['mime_type'];
     }
     return false;
 }
开发者ID:lchen01,项目名称:STEdwards,代码行数:19,代码来源:GetId3.php

示例4: foreach

 function mp3titles($file)
 {
     // Title the mp3s
     // Create ID3 object
     $getid3 = new getID3();
     $getid3->encoding = 'ISO 8859-1';
     $getid3->Analyze(realpath(APPPATH . "../../") . "/" . $file);
     $artist = $title = '';
     if (@$getid3->info['tags']) {
         foreach ($getid3->info['tags'] as $tag => $tag_info) {
             if (@$getid3->info['tags'][$tag]['artist'] || @$getid3->info['tags'][$tag]['title']) {
                 $artist = @$getid3->info['tags'][$tag]['artist'][0];
                 $title = @$getid3->info['tags'][$tag]['title'][0];
                 $album = @$getid3->info['tags'][$tag]['album'][0];
                 break;
             }
         }
     }
     if (isset($album)) {
         return array("artist" => $artist, "title" => $title, "album" => $album);
     } else {
         return array("artist" => $artist, "title" => $title);
     }
 }
开发者ID:NAzT,项目名称:Dominater-Framework,代码行数:24,代码来源:audio_helper.php

示例5: onDetail

    protected function onDetail()
    {
        if (empty($this->post['directory']) || empty($this->post['file'])) {
            return;
        }
        $file = realpath($this->path . '/' . $this->post['directory'] . '/' . $this->post['file']);
        if (!$this->checkFile($file)) {
            return;
        }
        require_once $this->options['id3Path'];
        // Xinha: The URL is weird in the standard distribution of filemanager, it seems to expect
        // that the files directory (where you are selecting/uploading) is always within the filemanager
        // directory itself somewhere.
        //
        // Also the 'baseURL' seems to be wanted as the parent of the 'basedir' ("directory" option)
        // Xinha is supplying both the same (eg url = /foo/test and dir = /home/bar/public_html/foo/test )
        // so we will rip off the first part of directory, below.
        $url = $this->options['baseURL'] . '/' . preg_replace('/^[^\\/]*\\//', '', $this->post['directory'] . '/' . $this->post['file']);
        $mime = $this->getMimeType($file);
        $content = null;
        // Xinha: We want to get some more information about what has been selected in a way
        // we can use it.  Effectively what gets put in here will be passed into the
        // 'onDetails' event handler of your FileManager object (if any).
        $extra_return_detail = array('url' => $url, 'mime' => $mime);
        if (FileManagerUtility::startsWith($mime, 'image/')) {
            $size = getimagesize($file);
            $content = '<img src="' . $url . '" class="preview" alt="" />
				<h2>${more}</h2>
				<dl>
					<dt>${width}</dt><dd>' . $size[0] . 'px</dd>
					<dt>${height}</dt><dd>' . $size[1] . 'px</dd>
				</dl>';
            // Xinha: Return some information about the image which can be access
            // from the onDetails event handler in FileManager
            $extra_return_detail['width'] = $size[0];
            $extra_return_detail['height'] = $size[1];
        } elseif (FileManagerUtility::startsWith($mime, 'text/') || $mime == 'application/x-javascript') {
            $filecontent = file_get_contents($file, null, null, 0, 300);
            if (!FileManagerUtility::isBinary($filecontent)) {
                $content = '<div class="textpreview">' . nl2br(str_replace(array('$', "\t"), array('&#36;', '&nbsp;&nbsp;'), htmlentities($filecontent))) . '</div>';
            }
        } elseif ($mime == 'application/zip') {
            $out = array(array(), array());
            $getid3 = new getID3();
            $getid3->Analyze($file);
            foreach ($getid3->info['zip']['files'] as $name => $size) {
                $icon = is_array($size) ? 'dir' : $this->getIcon($name);
                $out[$icon == 'dir' ? 0 : 1][$name] = '<li><a><img src="' . $this->options['assetBasePath'] . '/Icons/' . $icon . '.png" alt="" /> ' . $name . '</a></li>';
            }
            natcasesort($out[0]);
            natcasesort($out[1]);
            $content = '<ul>' . implode(array_merge($out[0], $out[1])) . '</ul>';
        } elseif (FileManagerUtility::startsWith($mime, 'audio/')) {
            $getid3 = new getID3();
            $getid3->Analyze($file);
            $content = '<div class="object">
					<object type="application/x-shockwave-flash" data="' . $this->options['assetBasePath'] . '/dewplayer.swf?mp3=' . rawurlencode($url) . '&volume=30" width="200" height="20">
						<param name="movie" value="' . $this->options['assetBasePath'] . '/dewplayer.swf?mp3=' . rawurlencode($url) . '&volume=30" />
					</object>
				</div>
				<h2>${more}</h2>
				<dl>
					<dt>${title}</dt><dd>' . $getid3->info['comments']['title'][0] . '</dd>
					<dt>${artist}</dt><dd>' . $getid3->info['comments']['artist'][0] . '</dd>
					<dt>${album}</dt><dd>' . $getid3->info['comments']['album'][0] . '</dd>
					<dt>${length}</dt><dd>' . $getid3->info['playtime_string'] . '</dd>
					<dt>${bitrate}</dt><dd>' . round($getid3->info['bitrate'] / 1000) . 'kbps</dd>
				</dl>';
        }
        echo json_encode(array_merge(array('content' => $content ? $content : '<div class="margin">
				${nopreview}<br/><button value="' . $url . '">${download}</button>
			</div>'), $extra_return_detail));
    }
开发者ID:ryumaru,项目名称:ryuzinewriter,代码行数:73,代码来源:FileManager.php

示例6: Analyze

 public function Analyze($filename)
 {
     if (file_exists($filename)) {
         // Short-hands
         $filetime = filemtime($filename);
         $filesize = filesize($filename);
         // Loopup file
         $this->cursor = mysql_query("SELECT `value` FROM `getid3_cache` WHERE (`filename` = '" . mysql_real_escape_string($filename) . "') AND (`filesize` = '" . mysql_real_escape_string($filesize) . "') AND (`filetime` = '" . mysql_real_escape_string($filetime) . "')", $this->connection);
         list($result) = @mysql_fetch_array($this->cursor);
         // Hit
         if ($result) {
             return unserialize(base64_decode($result));
         }
     }
     // Miss
     $result = parent::Analyze($filename);
     // Save result
     if (file_exists($filename)) {
         $this->cursor = mysql_query("INSERT INTO `getid3_cache` (`filename`, `filesize`, `filetime`, `analyzetime`, `value`) VALUES ('" . mysql_real_escape_string($filename) . "', '" . mysql_real_escape_string($filesize) . "', '" . mysql_real_escape_string($filetime) . "', '" . mysql_real_escape_string(time()) . "', '" . mysql_real_escape_string(base64_encode(serialize($result))) . "')", $this->connection);
     }
     return $result;
 }
开发者ID:JPisaBrony,项目名称:SonicFlow,代码行数:22,代码来源:extension.cache.mysql.php

示例7: _getId3

 /**
  * Read the file's embedded metadata with the getID3 library.
  *
  * @return getID3|bool Returns getID3 object, or false if there was an
  *  exception.
  */
 private function _getId3()
 {
     if (!$this->_id3) {
         require_once 'getid3/getid3.php';
         $id3 = new getID3();
         $id3->encoding = 'UTF-8';
         try {
             $id3->Analyze($this->getPath('original'));
             $this->_id3 = $id3;
         } catch (getid3_exception $e) {
             $message = $e->getMessage();
             _log("getID3: {$message}");
             return false;
         }
     }
     return $this->_id3;
 }
开发者ID:kwiliarty,项目名称:Omeka,代码行数:23,代码来源:File.php

示例8: catch

// | http://www.gnu.org/copyleft/gpl.html                                 |
// +----------------------------------------------------------------------+
// | getID3() - http://getid3.sourceforge.net or http://www.getid3.org    |
// +----------------------------------------------------------------------+
// | Authors: James Heinrich <infoØgetid3*org>                            |
// |          Allan Hansen <ahØartemis*dk>                                |
// +----------------------------------------------------------------------+
// | demo.basic.php                                                       |
// | getID3() demo file - showing the most basic use of getID3().         |
// +----------------------------------------------------------------------+
//
// $Id: demo.basic.php,v 1.3 2006/11/16 22:11:58 ah Exp $
// Enter your filename here
$filename = '/data/getid3/aiff_wave.aiff';
// Include getID3() library (can be in a different directory if full path is specified)
require_once '../getid3/getid3.php';
// Initialize getID3 engine
$getid3 = new getID3();
// Tell getID3() to use UTF-8 encoding - must send proper header as well.
$getid3->encoding = 'UTF-8';
// Tell browser telling it use UTF-8 encoding as well.
header('Content-Type: text/html; charset=UTF-8');
// 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;
}
开发者ID:peterlindkvist,项目名称:apache-player,代码行数:31,代码来源:demo.basic.php

示例9: AnalyzeDirectory

function AnalyzeDirectory()
{
    global $audio_path, $dbh;
    // Scan $audio_path
    try {
        // Build array containing filenames
        $files = array();
        ScanDirectory($audio_path, $files);
        // Initialize getID3 engine
        $getid3 = new getID3();
        $getid3->encoding = 'UTF-8';
        $getid3->option_md5_data = true;
        $getid3->option_md5_data_source = true;
        // Scan all files
        foreach ($files as $filename => $name) {
            try {
                $getid3->Analyze($filename);
                if (!@$getid3->info['audio']) {
                    xml_gen::p($name . ' skipped - not an audio file.');
                    continue;
                }
                // Extract data
                $filemtime = filemtime($filename);
                $filesize = filesize($filename);
                $filename_sls = addslashes(utf8_encode($filename));
                $format_name = @$getid3->info['fileformat'] . (@$getid3->info['audio']['dataformat'] != @$getid3->info['fileformat'] ? '/' . @$getid3->info['audio']['dataformat'] : '');
                $format_name_id = Lookup($format_name, 'format_name');
                $encoder_version_id = Lookup(@$getid3->info['audio']['encoder'], 'encoder_version');
                $encoder_options_id = Lookup(@$getid3->info['audio']['encoder_options'], 'encoder_options');
                $bitrate_mode_id = Lookup(@$getid3->info['audio']['bitrate_mode'], 'bitrate_mode');
                $channel_mode_id = Lookup(@$getid3->info['audio']['channelmode'], 'channel_mode');
                $sample_rate = (int) @$getid3->info['audio']['sample_rate'];
                $bits_per_sample = (int) @$getid3->info['audio']['bits_per_sample'];
                $lossless = (int) @$getid3->info['audio']['lossless'];
                $playtime = (double) @$getid3->info['playtime_seconds'];
                $avg_bit_rate = (double) @$getid3->info['bitrate'];
                $rg_track_gain = (double) @$getid3->info['replay_gain']['track']['adjustment'];
                $rg_album_gain = (double) @$getid3->info['replay_gain']['album']['adjustment'];
                $md5data = addslashes(@$getid3->info['md5_data_source'] ? @$getid3->info['md5_data_source'] : @$getid3->info['md5_data']);
                // Insert file entry
                $dbh->query("insert into getid3_file (filename, filemtime, filesize, format_name_id, encoder_version_id, encoder_options_id, bitrate_mode_id, channel_mode_id, sample_rate, bits_per_sample, lossless, playtime, avg_bit_rate, md5data, replaygain_track_gain, replaygain_album_gain) values ('{$filename_sls}', {$filemtime}, {$filesize}, {$format_name_id}, {$encoder_version_id}, {$encoder_options_id}, {$bitrate_mode_id}, {$channel_mode_id}, {$sample_rate}, {$bits_per_sample}, {$lossless}, {$playtime}, {$avg_bit_rate}, '{$md5data}', {$rg_track_gain}, {$rg_album_gain})");
                $file_id = $dbh->insert_id();
                // Loop thru tags
                if (@$getid3->info['tags']) {
                    foreach ($getid3->info['tags'] as $tag_name => $tag_data) {
                        // Loop thru fields
                        foreach ($tag_data as $field_name => $values) {
                            // Loop thru values
                            foreach ($values as $value) {
                                $tag_id = Lookup($tag_name, 'tag');
                                $field_id = Lookup($field_name, 'field');
                                $value_id = Lookup($value, 'value');
                                // Insert comments entry
                                $dbh->query("insert into getid3_comment (file_id, tag_id, field_id, value_id) values ({$file_id}, {$tag_id}, {$field_id}, {$value_id})");
                            }
                        }
                    }
                }
                echo xml_gen::p('#' . $file_id . ' - ' . utf8_encode($filename) . ' OK.');
                flush();
            } catch (Exception $e) {
                echo xml_gen::p_err($name . ' skipped - getID3() threw the exception: ' . $e->getmessage());
            }
        }
    } catch (Exception $e) {
        echo xml_gen::p_err('An error occured: ' . $e->getmessage());
    }
}
开发者ID:peterlindkvist,项目名称:apache-player,代码行数:68,代码来源:demo.mysql.php

示例10: foreach

	<!-- Playlist generated automatically using script from www.lasmit.com -->
    
    <trackList>

END_HEADER;

	if ($_REQUEST['shuffle']=="true") {
		shuffle($files);
	} else {
    	asort($files);
	}
	
	$counter = $i = 0;
    foreach ($files as $full_name => $short_name) {

	    $getid3->Analyze($dir . "/" . $short_name);	
	    
        $artist = $title = '';
            if (@$getid3->info['tags']) {
            foreach ($getid3->info['tags'] as $tag => $tag_info) {
                if (@$getid3->info['tags'][$tag]['title']) {
                    $artist = @$getid3->info['tags'][$tag]['artist'][0];
                    $title  = @$getid3->info['tags'][$tag]['title'][0];
                    $album  = @$getid3->info['tags'][$tag]['album'][0];
                    break;
                } else {
				$title  = basename($short_name, ".mp3");
				}
            }
        } else {
		$title = basename($short_name, ".mp3");
开发者ID:stitch,项目名称:RetroTV,代码行数:31,代码来源:playlist_generator.php

示例11: cacheAudioData

 protected function cacheAudioData()
 {
     $this->loadGetID3();
     $file = $this->FileData->fetchFilePath();
     $getid3 = new getID3();
     $getid3->Analyze($file);
     $length = $getid3->info['playtime_seconds'];
     $this->setMeta('length', $length);
     $this->setMeta('sha1', sha1_file($file));
     $this->FileData->unlinkFilePath();
 }
开发者ID:jmather,项目名称:majaxDoctrineMediaPlugin,代码行数:11,代码来源:PluginmajaxMediaFileInfo.class.php

示例12: mkdir

 $filesize = $_FILES[$index]["size"];
 $tmpname = $_FILES[$index]["tmp_name"];
 $fullname = $path . $separator . $filename;
 if (preg_match('/\\.mp3$/', $filename)) {
     echo "catfolder: " . $cat_folder . "\n";
     echo "folder: " . $path . "\n";
     echo "fullname: " . $fullname . "\n";
     if (!is_dir($path)) {
         mkdir($path);
     }
     if (move_uploaded_file($tmpname, $fullname)) {
         $getid3 = new getID3();
         // Tell getID3() to use UTF-8 encoding - must send proper header as well.
         $getid3->encoding = 'UTF-8';
         try {
             $getid3->Analyze($fullname);
             $bitrate = $getid3->info['audio']['bitrate'];
             $rate = $getid3->info['audio']['sample_rate'];
             $year = $getid3->info['id3v1']['year'];
             $artist = $getid3->info['id3v1']['artist'];
             $album = $getid3->info['id3v1']['album'];
             $track = $getid3->info['id3v1']['track'];
             $title = $getid3->info['id3v1']['title'];
             $time = round($getid3->info['playtime_seconds']);
             $size = filesize($fullname);
             $addtime = time();
             $sqlfullname = str_replace("\\", "\\\\", $fullname);
             if ($title == "") {
                 $title = $filename;
             }
             $catalog_obj = $as->getCatalogFromName($user, $password, $catalog);
开发者ID:peterlindkvist,项目名称:apache-player,代码行数:31,代码来源:upload.php

示例13: header

             if ($key == 'data' && isset($var['image_mime']) && isset($var['dataoffset'])) {
                 if (md5($value) == $md5) {
                     header("Content-type: " . $var['image_mime']);
                     echo $value;
                     break;
                 }
             }
             dump_img($value, $md5);
         }
     }
 }
 $getid3->option_tags_images = true;
 // Show embedded cover
 if (@$_GET["show_img"]) {
     try {
         $getid3->Analyze($_GET['filename']);
         dump_img($getid3->info, $_GET["show_img"]);
         die;
     } catch (Exception $e) {
         echo xml_gen::p('ERROR: ' . $e->message);
     }
 }
 // Show file info
 CommonHeader($_GET['filename']);
 $pd = pathinfo($_GET['filename']);
 $pd = $pd['dirname'];
 echo xml_gen::p('Browse: ' . xml_gen::a($_SERVER['SCRIPT_NAME'] . '?directory=' . urlencode($pd), $pd));
 try {
     $getid3->Analyze($_GET['filename']);
     dump($getid3->info);
 } catch (Exception $e) {
开发者ID:JPisaBrony,项目名称:SonicFlow,代码行数:31,代码来源:demo.browse.dhtml.php

示例14: analyze_file

 /**
  * Analyze file with getid3 and return mysql file_id.
  */
 protected function analyze_file($filename)
 {
     // get filesize (>2Gb files not supported)
     if (!($filesize = @filesize($filename))) {
         return 0;
     }
     // get date file last modified
     $filemtime = filemtime($filename);
     // extract dir- and basename in utf8 and add slashes for mysql
     $path_info = pathinfo(@iconv($this->server_cp, 'UTF-8', $filename));
     $filename_sls = addslashes($path_info['basename']);
     $dirname_sls = addslashes($path_info['dirname']);
     // get directory_id from dirname_sls
     $this->dbh->query("select id from getid3_directory where filename='{$dirname_sls}'");
     if ($this->dbh->next_record()) {
         $directory_id = $this->dbh->f('id');
     } else {
         $root_id = $this->get_root_id($filename);
         $this->dbh->query("insert into getid3_directory (root_id, filename) values ({$root_id}, '{$dirname_sls}')");
         $directory_id = $this->dbh->insert_id();
     }
     // cached? - determined by directory_id, filename and filemtime
     $this->dbh->query("select id from getid3_file where directory_id = {$directory_id} and filename = '{$filename_sls}' and filemtime = {$filemtime} and filesize = {$filesize}");
     if ($this->dbh->next_record()) {
         // great - return id
         return $this->dbh->f('id');
     }
     // not cached - analyze file with getid3
     require_once 'getid3/getid3.php';
     // initialize getID3 engine
     $getid3 = new getID3();
     $getid3->encoding = 'UTF-8';
     $getid3->option_md5_data = true;
     $getid3->option_md5_data_source = true;
     try {
         $getid3->Analyze($filename);
     } catch (getid3_exception $e) {
         // non media files (garbage)
         if ($e->getmessage() == 'Unable to determine file format') {
             // insert in database - no need to analyse again
             $this->dbh->query("replace into getid3_file (filemtime, directory_id, filename) values ({$filemtime}, {$directory_id}, '{$filename_sls}')");
             return $this->dbh->insert_id();
         } else {
             throw $e;
         }
     }
     $format_name = @$getid3->info['fileformat'] . (@$getid3->info['audio']['dataformat'] != @$getid3->info['fileformat'] ? '/' . @$getid3->info['audio']['dataformat'] : '');
     $format_name_id = $this->getid3_lookup_format_name_id($format_name, @$getid3->info['mime_type']);
     // skip for non audio files - i.e. images
     if (@$getid3->info['audio']) {
         $encoder_version_id = $this->getid3_lookup_id(@$getid3->info['audio']['encoder'], 'encoder_version');
         $encoder_options_id = $this->getid3_lookup_id(@$getid3->info['audio']['encoder_options'], 'encoder_options');
         $bitrate_mode_id = $this->getid3_lookup_id(@$getid3->info['audio']['bitrate_mode'], 'bitrate_mode');
         $channel_mode_id = $this->getid3_lookup_id(@$getid3->info['audio']['channelmode'], 'channel_mode');
         $sample_rate = (int) @$getid3->info['audio']['sample_rate'];
         $bits_per_sample = (int) @$getid3->info['audio']['bits_per_sample'];
         $channels = (int) @$getid3->info['audio']['channels'];
         $lossless = (int) @$getid3->info['audio']['lossless'];
         $playtime = (double) @$getid3->info['playtime_seconds'];
         $avg_bit_rate = (double) @$getid3->info['bitrate'];
         $rg_track_gain = isset($getid3->info['replay_gain']['track']['adjustment']) ? (double) $getid3->info['replay_gain']['track']['adjustment'] : 'null';
         $rg_album_gain = isset($getid3->info['replay_gain']['album']['adjustment']) ? (double) $getid3->info['replay_gain']['album']['adjustment'] : 'null';
         $md5_data = $getid3->info['md5_data'];
         // insert audio file entry
         $this->dbh->query("replace into getid3_file (directory_id, filename, filemtime, filesize, format_name_id, encoder_version_id, encoder_options_id, bitrate_mode_id, channel_mode_id, sample_rate, bits_per_sample, channels, lossless, playtime, avg_bit_rate, replaygain_track_gain, replaygain_album_gain, md5_data) values ({$directory_id}, '{$filename_sls}', {$filemtime}, {$filesize}, {$format_name_id}, 0{$encoder_version_id}, 0{$encoder_options_id}, 0{$bitrate_mode_id}, 0{$channel_mode_id}, {$sample_rate}, {$bits_per_sample}, {$channels}, {$lossless}, {$playtime}, {$avg_bit_rate}, {$rg_track_gain}, {$rg_album_gain}, '{$md5_data}')");
     } else {
         // insert audio file entry
         $this->dbh->query("replace into getid3_file (directory_id, filename, filemtime, filesize, format_name_id) values ({$directory_id}, '{$filename_sls}', {$filemtime}, {$filesize}, {$format_name_id})");
     }
     $file_id = $this->dbh->insert_id();
     // loop thru tags
     if (@$getid3->info['tags']) {
         foreach ($getid3->info['tags'] as $tag_name => $tag_data) {
             // loop thru fields
             foreach ($tag_data as $field_name => $values) {
                 // loop thru values
                 foreach ($values as $value) {
                     $field_id = $this->getid3_lookup_id($field_name, 'field');
                     $value_id = $this->getid3_lookup_id($value, 'value');
                     // insert comments entry
                     $this->dbh->query("replace into getid3_comment (file_id, field_id, value_id) values ({$file_id}, {$field_id}, {$value_id})");
                 }
             }
         }
     }
     return $file_id;
 }
开发者ID:peterlindkvist,项目名称:apache-player,代码行数:90,代码来源:morg.php

示例15: getPlaytimeID3

function getPlaytimeID3($file)
{
    // Initialize getID3 engine
    $getid3 = new getID3();
    // Tell getID3() to use UTF-8 encoding - must send proper header as well.
    $getid3->encoding = 'UTF-8';
    $result = array();
    try {
        $info = $getid3->Analyze($file);
        if (isset($info["playtime_seconds"])) {
            $result[0] = true;
            $result[1] = $info["playtime_seconds"];
        } else {
            $result[0] = false;
            $result[1] = "file format doesnt have playtime";
        }
        return $result;
    } catch (Exception $e) {
        $result[0] = false;
        $result[1] = $e->message;
        return $result;
    }
}
开发者ID:raedatoui,项目名称:View,代码行数:23,代码来源:fileFunctions.php


注:本文中的getID3::Analyze方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。