diff --git a/.gitattributes b/.gitattributes index 171d8a5..0a94073 100644 --- a/.gitattributes +++ b/.gitattributes @@ -41,3 +41,4 @@ *.caf binary *.aac binary *.wma binary +*.au binary diff --git a/src/AudioFormat.php b/src/AudioFormat.php index f89c261..a20e8f9 100644 --- a/src/AudioFormat.php +++ b/src/AudioFormat.php @@ -19,4 +19,5 @@ final class AudioFormat public const CAF = 'caf'; public const AAC = 'aac'; public const WMA = 'wma'; + public const AU = 'au'; } diff --git a/src/AudioMimeType.php b/src/AudioMimeType.php index 73cf690..45c5d07 100644 --- a/src/AudioMimeType.php +++ b/src/AudioMimeType.php @@ -19,4 +19,5 @@ final class AudioMimeType public const AUDIO_CAF = 'audio/x-caf'; public const AUDIO_AAC = 'audio/aac'; public const AUDIO_WMA = 'audio/x-ms-wma'; + public const AUDIO_AU = 'audio/basic'; } diff --git a/src/Detector/AuDetector.php b/src/Detector/AuDetector.php new file mode 100644 index 0000000..9088194 --- /dev/null +++ b/src/Detector/AuDetector.php @@ -0,0 +1,31 @@ +fread(4); + + return $bytes === '.snd' ? new AudioType( + AudioFormat::AU, + AudioMimeType::AUDIO_AU + ) : null; + } +} diff --git a/src/Provider/DefaultAudioProvider.php b/src/Provider/DefaultAudioProvider.php index 820f497..841de81 100644 --- a/src/Provider/DefaultAudioProvider.php +++ b/src/Provider/DefaultAudioProvider.php @@ -14,6 +14,7 @@ use Selective\AudioType\Detector\CafDetector; use Selective\AudioType\Detector\AacDetector; use Selective\AudioType\Detector\WmaDetector; +use Selective\AudioType\Detector\AuDetector; /** * All supported audio formats. @@ -38,6 +39,7 @@ public function getDetectors(): array new CafDetector(), new AacDetector(), new WmaDetector(), + new AuDetector(), ]; } } diff --git a/tests/AudioTypeDetectorTest.php b/tests/AudioTypeDetectorTest.php index c07cdfb..3f8aacf 100644 --- a/tests/AudioTypeDetectorTest.php +++ b/tests/AudioTypeDetectorTest.php @@ -75,6 +75,7 @@ public function providerGetAudioTypeFromFile(): array 'CAF' => [__DIR__ . '/files/test.caf', AudioFormat::CAF, AudioMimeType::AUDIO_CAF], 'AAC' => [__DIR__ . '/files/test.aac', AudioFormat::AAC, AudioMimeType::AUDIO_AAC], 'WMA' => [__DIR__ . '/files/test.wma', AudioFormat::WMA, AudioMimeType::AUDIO_WMA], + 'AU' => [__DIR__ . '/files/test.au', AudioFormat::AU, AudioMimeType::AUDIO_AU], ]; } diff --git a/tests/files/test.au b/tests/files/test.au new file mode 100644 index 0000000..cbcfaab Binary files /dev/null and b/tests/files/test.au differ