{% load staticfiles %}
<html>
<head>
<title>Test</title>
<link rel="stylesheet" type="text/css" href="{% static 'remie/css/markers.css' %}" />
<link rel="stylesheet" type="text/css" href="{% static 'remie/css/markers_teacher.css' %}" />
</head>
<body>
<div id="remie_player_container">
  <div id="media_panel">  
    <div id="player_container"></div>
    <div id="markers_upper_container"></div>
    <div id="markers_lower_container"></div>
  </div>
  <script type="text/javascript" src='{% static "remie/metadataplayer/LdtPlayer-core.js" %}'></script>
  <script type="text/javascript">
    
    if (typeof jQuery == "undefined") {
        jQuery = IriSP.jQuery;
    }
    var metadatas = {metadata: {url: "{% url 'projectjson_id' id=project_id %}?from_display=false"}};
    var metadata_key = "metadata"; 
    
    IriSP.libFiles.defaultDir = '{% static "remie/js/" %}';
    IriSP.libFiles.inDefaultDir.jQuery = 'jquery.js';
    IriSP.libFiles.locations.jwPlayerSWF = '{% static "remie/swf/player.swf" %}';
    IriSP.libFiles.locations.recordMicSwf = '{% static "remie/swf/record_mic.swf" %}';
    IriSP.libFiles.locations.zeroClipboardSwf = '{% static "remie/swf/ZeroClipboard10.swf" %}';
    IriSP.libFiles.locations.cssjQueryUI = '{% static "remie/css/jq-css/themes/base/jquery-ui.css" %}';
    IriSP.language = 'fr-fr';
   
    IriSP.widgetsDir = '{% static "remie/metadataplayer" %}';
    var _metadata = {
        url: metadatas[metadata_key].url,
        format: 'ldt'
    };
    var _config = {
      container: 'player_container',
      css: '{% static "remie/metadataplayer/LdtPlayer-core.css" %}',
      default_options: {
          metadata: _metadata
      },
      widgets: 
      [
        {
            type: "AutoPlayer",
            streamer: function(_url) {
                var _matches = _url.match(/^[^\/]+\/\/[^\/]+\/[^\/]+\//);
                if (_matches) {
                  return _matches[0];
                } else {
                  return _url;
                }
            },
            url_transform: function(url) {
                // Adaptation to jwplayer 6
                if(url.substr(url.length - 4).toLowerCase()=='.flv'){
                    return url.replace('/ddc_player/video/','/ddc_player/flv:video/');
                }
                return url.replace('/ddc_player/video/','/ddc_player/mp4:video/');
            },
            default_type: "AdaptivePlayer",
            autostart: false,
            height: 360,
            width: 640
        },{
           type: "Slider"
        },{
            type: "Controller",
            disable_annotate_btn: true,
            disable_search_btn: true,
            disable_ctrl_f: true
        },{
            type: "Markers",
            background: "#ffffff",
            annotation_type: "teacher_markers",
            container: "markers_upper_container",
            line_height: 50,
            project_id: "{{project_id}}",
            api_endpoint_template_create: "{% url 'api_dispatch_list' resource_name='annotations' api_name='1.0' %}",
            api_endpoint_template_edit: "{% url 'api_dispatch_list' resource_name='annotations' api_name='1.0' %}{% templatetag openvariable %}annotation_id{% templatetag closevariable %}/",
            api_endpoint_template_delete: "{% url 'api_dispatch_list' resource_name='annotations' api_name='1.0' %}{% templatetag openvariable %}annotation_id{% templatetag closevariable %}/{% templatetag openvariable %}project_id{% templatetag closevariable %}/",
            creator_name : "teacher",
            allow_empty_markers: true,
            play_on_submit: true,
            custom_send_button: "Sauver",
            filter_per_user: false,
        },{
            type: "Markers",
            background: "#ffffff",
            annotation_type: "markers_",
            container: "markers_lower_container",
            line_height: 50,
            project_id: "{{project_id}}",
            allow_empty_markers: true,
            custom_send_button: "Sauver",
            filter_per_user: true,
            preview_mode: true,
            api_users_endpoint: "{% url 'api_dispatch_list' resource_name='users' api_name='1.0' %}?username__in={% templatetag openvariable %}usernames_list_string{% templatetag closevariable %}&limit={% templatetag openvariable %}usernames_list_length{% templatetag closevariable %}",
            make_name_string_function: function(params){
                display_string = params.username;
                if (params.first_name && params.last_name){
                    display_string = params.first_name+" "+params.last_name.charAt(0)+"."
                }
                return display_string;
            },
        }
      ]
    }
    
    _myPlayer = new IriSP.Metadataplayer(_config);
  
  </script>
</div>
</body>
</html>