PHP code example of selective / audio-type
1. Go to this page and download the library: Download selective/audio-type library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
selective / audio-type example snippets
use Selective\AudioType\AudioTypeDetector;
use Selective\AudioType\Provider\DefaultAudioProvider;
use SplFileObject;
$file = new SplFileObject('example.mp3');
$detector = new AudioTypeDetector();
// Add audio detectors
$detector->addProvider(new DefaultAudioProvider());
$audioType = $detector->getAudioTypeFromFile($file);
// Get the audio format
echo $audioType->getFormat(); // mp3
// Get the mime type
echo $audioType->getMimeType(); // audio/mp3
use Selective\AudioType\AudioTypeDetector;
use Selective\AudioType\Provider\DefaultAudioProvider;
use SplTempFileObject;
$audio = new SplTempFileObject();
$audio->fwrite('my file content');
$detector = new AudioTypeDetector();
// Add audio detectors
$detector->addProvider(new DefaultAudioProvider());
echo $detector->getAudioTypeFromFile($audio)->getFormat();