diff options
author | TheTroll <trolldev@gmail.com> | 2010-02-26 14:47:14 +0100 |
---|---|---|
committer | TheTroll <trolldev@gmail.com> | 2010-02-26 14:47:14 +0100 |
commit | 13faaed4ec54b1611dcc1dd7aa796fe3649fdc6a (patch) | |
tree | bdd40801e6c2bb737044246bf16d4dce92e60ba6 | |
parent | 9cd6bbb758f3be5c2390a77770cc54b05dcf0b83 (diff) | |
download | istreamdev-13faaed4ec54b1611dcc1dd7aa796fe3649fdc6a.tar.gz istreamdev-13faaed4ec54b1611dcc1dd7aa796fe3649fdc6a.tar.bz2 |
Display ID3 tag if available for music
-rwxr-xr-x | includes/inc_audio.php | 17 | ||||
-rwxr-xr-x | includes/inc_files.php | 27 |
2 files changed, 36 insertions, 8 deletions
diff --git a/includes/inc_audio.php b/includes/inc_audio.php index f0e0046..2960aa5 100755 --- a/includes/inc_audio.php +++ b/includes/inc_audio.php @@ -51,9 +51,10 @@ if ($medianame_array[0]) sort($medianame_array); $count = count($medianame_array); + + // Directories for ($cnt=0; $cnt < $count; $cnt++) { - // Dirs if (mediagettype($mediapath .$subdir .$medianame_array[$cnt]) == 3) { $medianame2=addslashes($medianame_array[$cnt]); @@ -71,6 +72,8 @@ if ($medianame_array[0]) } } + + // Music files $idx = 1; for ($cnt=0; $cnt < $count; $cnt++) { @@ -95,19 +98,19 @@ if ($medianame_array[0]) print " <a class=\"noeffect\" href=\"javascript:var myarray = new Array({$jsarray});addplayer('{$mediapath2}{$subdir2}','{$medianame2}',myarray);document.player.Play();\">\r\n"; - print " <span class=\"number\">$idx</span><span class=\"stop\"></span><span class=\"name\">{$medianame_array[$cnt]}</span>\r\n"; + // Get song info + list($name, $duration) = mediagetmusicinfo($mediapath .$subdir .$medianame_array[$cnt]); + + print " <span class=\"number\">$idx</span><span class=\"stop\"></span><span class=\"name\">{$name}</span><span class=\"time\">{$duration}</span>\r\n"; print " </a>\r\n"; print " </li>\r\n"; $idx++; } } - - print("</div>"); - } -else - print "</div>\r\n"; + +print "</div>\r\n"; $upsubdir = dirname($subdir); diff --git a/includes/inc_files.php b/includes/inc_files.php index 06a9cc0..3e9e90f 100755 --- a/includes/inc_files.php +++ b/includes/inc_files.php @@ -4,7 +4,6 @@ $audiotypes='mp3 aac wav '; function mediagetinfostream($stream = "") { - global $ffmpegpath; // Get info @@ -62,3 +61,29 @@ function mediadirhasaudio($dir) return 0; } + +function mediagetmusicinfo($file ="") +{ + // Get info + $getid3 = new getID3; + $fileinfo = $getid3->analyze($file); + + $name = $fileinfo['tags']['id3v1']['title'][0]; + if ($name == "") + { + $name = $fileinfo['tags']['id3v2']['title'][0]; + if ($name == "") + { + $name = $fileinfo['filename']; + if ($name == "") + $name = "unknown"; + } + } + + if (!is_utf8($name)) + $name = utf8_encode($name); + + $duration = $fileinfo['playtime_string']; + + return array ($name, $duration); +} |