]> git.parisson.com Git - telemeta.git/commitdiff
cleanup and other stuff
authorriccardo <riccardo@parisson.com>
Sat, 25 Jun 2011 15:40:10 +0000 (17:40 +0200)
committerriccardo <riccardo@parisson.com>
Sat, 25 Jun 2011 15:40:10 +0000 (17:40 +0200)
telemeta/htdocs/timeside/js/player.js
telemeta/htdocs/timeside/js/timeside.js

index 211d5454a37ad756c4128ba1a69cc1e0a90a141c..b887983330c6ca838caa40f3e52cc80fe5a007af 100644 (file)
@@ -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
index 4afce6166c5f569711f150a820294f1e9649f2c1..3d49f47f626ee11556ae63020d3c54c0c810bf41 100644 (file)
@@ -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();});
     });
 };