Commit 14c2f0c7 authored by kent@passingphase.nz's avatar kent@passingphase.nz

first commit

parents
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/video_js.iml" filepath="$PROJECT_DIR$/.idea/video_js.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="4df796ff-6ad7-4a93-beee-7c55d0483146" name="Default" comment="" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ComposerSettings" synchronizationState="SYNCHRONIZE">
<pharConfigPath>$PROJECT_DIR$/composer.json</pharConfigPath>
</component>
<component name="FileEditorManager">
<leaf>
<file leaf-file-name="video_js.info.yml" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/video_js.info.yml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="video_js.libraries.yml" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/video_js.libraries.yml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="video_js.links.action.yml" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/video_js.links.action.yml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="video_js.links.menu.yml" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/video_js.links.menu.yml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="video_js.module" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/video_js.module">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="306">
<caret line="21" column="0" lean-forward="false" selection-start-line="21" selection-start-column="0" selection-end-line="21" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="video_js.permissions.yml" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/video_js.permissions.yml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="video_js.routing.yml" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/video_js.routing.yml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="video-js--video.html.twig" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/templates/video-js--video.html.twig">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="VideoJsListBuilder.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/VideoJsListBuilder.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="738">
<caret line="56" column="0" lean-forward="true" selection-start-line="56" selection-start-column="0" selection-end-line="56" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="VideoJs.php" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/Entity/VideoJs.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/composer.json" />
<option value="$PROJECT_DIR$/README.md" />
<option value="$PROJECT_DIR$/video_js.module" />
<option value="$PROJECT_DIR$/templates/video-js--video.html.twig" />
</list>
</option>
</component>
<component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
<component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER" />
<component name="JsGulpfileManager">
<detection-done>true</detection-done>
<sorting>DEFINITION_ORDER</sorting>
</component>
<component name="PhpWorkspaceProjectConfiguration" backward_compatibility_performed="true" />
<component name="ProjectFrameBounds">
<option name="x" value="16" />
<option name="y" value="20" />
<option name="width" value="1561" />
<option name="height" value="1000" />
</component>
<component name="ProjectView">
<navigator currentView="ProjectPane" proportions="" version="1">
<flattenPackages />
<showMembers />
<showModules />
<showLibraryContents />
<hideEmptyPackages />
<abbreviatePackageNames />
<autoscrollToSource />
<autoscrollFromSource />
<sortByType />
<manualOrder />
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scope" />
<pane id="Scratches" />
<pane id="ProjectPane">
<subPane>
<expand>
<path>
<item name="video_js" type="b2602c69:ProjectViewProjectNode" />
<item name="video_js" type="2a2b976b:PhpTreeStructureProvider$1" />
</path>
<path>
<item name="video_js" type="b2602c69:ProjectViewProjectNode" />
<item name="video_js" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="src" type="2a2b976b:PhpTreeStructureProvider$1" />
</path>
<path>
<item name="video_js" type="b2602c69:ProjectViewProjectNode" />
<item name="video_js" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="src" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="Entity" type="2a2b976b:PhpTreeStructureProvider$1" />
</path>
<path>
<item name="video_js" type="b2602c69:ProjectViewProjectNode" />
<item name="video_js" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="templates" type="2a2b976b:PhpTreeStructureProvider$1" />
</path>
</expand>
<select />
</subPane>
</pane>
</panes>
</component>
<component name="PropertiesComponent">
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
<property name="settings.editor.selected.configurable" value="preferences.sourceCode.Sass" />
<property name="WebServerToolWindowFactoryState" value="false" />
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="ShelveChangesManager" show_recycled="false">
<option name="remove_strategy" value="false" />
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="4df796ff-6ad7-4a93-beee-7c55d0483146" name="Default" comment="" />
<created>1521584888072</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1521584888072</updated>
<workItem from="1521584889255" duration="509000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="509000" />
</component>
<component name="ToolWindowManager">
<frame x="16" y="20" width="1561" height="1000" extended-state="0" />
<editor active="true" />
<layout>
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.24983819" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Docker" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
</layout>
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
</component>
<component name="VcsContentAnnotationSettings">
<option name="myLimit" value="2678400000" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager />
<watches-manager />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/composer.json">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="153">
<caret line="9" column="0" lean-forward="false" selection-start-line="9" selection-start-column="0" selection-end-line="9" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/README.md">
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state split_layout="SPLIT">
<first_editor relative-caret-position="0">
<caret line="0" column="73" lean-forward="false" selection-start-line="0" selection-start-column="73" selection-end-line="0" selection-end-column="73" />
<folding />
</first_editor>
<second_editor />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/video_js.info.yml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/video_js.libraries.yml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/video_js.links.action.yml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/video_js.links.menu.yml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/video_js.module">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="306">
<caret line="21" column="0" lean-forward="false" selection-start-line="21" selection-start-column="0" selection-end-line="21" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/video_js.permissions.yml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/video_js.routing.yml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/templates/video-js--video.html.twig">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/VideoJsListBuilder.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="738">
<caret line="56" column="0" lean-forward="true" selection-start-line="56" selection-start-column="0" selection-end-line="56" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Entity/VideoJs.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</component>
</project>
\ No newline at end of file
Use the Video JS library to apply videos to html elements on your website
## Install
Unzip library from github: https://github.com/videojs/video.js
Create /libraries/video-js folder
Copy/move video.min.js and video-js.min.css into video-js folder
This library is not published as a composer package
## Add Content
Video JS items are added as content and not configuration
Go to /admin/config/user-interface/video_js/sources to add sources
The target element is the element on the page that you wish to apply the video to.
The video is prepended to the target element
{
"name": "drupal/video_js",
"type": "drupal-module",
"description": "The Video JS module enables to attach background video to site pages",
"keywords": ["Drupal"],
"license": "GPL-2.0+",
"homepage": "https://www.drupal.org/project/video_js",
"minimum-stability": "dev",
"require": {
}
}
/**
* @file
* Javascript functionality for VideoJs
*/
(function ($, Drupal, drupalSettings) {
"use strict";
Drupal.behaviors.videoJs = {
attach: function (context, settings) {
if(typeof settings.video_js != 'undefined') {
// We insert the html into the element
var element = settings.video_js.element;
var html = settings.video_js.html;
$(element).prepend(html);
var options = {};
var player = videojs('my-player', options, function onPlayerReady() {
// In this context, `this` is the player that was created by Video.js.
this.play();
// How about an event listener?
// this.on('ended', function() {
// videojs.log('Awww...over so soon?!');
// });
});
}
updateSize(element);
// set events
$(window).resize( function() {
updateSize(element);
});
}
};
function updateSize(element) {
var containerW = $(element).outerWidth() < $(window).width() ? $(element).outerWidth() : $(window).width(),
containerH = $(element).outerHeight() < $(window).height() ? $(element).outerHeight() : $(window).height(),
containerAspect = containerW/containerH;
var mediaAspect = 16/9;
var vidEl = '#my-player';
if (containerAspect < mediaAspect) {
// taller
$(vidEl)
.width(containerH*mediaAspect)
.height(containerH);
// if (!settings.shrinkable) {
$(vidEl)
.css('top',0)
.css('left',-(containerH*mediaAspect-containerW)/2)
.css('height',containerH);
// } else {
// $(vidEl)
// .css('top',-(containerW/mediaAspect-containerH)/2)
// .css('left',0)
// .css('height',containerW/mediaAspect);
// }
$(vidEl+'_html5_api')
.css('width',containerH*mediaAspect)
.css('height',containerH);
$(vidEl+'_flash_api')
.css('width',containerH*mediaAspect)
.css('height',containerH);
} else {
// wider
$(vidEl)
.width(containerW);
$(vidEl)
.css('top',-(containerW/mediaAspect-containerH)/2)
.css('left',0)
.css('height',containerW/mediaAspect);
}
}
})(jQuery, Drupal, drupalSettings);
<?php
namespace Drupal\video_js\Entity;
use Drupal\Core\Entity\ContentEntityBase;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\file\Entity\File;
/**
* Defines the Video JS entity.
*
* @ContentEntityType(
* id = "video_js",
* label = @Translation("Video JS"),
* bundle_label = @Translation("Video JS type"),
* handlers = {
* "list_builder" = "Drupal\video_js\VideoJsListBuilder",
* "form" = {
* "default" = "Drupal\video_js\Form\VideoJsForm",
* "add" = "Drupal\video_js\Form\VideoJsForm",
* "edit" = "Drupal\video_js\Form\VideoJsForm",
* "delete" = "Drupal\video_js\Form\VideoJsDeleteForm"
* },
* },
* base_table = "video_js",
* admin_permission = "administer video js",
* entity_keys = {
* "id" = "pid",
* "label" = "label",
* "langcode" = "langcode",
* "uuid" = "uuid",
* "status" = "status"
* },
* links = {
* "canonical" = "/admin/config/user-interface/video_js/pages/{video_js}",
* "add-form" = "/admin/config/user-interface/video_js/pages/add",
* "edit-form" = "/admin/config/user-interface/video_js/pages/{video_js}/edit",
* "delete-form" = "/admin/config/user-interface/video_js/pages/{video_js}/delete",
* }
* )
*/
class VideoJs extends ContentEntityBase implements VideoJsInterface {
/**
* The Video JS ID.
*
* @var string
*/
protected $id;
/**
* The Video JS label.
*
* @var string
*/
protected $label;
/**
* The Video JS path.
*
* @var string
*/
protected $path;
/**
* {@inheritdoc}
*/
public function getPath() {
return $this->get('paths')->getvalue()[0]['value'];
}
/**
* {@inheritdoc}
*/
public function setPath($path) {
$this->path = $path;
return $this;
}
/**
* The VideoJs Source label.
*
* @var string
*/
protected $type = self::TYPE_FILE;
/**
* Get source type.
*
* @return string
* Source type.
*/
public function getType() {
return $this->type;
}
/**
* Get Link
*
* @return string
* link to file.
*/
public function getLink() {
return $this->get('link')->getValue();
}
/**
* Get the file path.
*
* @return string
* File path
*/
public function getFile() {
return $this->get('file')->getValue()[0]['target_id'];
}
/**
* Get the file format.
*
* @return string
* File format.
*/
public function getFormat() {
return $this->get('format')->getValue()[0]['value'];
}
/**
* Create the links to the video
*
* @return array
*/
public function createVideoLinks() {
if ($this->getType() == static::TYPE_FILE) {
$file = File::load($this->getFile());
return file_create_url($file->getFileUri());
}
return $this->getLink();
}
/**
* Get the target element.
*
* @return string
* File format.
*/
public function getElement() {
return $this->get('element')->getValue()[0]['value'];
}
/**
* Get the video html.
*
* @return array
* Html render array.
*/
public function getHtml() {
$renderer = \Drupal::service('renderer');
$render_array = [
'#theme' => 'video_js__video',
'#source' => $this->createVideoLinks(),
'#format' => $this->getFormat()
];
return $renderer->renderPlain($render_array);
}
/**
* Sets the source language.
*
* @param string $language
* Language code.
*/
public function setLanguage($language) {
$this->set('language', $language);
}
/**
* Sets the source created datetime.
*
* @param int $datetime
* The redirect created datetime.
*/
public function setCreated($datetime) {
$this->set('created', $datetime);
}
/**
* Gets the redirect created datetime.
*
* @return int
* The redirect created datetime.
*/
public function getCreated() {
return $this->get('created')->value;
}
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = [];
$fields['pid'] = BaseFieldDefinition::create('integer')
->setLabel(t('Id'))
->setDescription(t('The id for this source.'))
->setReadOnly(TRUE)
->setSetting('unsigned', TRUE);
$fields['label'] = BaseFieldDefinition::create('string')
->setLabel(t('Label'))
->setDescription(t('The label for this page.'))
->setRequired(TRUE)
->setDisplayOptions('form', array(