{{!
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 mod_interactivevideo/player
TODO describe template player
Example context (json):
{
}
}}
{{! Required for viostream, bunnystream.}}
{{#useembedly}}
<script src="https://cdn.embed.ly/player-0.1.0.min.js"></script>
{{/useembedly}}
<div id="interactivevideo-container"
     class="container-fluid {{#darkmode}}p-sm-3{{/darkmode}} {{^darkmode}}p-sm-3{{/darkmode}} alternative {{#displayoptions.distractionfreemode}}position-absolute{{/displayoptions.distractionfreemode}}"
     data-complete="{{completed}}">
    <div class="row justify-content-center mx-0">
        <div class="col-12 px-0">
            <div id="wrapper" class="position-relative mx-auto">
                <div id="video-wrapper"
                     class="d-flex align-items-center justify-content-center {{^darkmode}}border{{/darkmode}}">
                    {{! start of toolbar}}
                    <div id="toolbar" class="bg-transparent pt-5 position-fixed"></div>
                    {{! end of toolbar }}
                    <div class="position-absolute w-100 h-100 no-pointer bg-transparent"
                         id="background-loading"
                         style="display:none">
                        <div class="d-flex h-100 align-items-center justify-content-center">
                            <div class="spinner-border text-danger"
                                 style="width: 3rem;
                                        height: 3rem"
                                 role="status">
                                <span class="sr-only">Loading...</span>
                            </div>
                        </div>
                    </div>
                    {{#displayoptions.hidemainvideocontrols}}
                    <span class="rotatex-360 btn border-0 btn-sm btn-control iv-rounded-circle p-1"
                          id="fullscreen"
                          data{{bs}}-toggle="tooltip" data{{bs}}-container="#wrapper"
                          data{{bs}}-trigger="hover"
                          data{{bs}}-title="{{#str}}togglefullscreen,mod_interactivevideo{{/str}}"><i class="bi bi-fullscreen"></i></span>
                {{/displayoptions.hidemainvideocontrols}}
                {{^displayoptions.disablechapternavigation}}
                <div id="chapter-container-left"
                     class="d-none sticky-top position-fixed w-100">
                    <div data-region="chapterwrapper"
                         class="d-flex w-100 position-absolute h-100 flex-column shadow">
                        <div class="w-100 p-3 d-flex flex-column">
                            <button id="closechapter"
                                    class="btn btn-small iv-rounded-circle p-0 bg-secondary border-0">
                                <i class="fa fa-times"></i>
                            </button>
                            <div class="metadata"></div>
                            <span class="h4 mt-2 mb-0 text-truncate">{{{title}}}</span>
                        </div>
                        <ul data-region="chapterlists" class="list-group w-100 iv-rounded-0 m-0">
                        </ul>
                    </div>
                </div>
            {{/displayoptions.disablechapternavigation}}
            {{^displayoptions.useoriginalvideocontrols}}
            <div class="video-block"></div>
        {{/displayoptions.useoriginalvideocontrols}}
        {{#displayasstartscreen}}
        <div id="start-screen"
             class="w-100 position-absolute h-100 bg-white bottom-0">
            <div class="intro-content {{#hasintro}}hasintro{{/hasintro}} bg-light w-100 p-0 align-items-start">
                <div id="title-section"
                     class="bg-secondary w-100 d-flex align-items-center justify-content-between p-3 overflow-hidden position-sticky">
                    <div class="d-flex flex-column justify-content-center" style="max-width: calc(100% - 3rem);">
                        <div class="metadata d-block d-md-none"></div>
                        <h2 class="line-height-100 mb-0 title">{{{title}}}</h2>
                    </div>
                    <div id="spinner"
                         class="spinner-border text-danger"
                         style="width: 3rem;
                                height: 3rem"
                         role="status">
                        <span class="sr-only">Loading...</span>
                    </div>
                    <button id="play"
                            class="btn btn-flex iv-rounded-circle d-none pulse bg-white position-sticky">
                        <i class="bi bi-play-circle-fill text-danger"></i>
                    </button>
                </div>
                {{#hasintro}}
                <div class="p-2 p-md-3">{{{intro}}}</div>
            {{/hasintro}}
        </div>
    </div>
{{/displayasstartscreen}}
{{^displayasstartscreen}}
<div id="start-screen" class="w-100 position-absolute h-100 bottom-0 {{#square}}square{{/square}}" {{#posterimage}}style="background: url({{{posterimage}}}) center center / cover no-repeat;"{{/posterimage}} data-poster="{{{posterimage}}}">
    <div class="intro-content d-flex align-items-center justify-content-center position-absolute w-100"></div>
    <div id="video-info"
         class="p-1 p-sm-3 text-white w-100 h-100 position-absolute align-items-start flex-column justify-content-between d-flex">
        <div class="justify-content-between w-100 h-100 d-flex flex-column">
            <div class="metadata d-block d-md-none"></div>
            <span class="h1 text-white iv-font-weight-bold line-height-100 m-1 m-sm-2 p-sm-2 p-1">{{{title}}}</span>
        </div>
        <div id="spinner"
             class="spinner-border text-danger position-absolute"
             role="status"
             style="width: 3rem;
                    height: 3rem;
                    left: calc(50% - 1.5rem);
                    top: calc(50% - 1.5rem)">
            <span class="sr-only">Loading...</span>
        </div>
        <button class="btn btn-flex  bg-white iv-rounded-circle d-none position-absolute pulse"
                id="play">
            <i class="bi bi-play-circle-fill text-danger"></i>
        </button>
    </div>
</div>
{{/displayasstartscreen}}
<div id="end-screen"
     class="w-100 position-absolute h-100 {{#hasendscreentext}}bg-light{{/hasendscreentext}}{{^hasendscreentext}}{{^darkmode}}bg-light{{/darkmode}}{{#darkmode}}bg-black{{/darkmode}}{{/hasendscreentext}} d-none bottom-0">
    <div class="end-content {{#hasendscreentext}}hascontent w-100 p-0 align-items-start{{/hasendscreentext}}">
        {{#hasendscreentext}}
        <div id="title-section"
             class="bg-secondary w-100 d-flex align-items-center justify-content-between p-3 overflow-hidden position-sticky">
            <div class="d-flex flex-column justify-content-center">
                <div class="metadata d-block d-md-none"></div>
                <span class="h1 line-height-100 mb-0 title">{{{title}}}</span>
            </div>
            <button class="btn btn-flex btn-danger iv-rounded-circle pulse position-sticky"
                    id="restart">
                <i class="bi bi-arrow-repeat"></i>
            </button>
        </div>
        <div class="p-2 p-md-3">{{{endscreentext}}}</div>
    {{/hasendscreentext}} {{^hasendscreentext}}
    <button class="btn btn-flex btn-danger iv-rounded-circle pulse" id="restart">
        <i class="bi bi-arrow-repeat"></i>
    </button>
{{/hasendscreentext}}
</div>
</div>
<div id="annotation-canvas" class="d-none w-0">
    {{#html5}}
    <video id="player">
    </video>
{{/html5}}
{{^html5}}
<div id="player" class="p-0"></div>
{{/html5}}
</div>
{{#displayoptions.hidemainvideocontrols}}
<div id="lightprogress">
<div id="lightprogressbar"
     class="bg-danger position-absolute h-100"
     style="width: 0%"></div>
</div>
{{/displayoptions.hidemainvideocontrols}}
</div>
{{> mod_interactivevideo/controls}}
</div>
{{! Content }}
<div id="annotation-content"
     class="position-relative overflow-hidden border-0 mx-auto"></div>
</div>
</div>
</div>
{{> mod_interactivevideo/blocksettingshack }}
