public static function getId3tags($params) { try { require_once EYE_ROOT . '/' . APPS_DIR . '/viewer/library/id3.class.php'; $tags = array(); foreach ($params as $song) { $myFile = FSI::getFile($song); $myFile->checkReadPermission(); $myRealFile = $myFile->getRealFile(); if (!$myRealFile instanceof LocalFile) { $tags[] = array($song, array('artist' => 'N/A', 'album' => 'N/A', 'gender' => 'N/A', 'title' => 'N/A', 'year' => 'N/A', 'duration' => 'N/A')); } else { $fileName = AdvancedPathLib::getPhpLocalHackPath($myRealFile->getAbsolutePath()); //FIXME: seems like AudioFile does not work when using non-virtual files: find why! $AF = new AudioFile(); $AF->loadFile($fileName); $tags[] = array($song, array('artist' => $AF->id3_artist ? $AF->id3_artist : 'N/A', 'album' => $AF->id3_album ? $AF->id3_album : 'N/A', 'gender' => $AF->id3_genre ? $AF->id3_genre : 'N/A', 'title' => $AF->id3_title ? $AF->id3_title : 'N/A', 'year' => $AF->id3_year ? $AF->id3_year : 'N/A', 'duration' => shell_exec('exiftool -b -Duration ' . escapeshellarg($fileName)))); } } } catch (Except $e) { $tags[] = array($song, array('artist' => 'N/A', 'album' => 'N/A', 'gender' => 'N/A', 'title' => 'N/A', 'year' => 'N/A', 'duration' => 'N/A')); } return $tags; }
} } else { if (!($voiceshadow = $DB->get_record("voiceshadow", array("id" => $a)))) { error("Course module is incorrect"); } if (!($course = $DB->get_record("course", array("id" => $voiceshadow->course)))) { error("Course is misconfigured"); } if (!($cm = get_coursemodule_from_instance("voiceshadow", $voiceshadow->id, $course->id))) { error("Course Module ID was incorrect"); } } $name = "var{$var}"; $linktofile = $CFG->wwwroot . '/mod/voiceshadow/file.php?file=' . $voiceshadow->{$name}; $file = voiceshadow_getfileid($voiceshadow->{$name}); $AF = new AudioFile(); if (is_file($file->fullpatch)) { $AF->loadFile($file->fullpatch); $duration = round($AF->wave_length); if (empty($duration)) { $m = new mp3file($file->fullpatch); $a = $m->get_metadata(); $duration = $a['Length']; } } if ($uid) { $USER = $DB->get_record("user", array("id" => $uid)); } if (empty($time)) { $time = time(); }
$path = str_replace("\\", "/", $path); $dir = $path . $filetoaction . "/"; echo "получен путь {$path}.{$filetoaction}<br>"; // $handle=opendir('./'); $wr = fopen("mp3path.txt", "w"); $err = fwrite($wr, $dir); fclose($wr); // $handle=opendir ($dir); $handle = opendir($dir); while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { if (substr(strtoupper($file), strlen($file) - 4, 4) == ".WAV" || substr(strtoupper($file), strlen($file) - 4, 4) == ".AIF" || substr(strtoupper($file), strlen($file) - 4, 4) == ".MP3") { print "<a href=\"./test.php?filename={$file}\">{$file}</a><br>"; //вывод имени файла if ($file != "") { $AF = new AudioFile(); //($HTTP_GET_VARS[filename] переглючено на полный вывод :) $AF->loadFile($file); $AF->printSampleInfo(); if ($AF->wave_id == "RIFF") { $AF->visual_width = 600; $AF->visual_height = 500; $AF->getVisualization(substr($file, 0, strlen($file) - 4) . ".png"); print "<img src=./" . substr($file, 0, strlen($file) - 4) . ".png>"; } } } else { } } } print "</td><td valign=top>";
public function visualize($mediaId) { $media = Doctrine::getTable('MediaFile')->find($mediaId, Doctrine::HYDRATE_ARRAY); $file = $this->locateFile($media); if (!$file) { kohana::log('debug', 'Failing to visualize ' . $mediaId); die; } kohana::log('debug', 'Visualizing ' . $file); // Initialize audio analysis routine $audioFile = new AudioFile(); $audioFile->loadFile($file); $audioFile->visual_height = 250; $audioFile->visual_background_color = '#FFFFFF'; $audioFile->visual_border_color = '#FFFFFF'; $audioFile->visual_grid_color = '#CCCCCC'; $audioFile->visual_graph_color = '#0000FF'; header('Content-type: image/jpeg'); $audioFile->getVisualization(NULL); flush(); exit; }
/** * Overload this method to contain the task logic. */ public function process() { if (isset($_REQUEST['AudioFileID']) && ($AudioFile = AudioFile::get()->byID($_REQUEST['AudioFileID']))) { $AudioFile->process(); } }
private function metadata_block_completed() { if ($this->options['split_tracks']) { $this->open_mp3file(AudioFile::safe_filename($this->metadata->stream_title())); } }
function getSubClass($fileName, $diskFile) { //php4 can't list subclasses of class, so we need to add each one here require_once "AudioFile.php"; require_once "ImageFile.php"; require_once "VideoFile.php"; require_once "ZipFile.php"; if (preg_match('/\\.([^.]{2,4}$)/', $fileName, $m)) { $ext = strtolower($m[1]); } else { return "PlainFile"; } if (ImageFile::validateExtension($ext)) { return "ImageFile"; } if (ZipFile::validateExtension($ext)) { return "ZipFile"; } $audioValid = AudioFile::validateExtension($ext); $videoValid = VideoFile::validateExtension($ext); if ($audioValid && $videoValid) { exec(escapeshellcmd("file " . $diskFile), $out, $ret_error); if (preg_match("/video/", $out[0]) || preg_match("/movie/", $out[0])) { return "VideoFile"; } else { return "AudioFile"; } } if ($audioValid) { return "AudioFile"; } if ($videoValid) { return "VideoFile"; } return "PlainFile"; }