From: riccardo Date: Thu, 12 May 2011 17:25:55 +0000 (+0200) Subject: Renamed playerUtils in playerLoader + cleanup of playerLoader and other minor fixes:wq X-Git-Tag: 1.1~196 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=eef661f4896d4bdf1f465c5a5d3cbe91de55f541;p=telemeta.git Renamed playerUtils in playerLoader + cleanup of playerLoader and other minor fixes:wq --- diff --git a/telemeta/htdocs/js/application.js b/telemeta/htdocs/js/application.js index 737a1b59..b2496107 100644 --- a/telemeta/htdocs/js/application.js +++ b/telemeta/htdocs/js/application.js @@ -306,6 +306,8 @@ function loadScripts(){ } } + + function consolelog(text){ if(typeof console != 'undefined'){ var c = console; @@ -357,7 +359,7 @@ function PopupDiv(){ //setting instance-specific properties: for(k in data){ - if(k == 'ok' || k == 'blur' || k == 'close'){ + if(k == 'onOk' || k == 'onShow' || k == 'onClose'){ this.bind(k,data[k]); }else if(k == 'content'){ this.setContent(data[k]); @@ -429,7 +431,7 @@ function PopupDiv(){ p.fadeOutTime = 0, p.shadowOpacity = 0.25; p.zIndex = 10000; - // p.listItemClass = ''; + // p.listItemClass = ''; p.getFormData = function(){ var elms = this.find('input,select,textarea'); @@ -445,8 +447,10 @@ function PopupDiv(){ }; p.closeLater = function(millseconds){ - var me = this; - setTimeout(function(){ me.close();},millseconds); + var me = this; + setTimeout(function(){ + me.close(); + },millseconds); }, //methods: @@ -520,7 +524,7 @@ function PopupDiv(){ //var name = this.getListItemName(); var input = $('').attr('type','hidden').attr('name','selIndex'); var setEvents = function(idx,anchor,input){ - anchor.click(function(){ + anchor.click(function(){ input.val(idx); me.trigger('ok',true); return false; @@ -546,7 +550,10 @@ function PopupDiv(){ if('css' in item){ a.css(item['css']); } - a.css({'display':'block','margin':'2px'}); //margin is used to display the outline (focus) + a.css({ + 'display':'block', + 'margin':'2px' + }); //margin is used to display the outline (focus) setEvents(h,a,input); container.append(a); } @@ -668,9 +675,9 @@ function PopupDiv(){ } return; } - if(invokerIsClickable){ - this.invoker.attr('tabindex',0).attr(focusAttr,'true'); - } + if(invokerIsClickable){ + this.invoker.attr('tabindex',0).attr(focusAttr,'true'); + } var doc_ = d_; //closure (see nested function below) //now all elements (including header and footer) @@ -732,13 +739,13 @@ function PopupDiv(){ } //if we have elements of type listitem, add the specified class -// var name = this.getListItemName(); -// var elms = this.find('a[name='+name+']'); -// if(this.listItemClass){ -// elms.removeClass().addClass(this.listItemClass); -// this.listItemClass = ""; -// } -// elms.css('display','block'); + // var name = this.getListItemName(); + // var elms = this.find('a[name='+name+']'); + // if(this.listItemClass){ + // elms.removeClass().addClass(this.listItemClass); + // this.listItemClass = ""; + // } + // elms.css('display','block'); this.setFocusCycleRoot(this.focusable); @@ -830,28 +837,28 @@ function PopupDiv(){ this['_tmpHandlers'+this.getId()] = undefined; var focusElm = this.getFirstFocusableElement(); if(focusElm){ - var oldHandlers = []; - var type = 'click'; - var clickEvents =invoker.data("events")[type]; - $.each(clickEvents, function(key, value) { - oldHandlers.push(value); - }) - invoker.unbind(type); //remove (temporarily) the binding to the event. - //for instance, if we show the popup by clicking invoker, when the popup is shown do nothing - //on clicking invoker until popup.hide is called - - this['_tmpHandlers'+this.getId()] = oldHandlers; - invoker.unbind(type).bind(type,function(evt){ - //let the invoker have focus and let it be recognized as an element which does not blur the popup: - //invoker.attr('tabindex',0).attr(focusAttr,'true'); - if(div.length && div.is(':visible')){ - focusElm.focus(); + var oldHandlers = []; + var type = 'click'; + var clickEvents =invoker.data("events")[type]; + $.each(clickEvents, function(key, value) { + oldHandlers.push(value); + }) + invoker.unbind(type); //remove (temporarily) the binding to the event. + //for instance, if we show the popup by clicking invoker, when the popup is shown do nothing + //on clicking invoker until popup.hide is called + + this['_tmpHandlers'+this.getId()] = oldHandlers; + invoker.unbind(type).bind(type,function(evt){ + //let the invoker have focus and let it be recognized as an element which does not blur the popup: + //invoker.attr('tabindex',0).attr(focusAttr,'true'); + if(div.length && div.is(':visible')){ + focusElm.focus(); + return false; + } + //something wrong: close the popup and restore the hanlers + me.close.apply(me); return false; - } - //something wrong: close the popup and restore the hanlers - me.close.apply(me); - return false; - }); + }); } }else{ @@ -951,9 +958,9 @@ function PopupDiv(){ var placeAbove = spaceAbove > spaceBelow && div.outerHeight(true) > spaceBelow; //note that div.outerHeight() should be == div.outerHeight(true), as we set margins =0 -// alert(div.outerHeight(true)+' '+spaceAbove+' '+spaceBelow); -// div.css('visibility',''); -// return; + // alert(div.outerHeight(true)+' '+spaceAbove+' '+spaceBelow); + // div.css('visibility',''); + // return; this.setMaxSize({ height : (placeAbove ? spaceAbove : spaceBelow) diff --git a/telemeta/htdocs/js/playerLoader.js b/telemeta/htdocs/js/playerLoader.js new file mode 100644 index 00000000..346393f7 --- /dev/null +++ b/telemeta/htdocs/js/playerLoader.js @@ -0,0 +1,242 @@ +/** + * TimeSide - Web Audio Components + * Copyright (c) 2011 Parisson + * Author: Riccardo Zaccarelli and Olivier Guilyardi + * License: GNU General Public License version 2.0 + */ + +/** + * Class for loading a player. Requires a div#player, jQuery and all timeside javascript (player.js, markermap.js etcetera) + */ + +var player; //global player variable + +function togglePlayerMaximization() { + consolelog('entered togglePlayerMaximization'); + var view = $('#player'); + $('#player_maximized, #player_minimized').css('display', 'none'); + var ctr; + var dynamicResize = false; + if (view.parents('#player_maximized').length) { + ctr = $('#player_minimized').append(view); + } else { + ctr = $('#player_maximized').append(view); + dynamicResize = true; + } + ctr.css({ + opacity: 0, + display: 'block' + }); + var p = player; + if (p){ + p.resize(); + } + ctr.animate({ + opacity: 1 + }, 100); + if (p){ + p.setDynamicResize(dynamicResize); + } +} + + + +function loadPlayer(analizerUrl, soundUrl, itemId, visualizers, currentUserName){ + var $J = jQuery; + var playerDiv = $J('#player'); + if (!playerDiv.length){ + //playerError('div #player does not exists'); + //DO NOT RAISE ANY ERROR, JUST RETURN + return; + } + + if(!(analizerUrl)){ + playerError('invalid analyzer url'); + return; + } + + if(!(soundUrl)){ + playerError('invalid sound url'); + return; + } + + + //consolelog('till here all ok1'); + var msgElm = $J('#loading_span_text'); //element to show messages + //consolelog('till here all ok2'); + if(msgElm){ + msgElm.html('Loading analyzer...'); + } + + var tableBody = $J('#analyzer_div_id').find('table').find('tbody:last'); + + //function to be executed when the analyzer has fully loaded (ie, a duration is provided) + function load_player(soundUrl, durationInMsec, itemId, visualizers, currentUserName) { + var sound = soundManager.createSound({ + id: 'sound', + autoLoad: false, + url: soundUrl + }); + + loadScripts('/timeside/src/',['rulermarker.js','markermap.js', 'player.js', 'ruler.js','divmarker.js'], function() { + + + var p = new Player(jQuery('#player'), sound, durationInMsec, itemId, visualizers, currentUserName); + consolelog('initialized player'); + p._setupInterface(); + + player = p; + + $J('#player_maximized .toggle, #player_minimized .toggle').click(function() { + togglePlayerMaximization(); + this.blur(); + return false; + }); + }); + }; + + $J.ajax({ + url: analizerUrl, //'analyze/xml', + dataType: 'xml', + success: function(data){ + //populatetable + $J.each($J(data).find('data'),function(index,element){ + var elm = $J(element); + tableBody.append(''+elm.attr('name')+''+elm.attr('value')+'' + +elm.attr('unit')+''); + }); + //loaded analizer, loading player + if(msgElm){ + msgElm.html('Loading player...'); + } + var duration = $J(data).find('#duration').attr('value'); + duration = duration.split(":"); + consolelog('analyzer loaded, duration: '+duration); + //format duration + var pin = parseInt; + var pfl = parseFloat; + var timeInMSecs=pin(duration[0])*3600+pin(duration[1])*60+pfl(duration[2]); + timeInMSecs = Math.round(timeInMSecs*1000); + load_player(soundUrl, timeInMSecs, itemId, visualizers, currentUserName); + }, + error:function(){ + playerError('Error loading analyzer'); + //""); + } + }); +} + + + +//function loadPlayer(analizerUrl, soundUrl, itemId, visualizers, currentUserName){ +// +// if(!(analizerUrl) || !(soundUrl)){ +// return; +// } +// +// var $J = jQuery; +// //consolelog('till here all ok1'); +// var msgElm = $J('#loading_span_text'); //element to show messages +// //consolelog('till here all ok2'); +// if(msgElm){ +// msgElm.html('Loading analyzer...'); +// } +// var url = urlNormalized(); +// var tableBody = $J('#analyzer_div_id').find('table').find('tbody:last'); +// var load_player = this.load_player; +// $J.ajax({ +// url: analizerUrl, //'analyze/xml', +// dataType: 'xml', +// success: function(data){ +// //populatetable +// $J.each($J(data).find('data'),function(index,element){ +// var elm = $J(element); +// tableBody.append(''+elm.attr('name')+''+elm.attr('value')+'' +// +elm.attr('unit')+''); +// }); +// //loaded analizer, loading player +// if(msgElm){ +// msgElm.html('Loading player...'); +// } +// var duration = $J(data).find('#duration').attr('value'); +// duration = duration.split(":"); +// consolelog('analyzer loaded, duration: '+duration); +// //format duration +// var pin = parseInt; +// var pfl = parseFloat; +// var timeInMSecs=pin(duration[0])*3600+pin(duration[1])*60+pfl(duration[2]); +// timeInMSecs = Math.round(timeInMSecs*1000); +// load_player(soundUrl, timeInMSecs, itemId, visualizers, currentUserName); +// }, +// error:function(){ +// playerError('Error loading analyzer'); +// //""); +// } +// }); +//} +// +// +////loads a player WAITING for the sound identified by soundUrl to be FULLY LOADED!!!! +//function load_player(soundUrl, durationInMsecs, itemId, visualizers, currentUserName) { +// consolelog('PlayerLoader.load_player: '+soundUrl+' '+durationInMsecs); +// var load_player2 = this.load_player2; +// +// //this variable can be changed to load a sound immediately or not +// var loadImmediately = true; +// if(durationInMsecs){ +// loadImmediately = false; +// } +// var sound = soundManager.createSound({ +// id: 'sound', +// autoLoad: loadImmediately, +// url: soundUrl, +// onload: function() { //formerly was: whileloading +// //PROBLEM/BUG: on chrome and firefox whileloading is the same as onload, +// //ie it is not called at regular interval but when the whole file has loaded +// if(loadImmediately){ +// consolelog('entering while loading setting up---------------'+this.bytesLoaded+' of '+this.bytesTotal); +// loadImmediately=false; +// load_player2(this, this.duration, itemId, visualizers, currentUserName); +// } +// } +// }); +// if(!loadImmediately){ +// //TODO: remove this code is only temporary here!!!!!!!!!!!!!!!!!!!!1 +// loadScripts('/timeside/src/',['rulermarker.js', //'markerlist.js', +// 'markermap.js', 'player.js', 'ruler.js','divmarker.js'], function(){ +// load_player2(sound,durationInMsecs,itemId, visualizers, currentUserName); +// }); +// } +// +//} +////NOTE: the duration must be present. Loaded from xmlanalyzer (see above) +//function load_player2(sound, durationInMsec, itemId, visualizers, currentUserName) { +// +// if (!$('#player').length){ +// return; +// } +// consolelog("entered load_player2"); +// +// //TODO: what are we doing here???? +//// $('.ts-wave a img').insertAfter('.ts-wave a'); +//// $('.ts-wave a').remove(); +// +// var p = new Player(jQuery('#player'), sound, durationInMsec, itemId, visualizers, currentUserName); +// consolelog('initialized player'); +// p._setupInterface(); +// //p.loadMarkers(); +// +// player = p; +// +//// var change_visualizer_click = change_visualizer_clicked; +//// $('#visualizer_id').change(change_visualizer_click); +// //$('#visualizer_id_form').submit(change_visualizer_clicked); +// +// $('#player_maximized .toggle, #player_minimized .toggle').click(function() { +// togglePlayerMaximization(); +// this.blur(); +// return false; +// }); +// +// +//} diff --git a/telemeta/htdocs/js/playerUtils.js b/telemeta/htdocs/js/playerUtils.js deleted file mode 100644 index c4c1c260..00000000 --- a/telemeta/htdocs/js/playerUtils.js +++ /dev/null @@ -1,167 +0,0 @@ -var player; //public player variable - -function togglePlayerMaximization() { - consolelog('entered togglePlayerMaximization'); - var view = $('#player'); - $('#player_maximized, #player_minimized').css('display', 'none'); - var ctr; - var dynamicResize = false; - if (view.parents('#player_maximized').length) { - ctr = $('#player_minimized').append(view); - } else { - ctr = $('#player_maximized').append(view); - dynamicResize = true; - } - ctr.css({ - opacity: 0, - display: 'block' - }); - if (player){ - player.resize(); - } - ctr.animate({ - opacity: 1 - }, 100); - player.setDynamicResize(dynamicResize); -} - -//function change_visualizer_clicked(){ -// var $J = jQuery; -// var form = $J("#visualizer_id_form"); -// //var img = jQuery("").attr("src","/images/wait.gif").css('verticalAlign','middle'); -// -// var visId = $J("#visualizer_id"); -// visId.attr("disabled","disabled"); -// var img = $J(form.children()[0]); -// var src = undefined; -// if(img.attr('src')){ -// src = img.attr('src'); -// img.attr("src","/images/wait_small.gif"); -// } -// -// //form.append(img); -// setTimeout(function(){ -// if (player){ -// player.refreshImage(); -// } -// //img.remove(); -// setTimeout(function(){ -// if(src){ -// img.attr('src',src); -// } -// visId.removeAttr("disabled"); -// },300); -// },600); -//} - -function loadPlayer(analizerUrl, soundUrl, itemId, visualizers, currentUserName){ - - if(!(analizerUrl) || !(soundUrl)){ - return; - } - - var $J = jQuery; - consolelog('till here all ok1'); - var msgElm = $J('#loading_span_text'); //element to show messages - consolelog('till here all ok2'); - if(msgElm){ - msgElm.html('Loading analyzer...'); - } - var url = urlNormalized(); - var tableBody = $J('#analyzer_div_id').find('table').find('tbody:last'); - var load_player = this.load_player; - $J.ajax({ - url: analizerUrl, //'analyze/xml', - dataType: 'xml', - success: function(data){ - //populatetable - $J.each($J(data).find('data'),function(index,element){ - var elm = $J(element); - tableBody.append(''+elm.attr('name')+''+elm.attr('value')+'' - +elm.attr('unit')+''); - }); - //loaded analizer, loading player - if(msgElm){ - msgElm.html('Loading player...'); - } - var duration = $J(data).find('#duration').attr('value'); - duration = duration.split(":"); - consolelog('analyzer loaded, duration: '+duration); - //format duration - var pin = parseInt; - var pfl = parseFloat; - var timeInMSecs=pin(duration[0])*3600+pin(duration[1])*60+pfl(duration[2]); - timeInMSecs = Math.round(timeInMSecs*1000); - load_player(soundUrl, timeInMSecs, itemId, visualizers, currentUserName); - }, - error:function(){ - msgElm.parent().html(""); - } - }); -} - - -//loads a player WAITING for the sound identified by soundUrl to be FULLY LOADED!!!! -function load_player(soundUrl, durationInMsecs, itemId, visualizers, currentUserName) { - consolelog('PlayerUtils.load_player: '+soundUrl+' '+durationInMsecs); - var load_player2 = this.load_player2; - - //this variable can be changed to load a sound immediately or not - var loadImmediately = true; - if(durationInMsecs){ - loadImmediately = false; - } - var sound = soundManager.createSound({ - id: 'sound', - autoLoad: loadImmediately, - url: soundUrl, - onload: function() { //formerly was: whileloading - //PROBLEM/BUG: on chrome and firefox whileloading is the same as onload, - //ie it is not called at regular interval but when the whole file has loaded - if(loadImmediately){ - consolelog('entering while loading setting up---------------'+this.bytesLoaded+' of '+this.bytesTotal); - loadImmediately=false; - load_player2(this, this.duration, itemId, visualizers, currentUserName); - } - } - }); - if(!loadImmediately){ - //TODO: remove this code is only temporary here!!!!!!!!!!!!!!!!!!!!1 - loadScripts('/timeside/src/',['rulermarker.js', //'markerlist.js', - 'markermap.js', 'player.js', 'ruler.js','divmarker.js'], function(){ - load_player2(sound,durationInMsecs,itemId, visualizers, currentUserName); - }); - } - -} -//NOTE: the duration must be present. Loaded from xmlanalyzer (see above) -function load_player2(sound, durationInMsec, itemId, visualizers, currentUserName) { - - if (!$('#player').length){ - return; - } - consolelog("entered load_player2"); - - //TODO: what are we doing here???? - $('.ts-wave a img').insertAfter('.ts-wave a'); - $('.ts-wave a').remove(); - - var p = new Player(jQuery('#player'), sound, durationInMsec, itemId, visualizers, currentUserName); - consolelog('initialized player'); - p._setupInterface(); - //p.loadMarkers(); - - player = p; - -// var change_visualizer_click = change_visualizer_clicked; -// $('#visualizer_id').change(change_visualizer_click); - //$('#visualizer_id_form').submit(change_visualizer_clicked); - - $('#player_maximized .toggle, #player_minimized .toggle').click(function() { - togglePlayerMaximization(); - this.blur(); - return false; - }); - - -} diff --git a/telemeta/htdocs/timeside/src/markermap.js b/telemeta/htdocs/timeside/src/markermap.js index bc3fe85e..d088b30f 100644 --- a/telemeta/htdocs/timeside/src/markermap.js +++ b/telemeta/htdocs/timeside/src/markermap.js @@ -4,6 +4,12 @@ * Author: Riccardo Zaccarelli * License: GNU General Public License version 2.0 */ + +/** + * class fior managing markers in the player. Markers on the ruler (ruler.js) or on the divs (divmarker.js) + * are not included here, they are separate classes. See player.js (loadMarkers method) where the bindings + * between this class, ruler and divmarker are set + */ var MarkerMap = TimesideArray.extend({ init: function(itemId, currentUserName) { @@ -184,13 +190,6 @@ var MarkerMap = TimesideArray.extend({ }, - //TODO: there is no need of a public method - // removeHTTP: function(marker){ - // var public_id = marker.id - // //json(param,method,onSuccessFcn,onErrorFcn){ - // json([public_id], "telemeta.del_marker"); - // }, - //overridden method move: function(markerIndex, newOffset){ var newIndex = this.insertionIndex(newOffset); diff --git a/telemeta/htdocs/timeside/src/player.js b/telemeta/htdocs/timeside/src/player.js index b73ff291..5cb1e82f 100644 --- a/telemeta/htdocs/timeside/src/player.js +++ b/telemeta/htdocs/timeside/src/player.js @@ -182,54 +182,33 @@ var Player = TimesideClass.extend({ var $J = this.$J; //defined in the super constructor var me=this; - //TODO: use cssPrefix or delete cssPrefix!!!!! - //TODO: note that ts-viewer is already in the html page. Better avoid this (horrible) method and use the html -// var skeleton = { -// 'div.ts-viewer': { -// 'div.ts-ruler': {}, -// 'div.ts-wave': { -// 'div.ts-image-canvas': {}, -// 'div.ts-image-container': ['img.ts-image'] -// } -// }, -// 'div.ts-control': { -// 'div.ts-layout': { -// 'div.ts-playback': ['a.ts-play', 'a.ts-pause', 'a.ts-rewind', 'a.ts-forward', 'a.ts-set-marker' //] -// ,'a.ts-volume','img.ts-wait', 'select.ts-visualizer'] -// } -// }/*, -// 'div.marker-control': ['a.set-marker']*/ -// }; - //var jQueryObjs = this.loadUI(this.getContainer(), skeleton); - - //image source (see below) is given a src with a temporary 1x1 pixels transparent image //see http://www.nczonline.net/blog/2009/11/30/empty-image-src-can-destroy-your-site/ and //http://geekswithblogs.net/bcaraway/archive/2007/08/24/114945.aspx //for details var html = ["
", - "
", - "
", - "
", - "
", - "", - "
", - "
", - "
", - "
", - "
", - "
", - "", - "", - "", - "", - "", - "", - "", - "", - "
", - "
", - "
"]; + "
", + "
", + "
", + "
", + "", + "
", + "
", + "", + "
", + "
", + "
", + "", + "", + "", + "", + "", + "", + "", + "", + "
", + "
", + "
"]; this.getContainer().html(html.join('')); var container = this.getContainer(); @@ -242,7 +221,7 @@ var Player = TimesideClass.extend({ var volume = container.find('.ts-volume'); - //hide the wait image and set the src + //hide the wait image and set the src var waitImg = container.find('.ts-wait'); waitImg.attr('src','/images/wait_small.gif').attr('title','refreshing image').attr('alt','refreshing image').hide(); @@ -290,16 +269,6 @@ var Player = TimesideClass.extend({ volume.attr('href', '#').click(function(event){ return setVolume(event); }); - // volume.attr('href', '#').click(function(){ - // return false; - // }).bind('mousedown', this.attach( - // function(e){ - // if(e.which===1){ //left button - // this.setVolume(e); - // } - // return false; - // } - // )); //assigning title to all anchors container.find('a').attr('href', '#') @@ -309,10 +278,7 @@ var Player = TimesideClass.extend({ }); //creating the ruler - - //TODO: why the line below does not work?!!!!! - //var viewer = jQueryObjs.find('.ts-viewer'); - var viewer = this.getContainer().find('.ts-viewer'); + var viewer = container.find('.ts-viewer'); var ruler = new Ruler(viewer, this.getSoundDuration(), (this.getCurrentUserName() || false)); this.getRuler = function(){ return ruler; @@ -355,34 +321,34 @@ var Player = TimesideClass.extend({ //loadMarkers has finished its job this.loadMarkers(); - //set the marker popup - //functions to set the marker popup -// var popupMarker = $J('
').addClass('component').css({ -// 'dislay':'none', -// 'position':'absolute', -// 'zIndex':1000, -// 'overflow':'auto', -// 'display':'none' //TODO: remove this -// //'backgroundColor':'#666' -// }); -// $J('body').append(popupMarker); -// var w = v.width(); -// var h = v.height(); -// var offs = v.offset(); //relative to the document -// var width = parseInt(w/2); -// var height = parseInt(h/2); -// var margin = 5; -// popupMarker.css({ -// 'left':(margin+offs.left+width)+'px', -// 'top': parseInt(margin+offs.top)+'px', -// 'width':width+'px', -// 'height':height+'px' -// }); -// popupMarker.html("
"+gettrans('title')+"
"+ -// gettrans('description')+"
"); -// this.getMarkerPopup = function(){ -// return popupMarker; -// } + //set the marker popup + //functions to set the marker popup + // var popupMarker = $J('
').addClass('component').css({ + // 'dislay':'none', + // 'position':'absolute', + // 'zIndex':1000, + // 'overflow':'auto', + // 'display':'none' //TODO: remove this + // //'backgroundColor':'#666' + // }); + // $J('body').append(popupMarker); + // var w = v.width(); + // var h = v.height(); + // var offs = v.offset(); //relative to the document + // var width = parseInt(w/2); + // var height = parseInt(h/2); + // var margin = 5; + // popupMarker.css({ + // 'left':(margin+offs.left+width)+'px', + // 'top': parseInt(margin+offs.top)+'px', + // 'width':width+'px', + // 'height':height+'px' + // }); + // popupMarker.html("
"+gettrans('title')+"
"+ + // gettrans('description')+"
"); + // this.getMarkerPopup = function(){ + // return popupMarker; + // } }, showMarkerPopup: function(markerIndex){ @@ -407,7 +373,10 @@ var Player = TimesideClass.extend({ // } }, - + /** + * sets whether or not window resize resizes also this player. When true, a variable _dynamicResize =setInterval(...) is attached to + * this class. When false, if _dynamicResize is in this class, clearInterval(_dynamicResize) is called and then the key is deleted + */ setDynamicResize: function(value){ var key = '_dynamicResize'; if(!value && key in this){ @@ -472,40 +441,40 @@ var Player = TimesideClass.extend({ //NOTE: some buttons might be hidden AFTER THIS METHOD HAS BEEN INVOKED //TODO: why the line below does not work?!!!!! //jQueryObjs.find('.ts-control') -// var $J = this.$J; -// var control = $J('#player').find('.ts-control'); -// var imgwait = playerelements.find('.ts-wait').hide(); -// var select = playerelements.find('.ts-visualizer'); -// var maxHeight = control.height(); -// var availableWidth = 0; -// select.siblings().each(function(i,e){ -// var ee = $J(e); -// if(ee.is('a')){ -// availableWidth+=ee.outerWidth(true); -//// consolelog(ee); -//// consolelog(ee.outerWidth()); -// } -// }); -// -// availableWidth = control.width() - availableWidth; -// var both = select.add(imgwait); -// both.css({ -// 'margin':'0px', -// 'width':'', -// 'height':'' -// }); -// -// select.css('maxHeight', (maxHeight-(select.outerHeight(true)-select.height()))+'px'); -// imgwait.css('maxHeight', (maxHeight-(imgwait.outerHeight(true)-imgwait.height()))+'px'); -// var imgMarginTop = (maxHeight- imgwait.outerHeight(true))/2; -// var selectMarginTop = (maxHeight-select.outerHeight(true))/2; -// select.css('marginTop', selectMarginTop+'px'); -// imgwait.css('marginTop', imgMarginTop+'px'); -// -// select.css('maxWidth', (availableWidth-(select.outerWidth(true)-select.width())+'px')); -// imgwait.css('maxWidth', (availableWidth-(imgwait.outerWidth(true)-imgwait.width())+'px')); -// select.css('marginLeft', ((availableWidth-select.outerWidth(true)-selectMarginTop))+'px'); -// imgwait.css('marginLeft', ((availableWidth- imgwait.outerWidth(true) - imgMarginTop))+'px'); + // var $J = this.$J; + // var control = $J('#player').find('.ts-control'); + // var imgwait = playerelements.find('.ts-wait').hide(); + // var select = playerelements.find('.ts-visualizer'); + // var maxHeight = control.height(); + // var availableWidth = 0; + // select.siblings().each(function(i,e){ + // var ee = $J(e); + // if(ee.is('a')){ + // availableWidth+=ee.outerWidth(true); + //// consolelog(ee); + //// consolelog(ee.outerWidth()); + // } + // }); + // + // availableWidth = control.width() - availableWidth; + // var both = select.add(imgwait); + // both.css({ + // 'margin':'0px', + // 'width':'', + // 'height':'' + // }); + // + // select.css('maxHeight', (maxHeight-(select.outerHeight(true)-select.height()))+'px'); + // imgwait.css('maxHeight', (maxHeight-(imgwait.outerHeight(true)-imgwait.height()))+'px'); + // var imgMarginTop = (maxHeight- imgwait.outerHeight(true))/2; + // var selectMarginTop = (maxHeight-select.outerHeight(true))/2; + // select.css('marginTop', selectMarginTop+'px'); + // imgwait.css('marginTop', imgMarginTop+'px'); + // + // select.css('maxWidth', (availableWidth-(select.outerWidth(true)-select.width())+'px')); + // imgwait.css('maxWidth', (availableWidth-(imgwait.outerWidth(true)-imgwait.width())+'px')); + // select.css('marginLeft', ((availableWidth-select.outerWidth(true)-selectMarginTop))+'px'); + // imgwait.css('marginLeft', ((availableWidth- imgwait.outerWidth(true) - imgMarginTop))+'px'); return this; @@ -541,7 +510,10 @@ var Player = TimesideClass.extend({ var w =select.width(); var h = select.height(); select.hide(); - var progressBar = container.find('.ts-wait').css({'width':w+'px','height':h+'px'}).show(); + var progressBar = container.find('.ts-wait').css({ + 'width':w+'px', + 'height':h+'px' + }).show(); image.load(function(){ progressBar.hide(); @@ -767,7 +739,7 @@ var Player = TimesideClass.extend({ } }); - jQuery('#loading_span').empty().remove(); + $J('#loading_span').empty().remove(); //TODO: move this in load_player? // setUpPlayerTabs([jQuery('#tab_analysis'), jQuery('#tab_markers')], // [jQuery('#analyzer_div_id'), jQuery('#markers_div_id')], tabIndex, diff --git a/telemeta/htdocs/timeside/src/playlist.js b/telemeta/htdocs/timeside/src/playlist.js index a68ddd4c..02518783 100644 --- a/telemeta/htdocs/timeside/src/playlist.js +++ b/telemeta/htdocs/timeside/src/playlist.js @@ -46,7 +46,7 @@ var playlistUtils = { 'content':dd, invoker:anchorElement, showok:true, - ok:function(data){ + onOk:function(data){ if(!data[t] && !data[d]){ return; } @@ -106,7 +106,7 @@ var playlistUtils = { new PopupDiv({ invoker:anchorElement, content: ar, - ok:function(data){ + onOk:function(data){ var val = data.selIndex; consolelog(data); var callbackok = undefined; diff --git a/telemeta/templates/telemeta_default/mediaitem_detail.html b/telemeta/templates/telemeta_default/mediaitem_detail.html index f5ab4850..02245fa6 100644 --- a/telemeta/templates/telemeta_default/mediaitem_detail.html +++ b/telemeta/templates/telemeta_default/mediaitem_detail.html @@ -6,13 +6,13 @@ {% block stylesheets %} {{ block.super }} - - - -{% endblock %} + + + + {% endblock %} -{% block extra_javascript %} -{% if item.file %} + {% block extra_javascript %} + {% if item.file %} @@ -43,14 +43,33 @@ {% endif %} }; - + //managing errors (might be improved in future development) + function playerError(msg){ + var elm = jQuery('#loading_span'); + if(elm.length>0){ + elm.empty().remove(); + } + jQuery('#rightcol').hide(); + alert(msg); + } + //warn on soundmanager error: + soundManager.onerror = function() { + playerError('SoundManager error. Try to:\n - Reload the page\n - Empty the cache (see browser preferences) and reload the page\n - Restart the browser'); + }; + + setTimeout(function(){ + if(jQuery('#loading_span').length>0){ + playerError('SoundManager error. Try to:\n - Reload the page\n - Empty the cache (see browser preferences) and reload the page\n - Restart the browser'); + } + },10000); + //initializing the visualizers to be passed to the player var visualizers = {}; {% for v in visualizers %} visualizers["{{v.name}}"] = "{% url telemeta-item-visualize item.public_id,v.id,"WIDTH","HEIGHT" %}"; {% endfor %} - var scripts = ["{% url telemeta-js "wz_jsgraphics.js" %}", "{% url telemeta-timeside "src/timeside.js" %}","{% url telemeta-js "playerUtils.js" %}"]; + var scripts = ["{% url telemeta-js "wz_jsgraphics.js" %}", "{% url telemeta-timeside "src/timeside.js" %}","{% url telemeta-js "playerLoader.js" %}"]; jQuery(window).ready(function(){ //if soundmanager is ready, the callback is executed immetiately @@ -62,7 +81,7 @@ loadPlayer('{% url telemeta-item-analyze-xml item.public_id %}',"{% url telemeta-item-export item.public_id,"mp3" %}", '{{item.id}}', visualizers, CURRENT_USER_NAME); setupPlaylist(); }); - }); + }); }); @@ -74,7 +93,7 @@ {% if item %} {% block title %} - Item : {{ item }} + Item : {{ item }} {% endblock %} {% block title_buttons %} @@ -189,7 +208,7 @@ {% endblock geoethnic_data %}
{% if user.is_authenticated and perms.telemeta.change_mediaitem %} - {% trans "Edit" %} {% trans "keywords" %} + {% trans "Edit" %} {% trans "keywords" %} {% endif %}
{% block musical_data %} @@ -228,7 +247,7 @@ {% endblock musical_data %}
{% if user.is_authenticated and perms.telemeta.change_mediaitem %} - {% trans "Edit"%} {% trans "performance"%} + {% trans "Edit"%} {% trans "performance"%} {% endif %}
{% block general_data %}