src/js/modules/mediafragment.js
branchpopcorn-port
changeset 809 1997dae651c6
parent 758 7fdb2d92da58
equal deleted inserted replaced
808:f7de8a24fc74 809:1997dae651c6
    38                     // there's no better way than that because
    38                     // there's no better way than that because
    39                     // of possible race conditions
    39                     // of possible race conditions
    40                     this._serializer.sync(IriSP.wrap(this, function() {
    40                     this._serializer.sync(IriSP.wrap(this, function() {
    41                           this.lookupAnnotation.call(this, annotationId); 
    41                           this.lookupAnnotation.call(this, annotationId); 
    42                           }));
    42                           }));
    43                   }                                    
    43                   }
    44               }
    44               }
    45 };
    45 };
    46 
    46 
    47 /** handler for the seeked signal. It may have or may have not an argument.
    47 /** handler for the seeked signal. It may have or may have not an argument.
    48     @param time if not undefined, the time we're seeking to 
    48     @param time if not undefined, the time we're seeking to 
    60   if (IriSP.null_or_undefined(time) || typeof(time) != "number") {
    60   if (IriSP.null_or_undefined(time) || typeof(time) != "number") {
    61     var ntime = this._Popcorn.currentTime().toFixed(2)
    61     var ntime = this._Popcorn.currentTime().toFixed(2)
    62   } else {
    62   } else {
    63     var ntime = time.toFixed(2);
    63     var ntime = time.toFixed(2);
    64   }
    64   }
       
    65 
       
    66   // used to relay the new hash to the embedder
       
    67   this._Popcorn.trigger("IriSP.Mediafragment.hashchange", "#t=" + ntime);
    65   
    68   
    66   splitArr = window.location.href.split( "#" )
    69   splitArr = window.location.href.split( "#" )
    67   history.replaceState( {}, "", splitArr[0] + "#t=" + ntime );
    70   history.replaceState( {}, "", splitArr[0] + "#t=" + ntime );
    68 };
    71 };
    69 
    72 
    74 
    77 
    75   var history = window.history;
    78   var history = window.history;
    76   if ( !history.pushState ) {
    79   if ( !history.pushState ) {
    77     return false;
    80     return false;
    78   }
    81   }
       
    82  
       
    83   
       
    84   // used to relay the new hash to the embedder
       
    85   this._Popcorn.trigger("IriSP.Mediafragment.hashchange", "#id=" + annotationId);
    79   
    86   
    80   splitArr = window.location.href.split( "#" )
    87   splitArr = window.location.href.split( "#" )
    81   history.replaceState( {}, "", splitArr[0] + "#id=" + annotationId);
    88   history.replaceState( {}, "", splitArr[0] + "#id=" + annotationId);
    82  
    89 
       
    90   
    83   // reset the mutex afterwards to prevent the module from reacting to his own changes.
    91   // reset the mutex afterwards to prevent the module from reacting to his own changes.
    84   window.setTimeout(function() { _this.mutex = false }, 50);
    92   window.setTimeout(function() { _this.mutex = false }, 50);
    85 };
    93 };
    86 
    94 
    87 // lookup and seek to the beginning of an annotation
    95 // lookup and seek to the beginning of an annotation