32 public static function findChunks( $file, $maxChunks = -1 ) {
33 $riff = fread( $file, 4 );
34 if ( $riff !==
'RIFF' ) {
39 $fileSize = fread( $file, 4 );
40 if ( !$fileSize || strlen( $fileSize ) != 4 ) {
45 $fourCC = fread( $file, 4 );
46 if ( !$fourCC || strlen( $fourCC ) != 4 ) {
52 'fileSize' => self::extractUInt32( $fileSize ),
59 while ( !feof( $file ) && !( $numberOfChunks >= $maxChunks && $maxChunks >= 0 ) ) {
60 $chunkStart = ftell( $file );
62 $chunkFourCC = fread( $file, 4 );
63 if ( !$chunkFourCC || strlen( $chunkFourCC ) != 4 ) {
67 $chunkSize = fread( $file, 4 );
68 if ( !$chunkSize || strlen( $chunkSize ) != 4 ) {
71 $intChunkSize = self::extractUInt32( $chunkSize );
75 'fourCC' => $chunkFourCC,
76 'start' => $chunkStart,
77 'size' => $intChunkSize
81 $padding = $intChunkSize % 2;
83 fseek( $file, $intChunkSize + $padding, SEEK_CUR );