Created
January 8, 2020 22:16
-
-
Save ericjgruber/0fb070e5dbcbf299703015d09bf87036 to your computer and use it in GitHub Desktop.
Video Embed Field Plugin for Qumu Video
This file contains hidden or 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
<?php | |
namespace Drupal\module_name\Plugin\video_embed_field\Provider; | |
use Drupal\video_embed_field\ProviderPluginBase; | |
/** | |
* @VideoEmbedProvider( | |
* id = "qumu", | |
* title = @Translation("QUMU") | |
* ) | |
*/ | |
class Qumu extends ProviderPluginBase { | |
/** | |
* {@inheritdoc} | |
*/ | |
public function renderEmbedCode($width, $height, $autoplay) { | |
$embed_code = [ | |
'#type' => 'video_embed_iframe', | |
'#provider' => 'qumu', | |
'#url' => sprintf('https://resources.qumucloud.com/view/%s', $this->getVideoId()), | |
'#query' => [ | |
'autoplay' => $autoplay, | |
], | |
'#attributes' => [ | |
'width' => $width, | |
'height' => $height, | |
'frameborder' => '0', | |
'allowfullscreen' => 'allowfullscreen', | |
], | |
]; | |
return $embed_code; | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public function getRemoteThumbnailUrl() { | |
//todo: Does Qumu offer a URL to get a thumbnail? | |
return ''; | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public static function getIdFromInput($input) { | |
preg_match('/(?:https:\/\/resources.qumucloud.com\/view\/(?<id>[a-zA-Z0-9]{11}))/', $input, $matches); | |
return isset($matches['id']) ? $matches['id'] : FALSE; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment