{% spaceless %}
{% load i18n %}
{% load thumbnail %}
<div>
<div id="{{ player_id }}_embed" class="iri_player_embed">
</div>
<script type="text/javascript">
  /* Redefine a few variables */  
IriSP.jwplayer_swf_path = "{{WEB_URL}}{{LDT_MEDIA_PREFIX}}swf/player.swf";
IriSP.libdir = "{{WEB_URL}}{{LDT_MEDIA_PREFIX}}js/";

IriSP.paths["imgs"] = "{{WEB_URL}}{{LDT_MEDIA_PREFIX}}css/imgs";
IriSP.default_templates_vars["img_dir"] = IriSP.paths.imgs;

IriSP.platform_url = "{{WEB_URL}}{{BASE_URL}}";
IriSP.user = {
    name: '{{request.user.username}}',
    avatar: '{% thumbnail request.user.get_profile.image "48x48" format="PNG" crop="center" as im %}{{WEB_URL}}{{ im.url }}{% endthumbnail %}',
};
  
      
var config = {            
    gui: {
        width: {{ player_width }},
        height: 600,  
        container: '{{ player_id }}_embed',
        css: '{{WEB_URL}}{{LDT_MEDIA_PREFIX}}css/LdtPlayer.css',
        default_options: {
            metadata:{
                format:'cinelab',
                src: '{{ json_url }}',
                type:'json'
            },
            width: {{ player_width }},
            cinecast_version: false
        },
        widgets: [
            {
                type: "PolemicWidget",
                height: 50,
                requires: [
                    {
                        type: "TooltipWidget",
                        width: 180,
                        height: 160,
                        metadata : {
                            type:'empty'
                        }
                    }
                ]
            },
            {
                type: "SparklineWidget",
                height: 50
            },
            {
                type: "SliderWidget"
            },
            {
                type: "AnnotationsListWidget",
                container: "annot_media"
            },
            {
                type: "PlayerWidget",
                mode: "radio"
            },
            {
                type: "SegmentsWidget",
             requires: [
                    {
                        type: "TooltipWidget",
                        width: 180,
                        height: 160,
                        metadata : {
                            type:'empty'
                        }
                    }
                ],
            },
            {
                type: "SliceWidget",
                mode: "radio"
            },            
            {
                type: "ArrowWidget"
            },
            {
                type: "AnnotationsWidget"
            },
            {
                type: "TweetsWidget"
            },
            {
                type: "createAnnotationWidget",
                api_endpoint_template: "{{WEB_URL}}{{BASE_URL}}/ldtplatform/api/ldt/annotations/{% templatetag openvariable %}id{% templatetag closevariable %}{% templatetag closebrace %}.json",
                keywords: ["#amateur", "#digital-humanities"]
            }      
        ]
    },
      {% if external_url %}
      player:{
          type: {% if "youtube.com" in external_url %}'youtube'{% else %}'dailymotion'{% endif %}, // player type
          height: 300, 
          width: {{ player_width }}, 
          video: '{{ external_url }}'
      },
      {% else %}
      player:{
          type:'jwplayer', // player type
          live: true, 
          height: 300, 
          width: {{ player_width }}, 
          provider: "rtmp" 
      },
      {% endif %}
      modules: [
               { type: "MediaFragment",
                  metadata:{
                 format:'cinelab',
                 src:'{{ json_url }}',
                 type:'json'}
            }]

    };

    IriSP.initPlayer(config, "{{ json_url }}");
</script>
</div>
{% endspaceless %}
