-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from open-source-contributions/issue_#22
Resolves issue #22
- Loading branch information
Showing
7 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,3 +42,4 @@ | |
*.aac binary | ||
*.wma binary | ||
*.au binary | ||
*.rmi binary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Selective\AudioType\Detector; | ||
|
||
use Selective\AudioType\AudioFormat; | ||
use Selective\AudioType\AudioMimeType; | ||
use Selective\AudioType\AudioType; | ||
use SplFileObject; | ||
|
||
/** | ||
* Detector. | ||
*/ | ||
final class RmiDetector implements AudioDetectorInterface | ||
{ | ||
/** | ||
* Detect RMI, RIFF-MIDI audio format. | ||
* | ||
* @param SplFileObject $file The audio file | ||
* | ||
* @return AudioType|null The audio type | ||
*/ | ||
public function detect(SplFileObject $file): ?AudioType | ||
{ | ||
$magicNumber = (string)$file->fread(4); | ||
$header = (string)$file->fread(25); | ||
$hasIdentifiedHeader = strpos($header, 'RMIDdata') !== false || strpos($header, 'MThd') !== false; | ||
|
||
return $magicNumber === 'RIFF' && $hasIdentifiedHeader ? new AudioType( | ||
AudioFormat::RMI, | ||
AudioMimeType::AUDIO_RMI | ||
) : null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.