anybody know how to read the first 30 seconds of an mp3 file using php, as a preview version of the original mp3?

Recommended Answers

I'm not aware of any way to do this without using a library of some sort. Try google.

Here's one I just found by googling

Jump to Post

All 3 Replies

Thanks that worked..

Before, I found another version of that class online, but it didn't work properly.

Here is the code for those it would help..

header('Content-type: audio/mp3');
			header('Content-disposition: attachment; filename="afda.mp3"');
			header('X-Pad: avoid browser bug');
			header('Cache-Control: no-cache');
			$path = 'teachings/afda.mp3';
			$mp3 = new mp3($path);
			$mp3_1 = $mp3->extract(0,30);
			header('Content-length: ' . sizeof($mp3_1->str));
			echo $mp3_1->str;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.