{% extends 'home/home.html' %}

{% import 'ui/comment_page.html' as pg %}

{% block css %}
    <!--播放页面-->
    {# DPlayer #}
    <link href="https://cdn.bootcss.com/dplayer/1.22.2/DPlayer.min.css" rel="stylesheet">

    {# jwplayer #}
    <link rel="stylesheet" type="text/css" href="{{ url_for('static',filename='jwplayer/skins/stormtrooper.css') }}">
    <script type="text/javascript" src="{{ url_for('static',filename='ueditor/ueditor.config.js') }}"></script>
    <script type="text/javascript" src="{{ url_for('static',filename='ueditor/ueditor.all.js') }}"></script>
    <script type="text/javascript" src="{{ url_for('static',filename='ueditor/lang/zh-cn/zh-cn.js') }}"></script>
    <script>
        SyntaxHighlighter.all();
    </script>
    <!--播放页面-->
    <style>
        .col-lg-1, .col-lg-10, .col-lg-11, .col-lg-12, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-md-1, .col-md-10, .col-md-11, .col-md-12, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-sm-1, .col-sm-10, .col-sm-11, .col-sm-12, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-xs-1, .col-xs-10, .col-xs-11, .col-xs-12, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9 {
            padding-right: 3px;
            padding-left: 3px;
        }
        body{
            background-image: url({{ url_for('static',filename='base/images/4.jpg') }});
            background-size: cover;
        }
    </style>

{% endblock %}

{% block content %}
    <div class="row">
        <div class="col-md-8">
            {# 视频插入 #}
{#            <div id="moviecontainer" style="height: 500px;width: 774px"></div>#}
            <div id="moviecontainer"></div>
        </div>
        {# 左上角logo #}
        {#        <div id="logo" style="width: 20px;height: 20px;"></div>#}

        <div class="col-md-4" style="height:500px;">
            <div class="panel panel-info">
                <div class="panel-heading">
                    <h3 class="panel-title"><span class="glyphicon glyphicon-facetime-video"></span>&nbsp;视频介绍</h3>
                </div>
                <div class="panel-body" style="height:459px;overflow: scroll;">  {#右侧视频详情的滚动条#}
                    <table class="table">
                        <tr>
                            <td style="width:30%;color:#ccc;font-weight:bold;font-style:italic;">
                                <span class="glyphicon glyphicon-film"></span>&nbsp;片名
                            </td>
                            <td>{{ movie.title }}</td>
                        </tr>
                        <tr>
                            <td style="color:#ccc;font-weight:bold;font-style:italic;">
                                <span class="glyphicon glyphicon-tag"></span>&nbsp;标签
                            </td>
                            <td>{{ tag.name }}</td>
                        </tr>
                        <tr>
                            <td style="color:#ccc;font-weight:bold;font-style:italic;">
                                <span class="glyphicon glyphicon-time"></span>&nbsp;片长
                            </td>
                            <td>{{ movie.length }}</td>
                        </tr>
                        <tr>
                            <td style="color:#ccc;font-weight:bold;font-style:italic;">
                                <span class="glyphicon glyphicon-map-marker"></span>&nbsp;地区
                            </td>
                            <td>{{ movie.area }}</td>
                        </tr>
                        <tr>
                            <td style="color:#ccc;font-weight:bold;font-style:italic;">
                                <span class="glyphicon glyphicon-star"></span>&nbsp;星级
                            </td>
                            <td>
                                <div>
                                    {# 实心星星#}
                                    {% for val in range(1,1+movie.star) %}
                                        <span class="glyphicon glyphicon-star" style="color:#FFD119"></span>
                                    {% endfor %}
                                    {# 空心星星#}
                                    {% for val in range(1,6-movie.star) %}
                                        <span class="glyphicon glyphicon-star-empty" style="color:#FFD119"></span>
                                    {% endfor %}
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td style="color:#ccc;font-weight:bold;font-style:italic;">
                                <span class="glyphicon glyphicon-calendar"></span>&nbsp;上映时间
                            </td>
                            <td>{{ movie.release_time }}</td>
                        </tr>
                        <tr>
                            <td style="color:#ccc;font-weight:bold;font-style:italic;">
                                <span class="glyphicon glyphicon-play"></span>&nbsp;播放数量
                            </td>
                            <td>{{ movie.playnum }}</td>
                        </tr>
                        <tr>
                            <td style="color:#ccc;font-weight:bold;font-style:italic;">
                                <span class="glyphicon glyphicon-comment"></span>&nbsp;评论数量
                            </td>
                            <td>{{ movie.commentnum }}</td>
                        </tr>
                        <tr>
                            <td style="color:#ccc;font-weight:bold;font-style:italic;">
                                <span class="glyphicon glyphicon-picture"></span>&nbsp;影片介绍
                            </td>
                            <td>
                                {{ movie.info }}
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
        </div>
        <div class="col-md-12" style="margin-top:6px;">
            <div class="panel panel-danger">
                <div class="panel-heading">
                    <h3 class="panel-title"><span class="glyphicon glyphicon-comment"></span>&nbsp;视频评论</h3>
                </div>
                <div class="panel-body">
                    {# 评论前需登录 #}
                    {% if 'user' not in session %}
                        <div class="alert alert-danger alert-dismissible" role="alert">
                            <button type="button" class="close" data-dismiss="alert">
                                <span aria-hidden="true">×</span>
                                <span class="sr-only">Close</span>
                            </button>
                            <strong>请先<a href="{{ url_for('home.login') }}" target="_blank" class="text-info">登录</a>后，才可参与评论哟~亲！</strong>
                        </div>
                    {% endif %}
                    <ol class="breadcrumb" style="margin-top:6px;">

                        <li>全部评论({{ movie.commentnum }})

                    </ol>
                    {# 登陆后才显示提交评论,收藏视频 #}
                    {% if 'user' in session %}
                        {# 添加标签成功时的消息提示(category_filter:分类闪现) #}
                        {% for msg in get_flashed_messages(category_filter=['ok']) %}
                            <div class="alert alert-success alert-dismissible">
                                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                                <h4><i class="icon fa fa-check"></i> 恭喜您,操作成功 !</h4>
                                {{ msg }}
                            </div>
                        {% endfor %}
                        {# 添加标签失败时的消息提示 #}
                        {% for msg in get_flashed_messages(category_filter=['err']) %}
                            <div class="alert alert-danger alert-dismissible">
                                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                                <h4><i class="icon fa fa-ban"></i> 抱歉,操作失败!</h4>
                                {{ msg }}
                            </div>
                        {% endfor %}
                        <form role="form" style="margin-bottom:6px;"  method="post">
                            <div class="form-group">
                                <div>
                                    <style type="text/css">
                                        #comment {
                                            width: 1126px;
                                        }
                                    </style>
                                    <label for="comment">{{ form.content.label }}</label><br>
                                    {# 原版(带表情的): <label for="input_content">{{ form.content.label }}</label><br>#}
                                    {{ form.content }}
                                </div>
                                {% for err in form.content.errors %}
                                    <div class="col-md-12">
                                        <font style="color:red">{{ err }}</font>
                                    </div>
                                {% endfor %}

                            </div>
                            {{ form.submit }}
                            {{ form.csrf_token }}
                            <a onclick="" class="btn btn-danger" id="btn-col"><span class="glyphicon glyphicon-heart"></span>&nbsp;收藏视频</a>
                        </form>
                        <div class="col-md-12">
                            <font style="color:green" id="show_col_msg"></font>
                        </div>
                        <div class="clearfix"></div>

                    {% endif %}

                    <ul class="commentList">
                        {% for v in page_data.items %}
                            <li class="item cl">
                                <a>
                                    <i class="avatar size-L radius">
                                        {% if v.user.face %}
                                            <img alt="50x50"
                                                 src="{{ url_for('static',filename='uploads/users/' + v.user.face) }}"
                                                 class="img-circle"
                                                 style="border:1px solid #abcdef;width: 50px;height: 50px;">
                                        {% else %}
                                            <img alt="50x50" data-src="holder.js/50x50" class="img-circle"
                                                 style="border:1px solid #abcdef;width: 50px;height: 50px;">
                                        {% endif %}
                                    </i>
                                </a>
                                <div class="comment-main">
                                    <header class="comment-header">
                                        <div class="comment-meta">
                                            <a class="comment-author" href="user.html">{{ v.user.name }}</a>
                                            评论于
                                            <time title="{{ v.addtime }}" datetime="{{ v.addtime }}">
                                                {{ v.addtime }}
                                            </time>
                                        </div>
                                    </header>
                                    <div class="comment-body">
                                        {# |safe:过滤内容中HTML的标签#}
                                        <p>{{ v.content |safe }}</p>
                                    </div>
                                </div>
                            </li>
                        {% endfor %}
                    </ul>
                    <div class="col-md-12 text-center">
                        {# 引入后台页码模板 #}
                        {{ pg.page(page_data,'home.play',movie.id) }}
                    </div>
                </div>
            </div>
        </div>
    </div>
{% endblock %}


{% block js %}
    <!--播放页面-->
{#     DPlayer#}
{#        <script src="https://cdn.bootcss.com/dplayer/1.22.2/DPlayer.min.js"></script>#}
{#        <script>#}
{#            const dp = new DPlayer({#}
{#                container: document.getElementById('moviecontainer'),  //以id来播放视频#}
{#                screenshot: false,   //截屏#}
{#                theme: '#ff4b44',     //进度条等主题颜色#}
{#                loop: false,           //循环播放#}
{#                logo: 'logo.png',    //视频左上角小logo图片#}
{#                video: {#}
{#                    url: '{{ url_for('static',filename='uploads/' + movie.url) }}'  //视频地址#}
{#                    // pic: '1.png',  //封面#}
{#                    // width:66,#}
{#                    // height:60#}
{#                    // thumbnails: '1.png'   //鼠标放在进度条上移动时的预览图片#}
{#                },#}
{#                //contextmenu:['']  //添加右键菜单#}
{#                // subtitle: {#}
{#                //     url: 'webvtt.vtt'#}
{#                // },#}
{#                //弹幕系统#}
{#                 danmaku: {#}
{#                    id: 'demo',#}
{#                    api: 'https://api.prprpr.me/dplayer/'#}
{#                }#}
{#            });#}
{#        </script>#}


    {# jwplayer #}
    <script src="{{ url_for('static',filename='jwplayer/jwplayer.js') }}"></script>
    <script>
        var ue = UE.getEditor('input_content', {
            toolbars: [
                ['fullscreen', 'emotion', 'preview', 'link']
            ],
            initialFrameWidth: "100%",
            initialFrameHeight: "100",
        });
    </script>
    <script type="text/javascript">
        jwplayer.key = "P9VTqT/X6TSP4gi/hy1wy23BivBhjdzVjMeOaQ==";
    </script>
    <script type="text/javascript">
        jwplayer("moviecontainer").setup({
            flashplayer: "{{ url_for('static',filename='jwplayer/jwplayer.flash.swf') }}",
            playlist: [{
                file: "{{ url_for('static',filename='uploads/' + movie.url) }}",
                title: "{{ movie.title }}"
            }],
            modes: [{
                type: "html5"
            }, {
                type: "flash",
                src: "{{ url_for('static',filename='jwplayer/jwplayer.flash.swf') }}"
            }, {
                type: "download"
            }],
            skin: {
                name: "seven"  //播放器皮肤(好看的:glow,seven) ;E:\Python_Project\movie_dplayer\app\static\jwplayer\skins
            },
            "playlist.position": "left",
            "playlist.size": 400,
            height: 500,
            width: 774,
            autostart:true,
        });
    </script>


    <!--播放页面-->
    {# AJAX获取视频ID和用户ID #}
    <script>
        {#$(document).ready(function(){#}
            $("#btn-col").click(function(){
                var mid = {{ movie.id }};
                var uid = {{ session['user_id'] }};
                {#var msg = $("#show_col_msg");#}
                $.ajax({
                    url:"{{ url_for('home.moviecol_add') }}",
                    type:"GET",
                    data:"mid=" + mid + "&uid=" + uid,
                    dataType:"json",
                    success:function(res){
                        if(res.ok == 1) {
                            $("#show_col_msg").empty();
                            $("#show_col_msg").append("收藏视频成功!");
                            alert("收藏视频成功!");
                        }else{
                            $("#show_col_msg").empty();
                            $("#show_col_msg").append("您已收藏此视频哦!");
                            alert("您已收藏此视频哦!");
                        }
                    }
                })
            });

    </script>

{% endblock %}