27 $file = fopen( $filename,
'rb' );
33 public static function findChunks( $file, $maxChunks = -1 ) {
34 $riff = fread( $file, 4 );
35 if ( $riff !==
'RIFF' ) {
40 $fileSize = fread( $file, 4 );
41 if ( !$fileSize || strlen( $fileSize ) != 4 ) {
46 $fourCC = fread( $file, 4 );
47 if ( !$fourCC || strlen( $fourCC ) != 4 ) {
60 while ( !feof( $file ) && !( $numberOfChunks >= $maxChunks && $maxChunks >= 0 ) ) {
61 $chunkStart = ftell( $file );
63 $chunkFourCC = fread( $file, 4 );
64 if ( !$chunkFourCC || strlen( $chunkFourCC ) != 4 ) {
68 $chunkSize = fread( $file, 4 );
69 if ( !$chunkSize || strlen( $chunkSize ) != 4 ) {
76 'fourCC' => $chunkFourCC,
77 'start' => $chunkStart,
78 'size' => $intChunkSize
82 $padding = $intChunkSize % 2;
84 fseek( $file, $intChunkSize + $padding, SEEK_CUR );
97 return unpack(
'V', $string )[1];