From 37137fdafea84074d0abb8d0dc54f27c837d4762 Mon Sep 17 00:00:00 2001 From: riccardo Date: Sat, 25 Jun 2011 17:40:10 +0200 Subject: [PATCH] cleanup and other stuff --- telemeta/htdocs/timeside/js/player.js | 17 +++++++++-------- telemeta/htdocs/timeside/js/timeside.js | 25 ++++++++++++++++++------- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/telemeta/htdocs/timeside/js/player.js b/telemeta/htdocs/timeside/js/player.js index 211d5454..b8879833 100644 --- a/telemeta/htdocs/timeside/js/player.js +++ b/telemeta/htdocs/timeside/js/player.js @@ -83,11 +83,11 @@ Timeside.classes.Player = Timeside.classes.TimesideClass.extend({ var sMan = soundManager; var sound = configObject.sound; var createSound = false; - if(this.$TU.flahsFailed){ - this.soundErrorMsg = 'SoundManager error. If your browser does not support HTML5, Flash player (version '+soundManager.flashVersion+'+) must be installed.\nIf flash is installed, try to:\n - Reload the page\n - Empty the cache (see browser preferences/options/tools) and reload the page\n - Restart the browser'; + if(this.$TU.flashFailed){ + this.soundErrorMsg = 'soundManager error. If your browser does not support HTML5, Flash player (version '+sMan.flashVersion+'+) must be installed.\nIf flash is installed, try to:\n - Reload the page\n - Empty the cache (see browser preferences/options/tools) and reload the page\n - Restart the browser'; }else{ if(typeof sound !== 'string' && typeof sound !== 'object'){ - this.soundErrorMsg ='bad sound parameter (specify a a valid soundManager sound-object, an object with at least two properties, url and id, or URL as string)'; + this.soundErrorMsg ='bad sound parameter: specify a a valid soundManager sound-object, an object with at least two properties, url and id, or URL as string'; }else if(typeof sound === 'string'){ createSound = true; var soundURL = sound; @@ -108,6 +108,8 @@ Timeside.classes.Player = Timeside.classes.TimesideClass.extend({ if(createSound){ var soundOptions = sound; if(sMan.canPlayURL(soundOptions.url)){ //this actually checks only if the url is well formed, not if the file is there + //check if we specified a valid sound duration, otherwise the sound must be loaded + sound = sMan.createSound(soundOptions); }else{ this.soundErrorMsg = 'bad sound parameter (soundManager.canPlayURL returned false)'; @@ -124,7 +126,7 @@ Timeside.classes.Player = Timeside.classes.TimesideClass.extend({ }; } var soundDurationInMsec = configObject.soundDuration; - if(isNaN(soundDurationInMsec) || soundDurationInMsec<=0){ + if(typeof soundDurationInMsec !== 'number' || soundDurationInMsec<=0){ onError('invalid soundDurationInMsec: NaN or not positive'); return; } @@ -375,8 +377,6 @@ Timeside.classes.Player = Timeside.classes.TimesideClass.extend({ //Weird enough (with IE it isn't actually), we have just to set the property we already set in the css: //ie, top: auto. This is however useful even if somebody specified a top property on the divs ruler_.add(wave).add(control).css('top','auto'); - - onReady(this); }, @@ -440,8 +440,9 @@ Timeside.classes.Player = Timeside.classes.TimesideClass.extend({ }); }, - - soundErrorMsg: "", + showSoundErroMessage: function(){ + alert(this.soundErrorMsg); + }, //given a marker at index I, specifies that a marker corss event is fired whenever the sound position (pointer) //is in the interval ]markerCrossedOffsetMargin-I,I+markerCrossedOffsetMargin[ //the value is in seconds diff --git a/telemeta/htdocs/timeside/js/timeside.js b/telemeta/htdocs/timeside/js/timeside.js index 4afce616..3d49f47f 100644 --- a/telemeta/htdocs/timeside/js/timeside.js +++ b/telemeta/htdocs/timeside/js/timeside.js @@ -665,13 +665,24 @@ Timeside.load =function(config){ } }; + } + ts.player = undefined; + if(config.onReady && typeof config.onReady === 'function'){ + var oR = config.onReady; + config.onReady = function(player){ + ts.player = player; + oR(player); + }; + }else{ + config.onReady = function(player){ + ts.player = player; + }; } + //finally,define the error function ts.utils.loadScripts(thisScriptPath,ts_scripts, function() { - var p = new ts.classes.Player(config); - ts.player = p; - return false; + new ts.classes.Player(config); //do not assign it to any variable, we do it only onready },config.onError); }; @@ -679,12 +690,12 @@ Timeside.load =function(config){ $J(win).ready(function(){ - + var s = soundManager; //grab the case of soundManager init errors: - soundManager.onerror = function() { + s.onerror = function() { Timeside.utils.flashFailed = true; //end('SoundManager error. If your browser does not support HTML5, Flash player (version '+soundManager.flashVersion+'+) must be installed.\nIf flash is installed, try to:\n - Reload the page\n - Empty the cache (see browser preferences/options/tools) and reload the page\n - Restart the browser'); - + //and load all anyway: loadAll(); }; @@ -692,7 +703,7 @@ Timeside.load =function(config){ //if soundmanager is ready, the callback is executed immetiately //onready is executed BEFORE onload, it basically queues several onload events. //It it is executed immetiately if soundmanager has already been loaded - soundManager.onready(loadAll); + s.onready(function(){loadAll();}); }); }; -- 2.39.5