Skip to content
Snippets Groups Projects
Commit f98c6411 authored by Robin Ingelbrecht's avatar Robin Ingelbrecht Committed by robin.ingelbrecht
Browse files

Updated readme

parent 1f6f42fc
No related branches found
No related tags found
No related merge requests found
This module add support for embedding HTML5 videos into your website using Video Embed Field
## Installation
To install this module, do the following:
1. Download the Video Embed HTML5 module and follow the instruction for
[installing contributed modules](https://www.drupal.org/docs/8/extending-drupal-8/installing-contributed-modules-find-import-enable-configure-drupal-8).
## Usage
1. Install module
2. Add video embed field and enable "HTML5" provider
3. Add link that ends with mp4/ogg/webm
## Generating thumbnails
* If you want to use the Thumbnail formatter, you have to install the [php_ffmpeg module](https://www.drupal.org/project/php_ffmpeg)
* Configure it properly (install dependent binaries)
\ No newline at end of file
......@@ -21,6 +21,7 @@ class Html5 extends ProviderPluginBase {
/** @var FFMpeg $phpFFMpeg */
protected $phpFFMpeg;
protected $filename;
/**
* Html5 constructor.
......@@ -38,6 +39,10 @@ class Html5 extends ProviderPluginBase {
if ($module_handler->moduleExists('php_ffmpeg')) {
$this->phpFFMpeg = \Drupal::service('php_ffmpeg');
}
// Set filename for thumbnail.
list($video_url, $video_type) = $this->getVideoId();
$this->filename = md5($video_url);
}
/**
......@@ -75,13 +80,11 @@ class Html5 extends ProviderPluginBase {
if (!file_exists($local_uri)) {
file_prepare_directory($this->thumbsDirectory, FILE_CREATE_DIRECTORY);
try {
// Thumb does not exist yet. Generate it.
list($video_url, $video_type) = $this->getVideoId();
// Thumb does not exist yet. Generate it.
$video = $this->phpFFMpeg->open($video_url);
$filename = md5($video_url);
$video->frame(TimeCode::fromSeconds(1))
->save(drupal_realpath($this->thumbsDirectory) . '/' . $filename . '.jpg');
->save(drupal_realpath($this->thumbsDirectory) . '/' . $this->filename . '.jpg');
} catch (\Exception $e) {
}
}
......@@ -98,9 +101,7 @@ class Html5 extends ProviderPluginBase {
* {@inheritdoc}
*/
public function getLocalThumbnailUri() {
list($video_url, $video_type) = $this->getVideoId();
$filename = md5($video_url);
return $this->thumbsDirectory . '/' . $filename . '.jpg';
return $this->thumbsDirectory . '/' . $this->filename . '.jpg';
}
/**
......
<?php
use Drupal\Core\Routing\RouteMatchInterface;
/**
* Implements hook_help().
*/
function video_embed_html5_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.video_embed_html5':
$output = file_get_contents(drupal_get_path('module', 'video_embed_html5') . '/README.md');
return '<pre>' . $output . '</pre>';
break;
default:
}
}
/**
* Implements hook_theme().
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment