//die die; } //get path for original mp3file $path = $upload_dir . '/' . $current_file_dir . ".mp3"; //read MP3 $mp3 = new mp3($path); //create m3u8 header $m3u8_file = "#EXTM3U \n#EXT-X-MEDIA-SEQUENCE:0 \n#EXT-X-TARGETDURATION:" . $partlenght . "\n"; //start on second 0 $position = 0; //continue the loop while $continue_mp3split_loop = 1 $continue_mp3split_loop = 1; while ($continue_mp3split_loop == 1) { //split the part $mp3_1 = $mp3->extract($position, $partlenght); //export and save the part as file $mp3_1->save($archive_path . "/" . $current_file_dir . '/' . 'file' . $position . '.mp3'); //check if title has ended if (filesize($archive_path . "/" . $current_file_dir . '/' . 'file' . $position . '.mp3') < 2) { //stop the loop $continue_mp3split_loop = 0; //delete last empty file unlink($archive_path . "/" . $current_file_dir . '/' . 'file' . $position . '.mp3'); } else { //write file URL to m3u8-index $m3u8_file = $m3u8_file . "#EXTINF:" . $partlenght . ", \n" . $extern_archive_path . "/" . $current_file_dir . '/' . 'file' . $position . '.mp3 '; } //count up the secondcounter for next part $position = $position + $partlenght;