3
* Xibo - Digital Signage - http://www.xibo.org.uk
4
* Copyright (C) 2017 Spring Signage Ltd.
6
* This file is part of Xibo.
8
* Xibo is free software: you can redistribute it and/or modify
9
* it under the terms of the GNU Affero General Public License as published by
10
* the Free Software Foundation, either version 3 of the License, or
13
* Xibo is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU Affero General Public License for more details.
18
* You should have received a copy of the GNU Affero General Public License
19
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
21
namespace Xibo\Widget;
23
use InvalidArgumentException;
24
use Respect\Validation\Validator as v;
26
class VideoIn extends ModuleWidget
29
* Install or Update this module
30
* @param ModuleFactory $moduleFactory
32
public function installOrUpdate($moduleFactory)
34
if ($this->module == null) {
36
$module = $moduleFactory->createEmpty();
37
$module->name = 'Video In';
38
$module->type = 'videoin';
39
$module->class = 'Xibo\Widget\VideoIn';
40
$module->description = 'A module for displaying Video and Audio from an external source';
41
$module->imageUri = 'forms/video.gif';
43
$module->previewEnabled = 0;
44
$module->assignable = 1;
45
$module->regionSpecific = 1;
46
$module->renderAs = 'native';
47
$module->schemaVersion = $this->codeSchemaVersion;
48
$module->defaultDuration = 60;
49
$module->settings = [];
51
$this->setModule($module);
52
$this->installModule();
55
// Check we are all installed
56
$this->installFiles();
63
public function validate()
66
if (!v::stringType()->notEmpty()->validate($this->getOption('sourceId')))
67
throw new InvalidArgumentException(__('Please Select the sourceId'));
69
if ($this->getUseDuration() == 1 && !v::intType()->min(1)->validate($this->getDuration()))
70
throw new InvalidArgumentException(__('You must enter a duration.'));
76
$this->setDuration($this->getSanitizer()->getInt('duration', $this->getDuration()));
77
$this->setUseDuration($this->getSanitizer()->getCheckbox('useDuration'));
78
$this->setOption('sourceId', $this->getSanitizer()->getString('sourceId' , 'hdmi'));
87
public function edit()
90
$this->setDuration($this->getSanitizer()->getInt('duration', $this->getDuration()));
91
$this->setUseDuration($this->getSanitizer()->getCheckbox('useDuration'));
92
$this->setOption('sourceId', $this->getSanitizer()->getString('sourceId' ,'hdmi'));
100
public function isValid()
107
* Default code for the hover preview
110
public function hoverPreview()
112
// Default Hover window contains a thumbnail, media type and duration
113
$output = '<div class="well">';
114
$output .= '<div class="preview-module-image"><img alt="' . __($this->module->name) . ' thumbnail" src="' . $this->getConfig()->uri('img/' . $this->module->imageUri) . '" /></div>';
115
$output .= '<div class="info">';
117
$output .= ' <li>' . __('Type') . ': ' . $this->module->name . '</li>';
118
$output .= ' <li>' . __('Name') . ': ' . $this->getName() . '</li>';
119
$output .= ' <li>' . __('Input') . ': ' . $this->getOption('sourceId') . '</li>';
120
if ($this->getUseDuration() == 1)
121
$output .= ' <li>' . __('Duration') . ': ' . $this->widget->duration . ' ' . __('seconds') . '</li>';