javascriptphpblobhtml5-audioflac

PHP ZipArchive, play FLAC audio file which is inside a zip archive without extraction


It is about the following:

I like to play an audio file which is inside a zip archive without extraction.

This is my current approach:

<?
$z = new ZipArchive();
if ($z->open(dirname(__FILE__) . '/archiv.zip')) {
    $string = $z->getFromName("Part.flac");
}

?>

<audio src="?????" controls></audio>

The reading part works, but getFromName returns a string, the question is now how to convert the string back to it's 'binary flac format', so that the audio element can play it.

Any other better approach?


Solution

  • you can't do anything with any file inside a zip, you always have to extract it (even if just into memory).