override default platform templates to better serve html5 videos
authorymh <ymh.work@gmail.com>
Thu, 16 Jul 2015 02:38:01 +0200
changeset 17 18ba1a921633
parent 16 ad85999dd05c
child 18 909900f3c8fd
override default platform templates to better serve html5 videos
server/src/remieplt/templates/ldt/ldt_utils/embed/v2/iframe.html
server/src/remieplt/templates/ldt/ldt_utils/partial/embed_player.html
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/server/src/remieplt/templates/ldt/ldt_utils/embed/v2/iframe.html	Thu Jul 16 02:38:01 2015 +0200
@@ -0,0 +1,191 @@
+{% extends "ldt/ldt_utils/embed/iframe_base.html" %}
+{% load i18n %}
+{% load thumbnail %}
+{% load static %}
+{% load absurl %}
+{% load analytics %}
+{% block mdplayer_config %}
+    var _config = {
+        width: '{{ player_width }}',
+        container: '{{ player_id }}_embed',
+        css: '{% static "ldt/metadataplayer/LdtPlayer-core.css" %}',
+        default_options: {
+            metadata: _metadata
+        },
+        widgets: [
+            {
+                type: "AutoPlayer",
+                {% if external_url %}
+                        video: "{{ external_url }}",
+                {% else %}
+                        streamer: function(_url) {
+                            var _matches = _url.match(/^[^\/]+\/\/[^\/]+\/[^\/]+\//);
+                            if (_matches) {
+                                return _matches[0];
+                            } else {
+                                return _url;
+                            }
+                        },
+                {% endif %}
+                height: '{{ player_height }}',
+                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/');
+                },
+                autostart: {% if autostart %} true {% else %} false {% endif %},
+                default_type: 'AdaptivePlayer'
+            }
+          {% if polemic %}
+            ,{
+                type: "Polemic",
+              {% if polemic == 'all' %}
+                annotation_type: false,
+              {% else %}
+                     annotation_type: [
+                     {% for type in polemic_annotation_types %}
+                         {% if type == polemic_annotation_types|last %}
+                             "{{type}}"
+                         {% else %}
+                             "{{type}}",
+                         {% endif %}
+                     {% endfor %}],
+              {% endif %}
+                max_elements: {{ polemic__max_elements }},
+                defaultcolor: "#{{ polemic_defaultColor }}",
+                foundcolor: "#{{ polemic_foundColor }}",
+              {% if polemics_list %}
+                polemics : {{ polemics_list|safe }}
+              {% else %}
+                polemics : [
+                                {
+                                    "name" : "OK",
+                                    "keywords" : [ "++" ],
+                                    "color" : "#{{ polemic_okColor }}"
+                                },
+                                {
+                                    "name" : "KO",
+                                    "keywords" : [ "--" ],
+                                    "color" : "#{{ polemic_koColor }}"
+                                },
+                                {
+                                    "name" : "REF",
+                                    "keywords" : [ "==", "http://" ],
+                                    "color" : "#{{ polemic_refColor }}"  
+                                },
+                                {
+                                    "name" : "Q",
+                                    "keywords" : [ "?" ],
+                                    "color" : "#{{ polemic_qColor }}"
+                                }
+                            ]
+                       {% endif %}
+            }
+        {% endif %}
+        {% if sparkline %}
+            ,{
+                type: "Sparkline",
+                lineColor: "#{{ sparkline_lineColor }}",
+                fillColor: "#{{ sparkline_fillColor }}",
+            }
+        {% endif %}
+            ,{
+                type: "Slider"
+            }
+            
+            {% if annotations_list %},{
+                type: "AnnotationsList",
+                container: "AnnotationsList_ext",
+                ajax_url: "{% absurl 'segment_api_empty' resource_name='segments' api_name='1.0' %}{% templatetag openvariable %}media{% templatetag closevariable %}/{% templatetag openvariable %}begin{% templatetag closevariable %}/{% templatetag openvariable %}end{% templatetag closevariable %}",
+                ajax_granularity : 300000,
+                default_thumbnail : '{% static "ldt/css/imgs/video_sequence.png" %}',
+                show_audio: true,
+                rtmp_streamer: "rtmp://media.iri.centrepompidou.fr/ddc_micro_record/"
+            }{% endif %},{
+                type: "Controller"
+            }
+            {% if segments %},{
+                type: "Segments",
+                annotation_type: [
+                     {% for type in segments_annotation_types %}
+                         {% if type == segments_annotation_types|last %}
+                             "{{type}}"
+                         {% else %}
+                             "{{type}}",
+                         {% endif %}
+                     {% endfor %}]
+            }
+            {% endif %}
+            {% if multisegments %},{
+                type: "MultiSegments"
+            }
+            {% endif %}
+            {% if annotation %},{
+                type: "Annotation",
+                start_minimized: true,
+                site_name : "Lignes de Temps",
+                annotation_type: ["chap","découpage"]
+            }
+            {% endif %}
+            {% if tweet %},{
+                type: "Tweet",
+                hide_timeout: 5000
+            }
+            {% endif %}
+            {% if createannotation %},{
+                type: "CreateAnnotation",
+                api_endpoint_template: "{% absurl 'api_dispatch_list' resource_name='annotations' api_name='1.0' %}",
+                after_send_timeout: 8000,
+                {% if tag_titles or tag_titles == "" %}
+                       tag_titles : tag_titles_array,
+                   {% else %}
+                    tag_titles : false,
+                   {% endif %}
+                show_mic_record: {% if show_mic_record %}true{% else %}false{% endif %},
+                close_after_send: false,
+                slice_annotation_type: {% if createannotation_annotation_types %}
+                    [{% for type in createannotation_annotation_types %}
+                         {% if forloop.last %} "{{type}}"
+                         {% else %} "{{type}}",
+                         {% endif %}
+                     {% endfor %}]
+                   {% else %}
+                   ["chap","découpage"]
+                   {% endif %},
+                creator_name: '{{request.user.username}}',
+                creator_avatar: '{% thumbnail request.user.image "48x48" format="PNG" crop="center" as im %}{{ im.url }}{% endthumbnail %}' || "https://si0.twimg.com/sticky/default_profile_images/default_profile_1_normal.png",
+                {% if not createannotation_polemics %}polemics: []{% endif %}
+            }{% endif %}
+            {% if slideshare %},{
+                type: "Slideshare",
+                container: "Slideshare_ext",
+                embed_width: 400,
+                embed_height: 334,
+                annotation_type: "slide"
+            }
+            {% endif %},{
+                type: "Mediafragment"
+            }
+            {% if social %},{
+                type: "Social",
+                container: "Social_ext",
+                show_url: {% if show_url %}true{% else %}false{% endif %},
+                show_twitter: {% if show_twitter %}true{% else %}false{% endif %},
+                show_fb: {% if show_fb %}true{% else %}false{% endif %},
+                show_gplus: {% if show_gplus %}true{% else %}false{% endif %},
+                show_mail: {% if show_mail %}true{% else %}false{% endif %},
+                url: document.location.href.replace(/#.*$/,""),
+                text: document.title
+            }
+           {% endif %}
+           
+           {% if tagcloud %},{
+                type: "Tagcloud"
+            }
+           {% endif %}
+        ]
+    };
+{% endblock mdplayer_config %}
+{% analytics %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/server/src/remieplt/templates/ldt/ldt_utils/partial/embed_player.html	Thu Jul 16 02:38:01 2015 +0200
@@ -0,0 +1,126 @@
+{% spaceless %}
+{% load i18n %}
+{% load absurl %}
+{% load static %}
+{% load thumbnail %}
+<div>
+<div id="{{ player_id }}_embed" class="iri_player_embed">
+</div>
+<script type="text/javascript" src='{% static "ldt/metadataplayer/LdtPlayer-core.js" %}'></script>
+<script type="text/javascript">
+
+if (typeof jQuery == "undefined") {
+	jQuery = IriSP.jQuery;
+}
+var metadatas = {metadata: {url: '{{json_url}}{% if "?" in json_url %}&{% else %}?{% endif %}onecontent=1' }};
+var metadata_key = "metadata";
+
+IriSP.libFiles.defaultDir = '{% static "ldt/js/" %}';
+IriSP.libFiles.locations.jwPlayerSWF = '{% static "ldt/swf/player.swf" %}';
+IriSP.libFiles.locations.recordMicSwf = '{% static "ldt/swf/record_mic.swf" %}';
+IriSP.libFiles.locations.zeroClipboardSwf = '{% static "ldt/swf/ZeroClipboard10.swf" %}';
+IriSP.libFiles.locations.cssjQueryUI = '{% static "ldt/css/jq-css/themes/base/jquery-ui.css" %}';
+IriSP.language = '{{LANGUAGE_CODE}}';
+
+IriSP.widgetsDir = '{% static "ldt/metadataplayer" %}';
+var _metadata = {
+    url: metadatas[metadata_key].url,
+    format: 'ldt'
+};
+var _config = {
+    width: '{{ player_width }}',
+    container: '{{ player_id }}_embed',
+    css: '{% static "ldt/metadataplayer/LdtPlayer-core.css" %}',
+    default_options: {
+        metadata: _metadata
+    },
+    widgets: [
+        {
+            type: "AutoPlayer",
+            default_type: 'AdaptivePlayer',
+    {% if external_url %}
+            video: "{{ external_url }}",
+    {% endif %}
+            height: {% if player_height %}{{ player_height }}{% else %}300{% endif %},
+            autostart: true,
+            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/');
+            }
+        },
+        {
+            type: "Polemic"
+    {% if polemic == 'all' %}
+            ,annotation_type: false
+    {% endif %}
+        },
+    {% if polemic != 'all' %}
+        {
+            type: "Sparkline"
+        },
+    {% endif %}
+        {
+            type: "Slider"
+        },{
+            type: "AnnotationsList",
+            container: "AnnotationsList_ext",
+            ajax_url: "{% absurl 'segment_api_empty' resource_name='segments' api_name='1.0' %}{% templatetag openvariable %}media{% templatetag closevariable %}/{% templatetag openvariable %}begin{% templatetag closevariable %}/{% templatetag openvariable %}end{% templatetag closevariable %}",
+            ajax_granularity : 300000,
+            default_thumbnail : '{% static "ldt/css/imgs/video_sequence.png" %}',
+            show_audio: true,
+            audio_url_transform: function(url) {
+                return url.replace("ddc_micro_record/","ddc_micro_record/flv:");
+            }
+        },{
+            type: "Controller"
+        },{
+            type: "MultiSegments"
+            {% if toggle_multisegments %},
+            visible_by_default: false
+            {% endif %}
+        },{
+            type: "Tweet",
+            hide_timeout: 5000
+        }{% if not toggle_multisegments %},{
+            type: "CreateAnnotation",
+            api_endpoint_template: "{% absurl 'api_dispatch_list' resource_name='annotations' api_name='1.0' %}",
+            after_send_timeout: 8000,
+            show_mic_record: {% if show_mic_record %}true{% else %}false{% endif %},
+            close_after_send: false,
+            slice_annotation_type: ["chap","découpage"],
+            creator_name: '{{request.user.username}}',
+            creator_avatar: '{% thumbnail request.user.image "48x48" format="PNG" crop="center" as im %}{{ im.url }}{% endthumbnail %}' || "https://si0.twimg.com/sticky/default_profile_images/default_profile_1_normal.png"
+        }{% endif %},{
+            type: "Slideshare",
+            container: "Slideshare_ext",
+            embed_width: 400,
+            embed_height: 334,
+            annotation_type: "slide"
+        },{
+            type: "Mediafragment"
+        },{
+            type: "Social",
+            container: "Social_ext",
+            url: document.location.href.replace(/#.*$/,""),
+            text: document.title
+        }
+        {% if toggle_multisegments %},{
+            type: "Tagcloud",
+            container: "TagcloudContainer",
+            include_titles: false,
+            include_descriptions: false,
+            min_count: 0,
+            tag_count: 100,
+            remove_zero_duration: {% if remove_zero_duration %}true{% else %}false{% endif %}
+        }
+        {% endif %}
+    ]
+};
+
+_myPlayer = new IriSP.Metadataplayer(_config);
+</script>
+</div>
+{% endspaceless %}