Skip to content

Commit

Permalink
Add FLV (Adobe Flash Video) #11
Browse files Browse the repository at this point in the history
  • Loading branch information
odan committed Sep 3, 2019
1 parent 7fc1a01 commit 86b0876
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@
*.ogg binary
*.ogv binary
*.wmv binary
*.flv binary
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Video type detection library for PHP.
* **WEBM**
* **QuickTime**
* **WMV** (Windows Media Video)
* **FLV** (Adobe Flash Video)

## Requirements

Expand Down
29 changes: 29 additions & 0 deletions src/Detector/FlvDetector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Selective\VideoType\Detector;

use Selective\VideoType\VideoFormat;
use Selective\VideoType\VideoType;
use Selective\VideoType\VideoMimeType;
use SplFileObject;

/**
* Detector.
*/
final class FlvDetector implements VideoDetectorInterface
{
/**
* FLV - Adobe Flash Video.
*
* @param SplFileObject $file The video file
*
* @return VideoType|null The video type
*/
public function detect(SplFileObject $file): ?VideoType
{
return (string)$file->fread(3) === 'FLV' ? new VideoType(
VideoFormat::FLV,
VideoMimeType::VIDEO_FLV
) : null;
}
}
2 changes: 2 additions & 0 deletions src/Provider/DefaultVideoProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Selective\VideoType\Provider;

use Selective\VideoType\Detector\AviDetector;
use Selective\VideoType\Detector\FlvDetector;
use Selective\VideoType\Detector\MpegDetector;
use Selective\VideoType\Detector\Mpeg4Detector;
use Selective\VideoType\Detector\MkvDetector;
Expand Down Expand Up @@ -34,6 +35,7 @@ public function getDetectors(): array
new ThreeGp2Detector(),
new QuickTimeDetector(),
new WmvDetector(),
new FlvDetector(),
];
}
}
1 change: 1 addition & 0 deletions src/VideoFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ final class VideoFormat
public const THREEG2 = '3g2';
public const QUICK_TIME = 'mov';
public const WMV = 'wmv';
public const FLV = 'flv';
}
1 change: 1 addition & 0 deletions src/VideoMimeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ final class VideoMimeType
public const VIDEO_3G2 = 'video/3gpp2';
public const VIDEO_QUICK_TIME = 'video/quicktime';
public const VIDEO_WMV = 'video/x-ms-wmv';
public const VIDEO_FLV = 'video/x-flv';
}
1 change: 1 addition & 0 deletions tests/VideoTypeDetectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public function providerGetVideoTypeFromFile(): array
[__DIR__ . '/videos/test.mov', VideoFormat::QUICK_TIME, VideoMimeType::VIDEO_QUICK_TIME],
[__DIR__ . '/videos/test.ogv', VideoFormat::OGV, VideoMimeType::VIDEO_OGG],
[__DIR__ . '/videos/test.wmv', VideoFormat::WMV, VideoMimeType::VIDEO_WMV],
[__DIR__ . '/videos/test.flv', VideoFormat::FLV, VideoMimeType::VIDEO_FLV],
];
}

Expand Down
1 change: 1 addition & 0 deletions tests/videos/test.flv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FLV

0 comments on commit 86b0876

Please sign in to comment.