PHP code example of selective / video-type
1. Go to this page and download the library: Download selective/video-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 / video-type example snippets
use Selective\VideoType\VideoTypeDetector;
use Selective\VideoType\Provider\DefaultVideoProvider;
use SplFileObject;
$file = new SplFileObject('example.mp4');
$detector = new VideoTypeDetector();
// Add video detectors
$detector->addProvider(new DefaultVideoProvider());
$videoType = $detector->getVideoTypeFromFile($file);
// Get the video format
echo $videoType->getFormat(); // mp4
// Get the mime type
echo $videoType->getMimeType(); // video/mp4
$video = new SplTempFileObject();
$video->fwrite('my file content');
$detector = new VideoTypeDetector();
// Add video detectors
$detector->addProvider(new DefaultVideoProvider());
echo $detector->getVideoTypeFromFile($file)->getFormat();