From 886103c1596df58950e7a603fbed364b832d5ecc Mon Sep 17 00:00:00 2001 From: riccardo Date: Wed, 6 Apr 2011 17:33:06 +0200 Subject: [PATCH] fixed play at position >0 when sound is not loaded (now load sound and play), removed mediaitem.html and restored the old mediaitem_detail as base class for mediaitem_edit, mediaitem_copy etc... --- telemeta/htdocs/timeside/src/player.js | 39 ++- telemeta/htdocs/timeside/src/ruler.js | 3 +- telemeta/templates/telemeta/mediaitem.html | 1 - .../telemeta_default/collection_add.html | 1 + .../telemeta_default/collection_edit.html | 7 +- .../templates/telemeta_default/mediaitem.html | 295 ------------------ .../telemeta_default/mediaitem_copy.html | 2 +- .../telemeta_default/mediaitem_detail.html | 290 ++++++++++++++++- .../telemeta_default/mediaitem_detail_dc.html | 2 +- .../telemeta_default/mediaitem_edit.html | 6 +- 10 files changed, 328 insertions(+), 318 deletions(-) delete mode 100644 telemeta/templates/telemeta/mediaitem.html delete mode 100644 telemeta/templates/telemeta_default/mediaitem.html diff --git a/telemeta/htdocs/timeside/src/player.js b/telemeta/htdocs/timeside/src/player.js index cc254a12..f9719c5c 100644 --- a/telemeta/htdocs/timeside/src/player.js +++ b/telemeta/htdocs/timeside/src/player.js @@ -38,7 +38,6 @@ TimeSide(function($N, $J) { container: null, imageWidth: null, imageHeight: null, - soundPosition: 0, initialize: function($super, container, cfg) { $super(); @@ -174,13 +173,13 @@ TimeSide(function($N, $J) { this.refreshImage(); this.resize(); -// var resizeTimer = null; -// $J(window).resize(this.attach(function() { -// if (resizeTimer){ -// clearTimeout(resizeTimer); -// } -// resizeTimer = setTimeout(this.attach(this.resize), 100); -// })); + // var resizeTimer = null; + // $J(window).resize(this.attach(function() { + // if (resizeTimer){ + // clearTimeout(resizeTimer); + // } + // resizeTimer = setTimeout(this.attach(this.resize), 100); + // })); this.setSoundVolume(this.getSoundVolume()); //finally, binds events to play and pause. At the end cause this.ruler has to be fully initialized @@ -190,15 +189,29 @@ TimeSide(function($N, $J) { return false; }); //var r = this.ruler; + var player = this; + var playOptions = { + whileplaying: function(){ + ruler._movePointer(this.position/1000); //this will refer to the sound object + } + }; this.elements.play.attr('href', '#').bind('click', function(){ + consolelog('playstate'+sound.playState); + consolelog('readystate'+sound.readyState); if(sound.playState!=1 || sound.paused){ - sound.play({ - whileplaying: function(){ - ruler._movePointer(this.position/1000); - //consolelog(this.ruler); + //if sound has to be loaded and position is not zero, load it first + if(sound.readyState==0 && player.getSoundPosition()){ + sound.options.onload=function(){ + this.setPosition(player.getSoundPosition()*1000); + //consolelog('loaded and played from '+player.getSoundPosition() +' '+this.position); + sound.play(playOptions); } - }); + sound.load(); + }else{ + //consolelog('NOT loaded and played'); + sound.play(playOptions); + } } return false; }); diff --git a/telemeta/htdocs/timeside/src/ruler.js b/telemeta/htdocs/timeside/src/ruler.js index f6891a12..bb89e287 100644 --- a/telemeta/htdocs/timeside/src/ruler.js +++ b/telemeta/htdocs/timeside/src/ruler.js @@ -393,10 +393,11 @@ TimeSide(function($N, $J) { this.pointer.setText($N.Util.makeTimeLabel(offset)); } this.pointerPos = offset; + this.debug('_movePointer: position set to'+offset); }, //called by everything else than playing, same as _movePointer but updates also the sound position accordingly _movePointerAndUpdateSoundPosition: function(offset) { - this._movePointer(offset) + this._movePointer(offset); this.cfg.sound.setPosition(parseInt(1000*this.pointerPos)); }, diff --git a/telemeta/templates/telemeta/mediaitem.html b/telemeta/templates/telemeta/mediaitem.html deleted file mode 100644 index 7665a03f..00000000 --- a/telemeta/templates/telemeta/mediaitem.html +++ /dev/null @@ -1 +0,0 @@ -{% extends "telemeta_default/mediaitem.html" %} diff --git a/telemeta/templates/telemeta_default/collection_add.html b/telemeta/templates/telemeta_default/collection_add.html index c1d53e4e..800d748d 100644 --- a/telemeta/templates/telemeta_default/collection_add.html +++ b/telemeta/templates/telemeta_default/collection_add.html @@ -2,6 +2,7 @@ {% load i18n %} {% load telemeta_utils %} + {% block title_buttons %} {% trans "Cancel" %} {% endblock %} diff --git a/telemeta/templates/telemeta_default/collection_edit.html b/telemeta/templates/telemeta_default/collection_edit.html index 75f13113..eaf4aa45 100644 --- a/telemeta/templates/telemeta_default/collection_edit.html +++ b/telemeta/templates/telemeta_default/collection_edit.html @@ -2,7 +2,12 @@ {% load i18n %} {% load telemeta_utils %} -{% trans "Cancel" %} +{% block title %} + Collection: {{ collection }} +{% endblock %} +{% block title_buttons %} + {% trans "Cancel" %} +{% endblock %} {% block infos %}
diff --git a/telemeta/templates/telemeta_default/mediaitem.html b/telemeta/templates/telemeta_default/mediaitem.html deleted file mode 100644 index a13faeb9..00000000 --- a/telemeta/templates/telemeta_default/mediaitem.html +++ /dev/null @@ -1,295 +0,0 @@ -{% extends "telemeta/base.html" %} -{% load telemeta_utils %} -{% load i18n %} - -{% block head_title %}{% trans "Item" %}- {{ block.super }}{% endblock %} - -{% block stylesheets %} -{{ block.super }} - - - - {% endblock %} - - {% block extra_javascript %} - - - - - - -{% endblock %} - - -{% if item %} - -{% block title %} -{% endblock %} -{% block title_buttons %} -{% endblock %} - -{% block content %} - - -
- {% if item.file %} - {% if public_access or user.is_staff %} -
- Minimize -
-
-
-
- Maximize -
-
-
-
-
- - -
-
-
-
-
-
-
-  Visualization : - - -
- - -
- -
- -   - Loading... - - -
- -
- -
- - - - - - - -
{% trans "Property" %}{% trans "Value" %}{% trans "Unit" %}
-
- - - {% if audio_export_enabled %} -
-

{% trans "Download:" %} - {% for format in export_formats %} - - {{ format.extension }} - {% endfor %}

-
- {% endif %} - -
- {% endif %} - {% endif %} - - {% block infos %} -
- {% block general_info %} -
- {% dl_field item "title" %} - {% dl_field item "alt_title" %} - {% dl_field item "collector" %} -
{% field_label item "collection" %}
-
{{ item.collection }}
- {% if item.recorded_from_date %} -
{% trans "Recording date" %}
-
{{ item.recorded_from_date }} {{ item.recorded_to_date|prepend:" - " }}
- {% endif %} -
- {% endblock general_info %} -
-
- {% block geoethnic_data %} -
-

{% trans "Geographic and cultural informations" %}

-
- {% if item.location %} -
{% trans "Location" %}
-
{{ item.location.fullnames|join:"
" }}
- {% endif %} - {% dl_field item "location_comment" %} - {% dl_field item "cultural_area" %} - {% dl_field item "ethnic_group" %} - {% dl_field item "context_comment" %} - {% dl_field item "keywords" join with ", " %} -
-
- {% endblock geoethnic_data %} -
-
- {% block musical_data %} -
-

{% trans "Musical informations" %}

-
- {% dl_field item "vernacular_style" %} - {% dl_field item "generic_style" %} - {% dl_field item "author" %} -
- {% if item.performances %} -
- - - - - - - - - - - {% for performance in item.performances.all %} - - - - - - - {% endfor %} - -
{% field_label "MediaItemPerformance" "instruments_num" %}{% field_label "MediaItemPerformance" "instrument" %}{% field_label "MediaItemPerformance" "alias" %}{% field_label "MediaItemPerformance" "musicians" %}
{{ performance.instruments_num }}{{ performance.instrument|default:"" }}{{ performance.alias|default:"" }}{{ performance.musicians }}
-
- {% endif %} -
- {% endblock musical_data %} -
-
- {% block general_data %} -
-

{% trans "General informations" %}

-
- {% dl_field item "comment" %} - {% dl_field item "collector_selection" %} -
-
- {% endblock general_data %} -
-
- {% block archive_data %} -
-

{% trans "Archiving data" %}

-
- {% dl_field item "code" %} - {% dl_field item "old_code" %} - {% dl_field item "track" %} - {% dl_field item "creator_reference" %} - {% dl_field item "external_references" %} - {% dl_field item "public_access_label" %} -
-
- {% endblock archive_data %} -
-
- {% block technical_data %} -
-

{% trans "Technical data" %}

-
-
-
{% trans "Media type" %}
{% trans "Audio" %}
- {% dl_field item "approx_duration" %} -
-
-
- {% endblock technical_data %} -
- {% endblock infos %} -
-{% endblock %} -{% else %} -

No such item

-{% endif %} diff --git a/telemeta/templates/telemeta_default/mediaitem_copy.html b/telemeta/templates/telemeta_default/mediaitem_copy.html index ed03bef3..b56ade84 100644 --- a/telemeta/templates/telemeta_default/mediaitem_copy.html +++ b/telemeta/templates/telemeta_default/mediaitem_copy.html @@ -1,4 +1,4 @@ -{% extends "telemeta/mediaitem.html" %} +{% extends "telemeta/mediaitem_detail.html" %} {% load telemeta_utils %} {% load i18n %} diff --git a/telemeta/templates/telemeta_default/mediaitem_detail.html b/telemeta/templates/telemeta_default/mediaitem_detail.html index bd2cf46a..feef1abf 100644 --- a/telemeta/templates/telemeta_default/mediaitem_detail.html +++ b/telemeta/templates/telemeta_default/mediaitem_detail.html @@ -1,13 +1,83 @@ -{% extends "telemeta/mediaitem.html" %} +{% extends "telemeta/base.html" %} {% load telemeta_utils %} {% load i18n %} +{% block head_title %}{% trans "Item" %}- {{ block.super }}{% endblock %} + +{% block stylesheets %} +{{ block.super }} + + + + {% endblock %} + + {% block extra_javascript %} + + + + + + +{% endblock %} + + +{% if item %} {% block title %} Item : {{ item }} {% endblock %} {% block title_buttons %} -
+
{% if user.is_authenticated and perms.telemeta.change_mediaitem %} {% trans "Edit" %} {% trans "Copy" %} @@ -20,3 +90,219 @@ Dublin Core
{% endblock %} + +{% block content %} + + +
+ {% if item.file %} + {% if public_access or user.is_staff %} +
+ Minimize +
+
+
+
+ Maximize +
+
+
+
+
+ + +
+
+
+
+
+
+
+  Visualization : + + +
+ + +
+ +
+ +   + Loading... + + +
+ +
+ +
+ + + + + + + +
{% trans "Property" %}{% trans "Value" %}{% trans "Unit" %}
+
+ + + {% if audio_export_enabled %} +
+

{% trans "Download:" %} + {% for format in export_formats %} + + {{ format.extension }} + {% endfor %}

+
+ {% endif %} + +
+ {% endif %} + {% endif %} + + {% block infos %} +
+ {% block general_info %} +
+ {% dl_field item "title" %} + {% dl_field item "alt_title" %} + {% dl_field item "collector" %} +
{% field_label item "collection" %}
+
{{ item.collection }}
+ {% if item.recorded_from_date %} +
{% trans "Recording date" %}
+
{{ item.recorded_from_date }} {{ item.recorded_to_date|prepend:" - " }}
+ {% endif %} +
+ {% endblock general_info %} +
+
+ {% block geoethnic_data %} +
+

{% trans "Geographic and cultural informations" %}

+
+ {% if item.location %} +
{% trans "Location" %}
+
{{ item.location.fullnames|join:"
" }}
+ {% endif %} + {% dl_field item "location_comment" %} + {% dl_field item "cultural_area" %} + {% dl_field item "ethnic_group" %} + {% dl_field item "context_comment" %} + {% dl_field item "keywords" join with ", " %} +
+
+ {% endblock geoethnic_data %} +
+
+ {% block musical_data %} +
+

{% trans "Musical informations" %}

+
+ {% dl_field item "vernacular_style" %} + {% dl_field item "generic_style" %} + {% dl_field item "author" %} +
+ {% if item.performances %} +
+ + + + + + + + + + + {% for performance in item.performances.all %} + + + + + + + {% endfor %} + +
{% field_label "MediaItemPerformance" "instruments_num" %}{% field_label "MediaItemPerformance" "instrument" %}{% field_label "MediaItemPerformance" "alias" %}{% field_label "MediaItemPerformance" "musicians" %}
{{ performance.instruments_num }}{{ performance.instrument|default:"" }}{{ performance.alias|default:"" }}{{ performance.musicians }}
+
+ {% endif %} +
+ {% endblock musical_data %} +
+
+ {% block general_data %} +
+

{% trans "General informations" %}

+
+ {% dl_field item "comment" %} + {% dl_field item "collector_selection" %} +
+
+ {% endblock general_data %} +
+
+ {% block archive_data %} +
+

{% trans "Archiving data" %}

+
+ {% dl_field item "code" %} + {% dl_field item "old_code" %} + {% dl_field item "track" %} + {% dl_field item "creator_reference" %} + {% dl_field item "external_references" %} + {% dl_field item "public_access_label" %} +
+
+ {% endblock archive_data %} +
+
+ {% block technical_data %} +
+

{% trans "Technical data" %}

+
+
+
{% trans "Media type" %}
{% trans "Audio" %}
+ {% dl_field item "approx_duration" %} +
+
+
+ {% endblock technical_data %} +
+ {% endblock infos %} +
+{% endblock %} +{% else %} +

No such item

+{% endif %} diff --git a/telemeta/templates/telemeta_default/mediaitem_detail_dc.html b/telemeta/templates/telemeta_default/mediaitem_detail_dc.html index 06166632..59f6bb71 100644 --- a/telemeta/templates/telemeta_default/mediaitem_detail_dc.html +++ b/telemeta/templates/telemeta_default/mediaitem_detail_dc.html @@ -1,4 +1,4 @@ -{% extends "telemeta/mediaitem.html" %} +{% extends "telemeta/mediaitem_detail.html" %} {% load telemeta_utils %} {% load i18n %} diff --git a/telemeta/templates/telemeta_default/mediaitem_edit.html b/telemeta/templates/telemeta_default/mediaitem_edit.html index 0a3061b9..e2a68087 100644 --- a/telemeta/templates/telemeta_default/mediaitem_edit.html +++ b/telemeta/templates/telemeta_default/mediaitem_edit.html @@ -1,9 +1,9 @@ -{% extends "telemeta/mediaitem.html" %} +{% extends "telemeta/mediaitem_detail.html" %} {% load i18n %} {% load telemeta_utils %} -{% block title %} - + {% block title %} + Item : {{ item }} {% endblock %} {% block title_buttons %} {% trans "Cancel" %} -- 2.39.5