]> git.parisson.com Git - telemeta.git/commitdiff
* add video.js for video player tool
authoryomguy <yomguy@parisson.com>
Fri, 3 Feb 2012 17:42:15 +0000 (18:42 +0100)
committeryomguy <yomguy@parisson.com>
Fri, 3 Feb 2012 17:42:15 +0000 (18:42 +0100)
* fix duration (get decoder's one)
* fix webm in mapping

telemeta/htdocs/images/webm.png [new file with mode: 0644]
telemeta/models/media.py
telemeta/templates/telemeta/base.html
telemeta/templates/telemeta/mediaitem_detail.html
telemeta/views/base.py

diff --git a/telemeta/htdocs/images/webm.png b/telemeta/htdocs/images/webm.png
new file mode 100644 (file)
index 0000000..c9be86f
Binary files /dev/null and b/telemeta/htdocs/images/webm.png differ
index 65cd01c73cb807abdb5e88c1ea45af6841d74b1e..824eb23cc211e925a2752238f59f8a184f8a83ac 100644 (file)
@@ -566,7 +566,7 @@ class DublinCoreToFormatMetadata(object):
     in various audio metadata format (MP3, OGG, etc...)"""
 
     #FIXME: should be given by timeside
-    unavailable_extensions = ['wav', 'aiff', 'aif', 'flac']
+    unavailable_extensions = ['wav', 'aiff', 'aif', 'flac', 'webm']
 
     metadata_mapping = {
                     'mp3' : {
index e1d278d432f52e4f1afef22d8b4f0c199d9a2c5f..39227d0ba09e1727b30a1e041853024769c69d04 100644 (file)
 
 {# spaces between li and a elements breaks layout #}
 
-<!--<ul id="nav">
- <a href="{% url telemeta-home %}" class="darkblue">{% trans "Home" %}</a>
- <a href="{% url telemeta-collections %}" class="blue">{% trans "Collections" %}</a>
- <a href="{% url telemeta-items %}" class="green">{% trans "Items" %}</a></li>
- <a href="{% url telemeta-geo-continents %}" class="yellow">{% trans "Geo Navigator" %}</a>
- <a href="{% url telemeta-search-criteria %}" class="orange">{% trans "Advanced search" %}</a>
- {% if user.is_authenticated %}
- <a href="{% url telemeta-users %}" class="red">{% trans "Users" %}</a>
- {% endif %}
- {% if user.is_staff %}
- <a href="{% url telemeta-admin %}" class="violet">{% trans "Admin" %}</a>
-{% endif %}
-</ul>-->
-
 <ul id="nav">
  {% if user.is_authenticated %}
   <li><a href="#desk#" class="blue">{% trans "Desk" %}</a></span>
index 9cd33f6790d37ba93ea90fd2bdf5cbf64de8ee1d..308751e913af9a7cc6a1d2f9567f5bfb9335870c 100644 (file)
             });
     {% endif %}
 </script>
+
+{% if "video" in mime_type %}
+<link href="http://vjs.zencdn.net/c/video-js.css" rel="stylesheet">
+<script src="http://vjs.zencdn.net/c/video.js"></script>
+{% endif %}
+
 {% endif %}
 {% endblock %}
 
@@ -122,10 +128,21 @@ Item : <a href="{% url telemeta-item-detail item.public_id %}">{{ item }}</a>
 
     {% if "video" in mime_type %}
     <div>
-        <video width="362" controls="controls" preload="auto">
+    <video id="my_video_1" class="video-js vjs-default-skin" width="362" height="240" controls preload="auto" data-setup="{}">
+        <!-- Hello Chrome and Firefox (and Opera?) -->
         <source src="{% url telemeta-item-export item.public_id mime_type|mime_to_ext %}" type="{{ mime_type }}" />
         </video>
+        <div id="videotime"></div>
     </div>
+    <script>
+    (function(){
+        var v = document.getElementsByTagName('video')[0]
+        var t = document.getElementById('videotime');
+        v.addEventListener('timeupdate',function(event){
+            t.innerHTML = v.currentTime;
+            },false);
+            })();
+    </script>
     {% endif %}
 
         <!-- </div> -->
index 5d8cc67e9cfba22ed4de12b905608069fba90009..2243bb58b7b18a8edec4b96bfc79e394f0024d59 100644 (file)
@@ -590,7 +590,6 @@ class ItemView(object):
 
         previous, next = self.item_previous_next(item)
         mime_type = self.item_analyze(item)
-        print mime_type
         playlists = get_playlists(request)
         public_access = get_public_access(item.public_access, str(item.recorded_from_date).split('-')[0],
                                                 str(item.recorded_to_date).split('-')[0])
@@ -759,7 +758,7 @@ class ItemView(object):
                     time = value.split(':')
                     time[2] = time[2].split('.')[0]
                     time = ':'.join(time)
-                    item.approx_duration = str(time)
+                    item.approx_duration = time
                     item.save()
                 if analysis.analyzer_id == 'mime_type':
                     mime_type = analysis.value
@@ -791,23 +790,21 @@ class ItemView(object):
                                              analyzer_id='resolution', unit='bits',
                                              value=unicode(decoder.audiowidth))
                 analysis.save()
+                analysis = MediaItemAnalysis(item=item, name='Duration',
+                                             analyzer_id='duration', unit='s',
+                                             value=unicode(datetime.timedelta(0,decoder.duration)))
+                analysis.save()
 
                 for analyzer in analyzers_sub:
                     value = analyzer.result()
-                    if analyzer.id() == 'duration':
-                        approx_value = int(round(value))
-                        item.approx_duration = approx_value
-                        try:
-                            item.save()
-                        except:
-                            pass
-                        value = datetime.timedelta(0,value)
-
                     analysis = MediaItemAnalysis(item=item, name=analyzer.name(),
                                                  analyzer_id=analyzer.id(),
                                                  unit=analyzer.unit(), value=str(value))
                     analysis.save()
 
+                #FIXME: parse tags on first load
+#                tags = decoder.tags
+
         return mime_type
 
     def item_analyze_xml(self, request, public_id):
@@ -893,14 +890,7 @@ class ItemView(object):
         else:
             flag = flag[0]
 
-        mime_type = self.item_analyze(item)
-        if mime_type:
-            format = mime_type
-
-        else:
-            decoder = timeside.decoder.FileDecoder(audio)
-            format = decoder.format()
-
+        format = self.item_analyze(item)
         dc_metadata = dublincore.express_item(item).to_list()
         mapping = DublinCoreToFormatMetadata(extension)
         metadata = mapping.get_metadata(dc_metadata)