<!--
  ~ Copyright (C) 2024 Xibo Signage Ltd
  ~
  ~ Xibo - Digital Signage - https://xibosignage.com
  ~
  ~ This file is part of Xibo.
  ~
  ~ Xibo is free software: you can redistribute it and/or modify
  ~ it under the terms of the GNU Affero General Public License as published by
  ~ the Free Software Foundation, either version 3 of the License, or
  ~ any later version.
  ~
  ~ Xibo is distributed in the hope that it will be useful,
  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  ~ GNU Affero General Public License for more details.
  ~
  ~ You should have received a copy of the GNU Affero General Public License
  ~ along with Xibo.  If not, see <http://www.gnu.org/licenses/>.
  -->
<module>
    <id>core-video</id>
    <name>Video</name>
    <author>Core</author>
    <description>Upload Video files to assign to Layouts</description>
    <icon>fa fa-file-video-o</icon>
    <class>\Xibo\Widget\VideoProvider</class>
    <validatorClass>\Xibo\Widget\Validator\ZeroDurationValidator</validatorClass>
    <type>video</type>
    <dataType></dataType>
    <schemaVersion>1</schemaVersion>
    <assignable>1</assignable>
    <regionSpecific>0</regionSpecific>
    <renderAs>native</renderAs>
    <defaultDuration>0</defaultDuration>
    <hasThumbnail>1</hasThumbnail>
    <settings>
        <property id="validExtensions" type="text">
            <title>Valid Extensions</title>
            <helpText>The Extensions allowed on files uploaded using this module. Comma Separated.</helpText>
            <default>wmv,avi,mpg,mpeg,webm,mp4</default>
        </property>
        <property id="defaultMute" type="checkbox">
            <title>Default Mute?</title>
            <helpText>Should new Video Widgets default to Muted?</helpText>
            <default>1</default>
        </property>
        <property id="defaultScaleType" type="dropdown" mode="single">
            <title>Default Scale type</title>
            <helpText>How should new Video Widgets be scaled by default?</helpText>
            <default>aspect</default>
            <options>
                <option name="aspect">Aspect</option>
                <option name="stretch">Stretch</option>
            </options>
        </property>
    </settings>
    <properties>
        <property id="message-duration" type="message" includeInXlf="false">
            <title>This video will play for %media.duration% seconds. Cut the video short by setting a shorter duration in the Advanced tab. Wait on the last frame or set to Loop by setting a higher duration in the Advanced tab.</title>
        </property>
        <property id="loop" type="checkbox">
            <title>Loop?</title>
            <helpText>Should the video loop if it finishes before the provided duration?</helpText>
            <default>0</default>
            <visibility>
                <test type="and">
                    <condition field="useDuration" type="eq">1</condition>
                    <condition field="duration" type="gt">$media.duration$</condition>
                </test>
            </visibility>
        </property>
        <property id="scaleType" type="dropdown" mode="single">
            <title>Scale type</title>
            <helpText>How should this video be scaled?</helpText>
            <default>%defaultScaleType%</default>
            <options>
                <option name="aspect">Aspect</option>
                <option name="stretch">Stretch</option>
            </options>
        </property>
        <property id="mute" type="checkbox">
            <title>Mute?</title>
            <helpText>Should the video be muted?</helpText>
            <default>%defaultMute%</default>
        </property>
        <property id="showFullScreen" type="checkbox">
            <title>Show Full Screen?</title>
            <helpText>Should the video expand over the top of existing content and show in full screen?</helpText>
            <default>0</default>
        </property>
    </properties>
    <preview>
        <twig><![CDATA[
{% if options.scaleTypeId == "stretch" %}
    {% set proportional = 0 %}
{% else %}
    {% set proportional = 1 %}
{% endif %}
<div class="img-container" style="display:table; width:100%; height: {{ height }}px">
    <i class="module-preview-icon fa fa-file-video-o" style="position:absolute; color:#ececec;text-shadow: 0 0 2px black;z-index: 1;left:50%;top:50%;transform:translate(-50%,-50%);font-size: 3rem;"></i>
    <div style="display: table-cell;vertical-align: middle;text-align: center;">
        <img src="{{ downloadUrl }}&width={{ width }}&height={{ height }}&proportional={{ proportional }}&fit=0"/>
    </div>
</div>
		]]></twig>
    </preview>
</module>
