30 public static function findChunks( $file, $maxChunks = -1 ) {
31 $riff = fread( $file, 4 );
32 if ( $riff !==
'RIFF' ) {
37 $fileSize = fread( $file, 4 );
38 if ( !$fileSize || strlen( $fileSize ) != 4 ) {
43 $fourCC = fread( $file, 4 );
44 if ( !$fourCC || strlen( $fourCC ) != 4 ) {
50 'fileSize' => self::extractUInt32( $fileSize ),
57 while ( !feof( $file ) && !( $numberOfChunks >= $maxChunks && $maxChunks >= 0 ) ) {
58 $chunkStart = ftell( $file );
60 $chunkFourCC = fread( $file, 4 );
61 if ( !$chunkFourCC || strlen( $chunkFourCC ) != 4 ) {
65 $chunkSize = fread( $file, 4 );
66 if ( !$chunkSize || strlen( $chunkSize ) != 4 ) {
69 $intChunkSize = self::extractUInt32( $chunkSize );
73 'fourCC' => $chunkFourCC,
74 'start' => $chunkStart,
75 'size' => $intChunkSize
79 $padding = $intChunkSize % 2;
81 fseek( $file, $intChunkSize + $padding, SEEK_CUR );