{{!
    This file is part of Moodle - http://moodle.org/

    Moodle is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Moodle 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 General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
}}
{{!
    @template videotimeplugin_live/video_embed

    This template will render the video time activity and load player in tab

    Variables required for this template:
    * uniqueid - Unique id of player on page
    * vimeo_url - vimeo url

    Variables optional for this template:
    * responsive - markup for next activity button
    * video_description - vimeo video descript

    Example context (json):
    {
        "responsive": true,
        "cmid": 3,
        "contextid": 3,
        "haspro": 0,
        "interval": 2.5,
        "instance": "{}",
        "peerid": 3,
        "token": "lklsdfj8af98e",
        "uniqueid": "60dccff8871f6",
        "video_description": "UX design tips",
        "video": 1,
        "vimeo_url": "https://vimeo.com/323424"
    }

}}
{{# instance }}
<div {{^responsive}}class="vimeo-container justify-content-center"{{/responsive}} data-roomid="{{ roomid }}" data-contextid="{{ contextid }}">
    <div class="videotime-embed video-resize">
        {{# posterurl }}
            <img src="{{ posterurl }}" class="poster-img w-100">
        {{/ posterurl }}
        <video class="w-100 hidden"
            id="video-embed-{{uniqueid}}"
            autoplay
            controls {{# playsinline }} playsinline {{/ playsinline }}
            muted
        >
        </video>
        <audio class="w-100"
            id="audio-embed-{{uniqueid}}"
            autoplay
            controls {{# playsinline }} playsinline {{/ playsinline }}
        >
        </audio>
    </div>
    <div class="vimeo-video-description">
        {{{video_description}}}
    </div>
</div>
{{/ instance }}
{{#js}}
    require(['videotimeplugin_live/videotime'], function(VideoTime) {
        var v = new VideoTime('video-embed-{{uniqueid}}', {{cmid}}, {{haspro}}, {{interval}}, {{{instance}}});
        v.initialize(
            {{ contextid }},
            '{{ token }}',
            {{ peerid }}
        );
    });
{{/js}}
