The mp3 file is valid.
When we run the code, it gives an error:
"video can't be played because the file is corrupt"
Do we need to configure getid3.php to read mp3 files first?
Here's our code:
Code: Select all
<?php
$filename = "/home/bruce/public_html/cat/system/download/ge229/ge229_together.mp3";
require_once('/usr/share/php/getid3/getid3.php');
$getID3 = new getID3();
$id3_info = $getID3->analyze($filename);
list($t_min, $t_sec) = explode(':', $id3_info['length']);
$time = ($t_min * 60) + $t_sec;
$preview = $time / 30; // Preview time of 30 seconds
$handle = fopen($filename, 'r');
$content = fread($handle, filesize($filename));
$length = strlen($content);
// if (!$session->IsLoggedIn()) {
$length = round(strlen($content) / $preview);
$content = substr($content, $length * .66 /* Start extraction ~20 seconds in */, $length);
// }
header("Content-Type: {$id3_info['mime_type']}");
header("Content-Length: {$length}");
print $content;
- [Thu Sep 03 11:20:25.607295 2015] [:error] [pid 4938] [client 70.188.133.169:65287] PHP Notice: Undefined index: length in /home/bruce/public_html/cat/mp3demo.php on line 9
[Thu Sep 03 11:20:25.607365 2015] [:error] [pid 4938] [client 70.188.133.169:65287] PHP Notice: Undefined offset: 1 in /home/bruce/public_html/cat/mp3demo.php on line 9
[Thu Sep 03 11:20:25.610158 2015] [:error] [pid 4938] [client 70.188.133.169:65287] PHP Warning: Division by zero in /home/bruce/public_html/cat/mp3demo.php on line 20