-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
72 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"admin": { | ||
"input_type": "charcoal/admin/property/input/video", | ||
"display_type": "charcoal/admin/property/display/video" | ||
} | ||
} |
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,66 @@ | ||
<?php | ||
|
||
namespace Charcoal\Property; | ||
|
||
// From 'charcoal-property' | ||
use Charcoal\Property\FileProperty; | ||
|
||
/** | ||
* Video Property. | ||
* | ||
* The video property is a specialized file property that handles video file. | ||
*/ | ||
class VideoProperty extends FileProperty | ||
{ | ||
/** | ||
* @return string | ||
*/ | ||
public function type() | ||
{ | ||
return 'video'; | ||
} | ||
|
||
/** | ||
* Retrieves the default list of acceptable MIME types for uploaded files. | ||
* | ||
* This method should be overriden. | ||
* | ||
* @return string[] | ||
*/ | ||
public function getDefaultAcceptedMimetypes() | ||
{ | ||
return [ | ||
'video/mp4', | ||
'video/webm', | ||
'video/ogg', | ||
'video/ogv', | ||
'video/x-matroska', | ||
]; | ||
} | ||
|
||
/** | ||
* Resolve the file extension from the given MIME type. | ||
* | ||
* @param string $type The MIME type to resolve. | ||
* @return string|null The extension based on the MIME type. | ||
*/ | ||
protected function resolveExtensionFromMimeType($type) | ||
{ | ||
switch ($type) { | ||
case 'video/mp4': | ||
return 'mp4'; | ||
|
||
case 'video/webm': | ||
return 'webm'; | ||
|
||
case 'video/ogg': | ||
case 'video/ogv': | ||
return 'ogv'; | ||
|
||
case 'video/x-matroska': | ||
return 'mkv'; | ||
} | ||
|
||
return null; | ||
} | ||
} |