r103564 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103563‎ | r103564 | r103565 >
Date:03:02, 18 November 2011
Author:dale
Status:ok
Tags:
Comment:
updated onEvents for native player interface
Modified paths:
  • /trunk/extensions/TimedMediaHandler/MwEmbedModules/EmbedPlayer/resources/mw.EmbedPlayerNative.js (modified) (history)

Diff [purge]

Index: trunk/extensions/TimedMediaHandler/MwEmbedModules/EmbedPlayer/resources/mw.EmbedPlayerNative.js
@@ -370,10 +370,14 @@
371371 return this.playerElement.currentTime;
372372 },
373373
374 - // Update the poster src ( updates the native object if in dom )
 374+ /**
 375+ * Updates the poster source for the video tatg
 376+ * @param {string}
 377+ * src Url of the poster iamge
 378+ */
375379 updatePosterSrc: function( src ){
376380 if( this.getPlayerElement() ){
377 - this.getPlayerElement().poster = src;
 381+ $( this.getPlayerElement() ).attr( 'poster', src );
378382 }
379383 // Also update the embedPlayer poster
380384 this.parent_updatePosterSrc( src );
@@ -565,8 +569,9 @@
566570 } else {
567571 // Should not happen offten
568572 this.playerElement.load();
569 - if( callback)
 573+ if( callback ){
570574 callback();
 575+ }
571576 }
572577 },
573578
@@ -586,19 +591,20 @@
587592 * Local method for seeking event
588593 * fired when "seeking"
589594 */
590 - onseeking: function() {
591 - mw.log( "native:onSeeking");
 595+ _onseeking: function() {
 596+ mw.log( "EmbedPlayerNative::onSeeking " + this.seeking);
592597 // Trigger the html5 seeking event
593598 //( if not already set from interface )
594599 if( !this.seeking ) {
595600 this.seeking = true;
596 -
597601 // Run the onSeeking interface update
598602 this.controlBuilder.onSeek();
599603
600604 // Trigger the html5 "seeking" trigger
601 - mw.log("native:seeking:trigger:: " + this.seeking);
602 - $( this ).trigger( 'seeking' );
 605+ mw.log("EmbedPlayerNative::seeking:trigger:: " + this.seeking);
 606+ if( this._propagateEvents ){
 607+ $( this ).trigger( 'seeking' );
 608+ }
603609 }
604610 },
605611
@@ -606,20 +612,25 @@
607613 * Local method for seeked event
608614 * fired when done seeking
609615 */
610 - onseeked: function() {
611 - mw.log("native:onSeeked");
 616+ _onseeked: function() {
 617+ mw.log("EmbedPlayerNative::onSeeked " + this.seeking + ' ct:' + this.playerElement.currentTime );
 618+ // sync the seek checks so that we don't re-issue the seek request
 619+ this.previousTime = this.currentTime = this.playerElement.currentTime;
612620 // Trigger the html5 action on the parent
613621 if( this.seeking ){
614622 this.seeking = false;
615 - $( this ).trigger( 'seeked' );
 623+ if( this._propagateEvents ){
 624+ $( this ).trigger( 'seeked' );
 625+ }
616626 }
617 - this.seeking = false;
 627+ // update the playhead status
 628+ this.monitor();
618629 },
619630
620631 /**
621632 * Handle the native paused event
622633 */
623 - onpause: function(){
 634+ _onpause: function(){
624635 mw.log( "EmbedPlayer:native: OnPaused:: " + this._propagateEvents );
625636 if( this._propagateEvents ){
626637 this.parent_pause();
@@ -629,7 +640,7 @@
630641 /**
631642 * Handle the native play event
632643 */
633 - onplay: function(){
 644+ _onplay: function(){
634645 mw.log("EmbedPlayer:native:: OnPlay::" + this._propagateEvents );
635646 // Update the interface ( if paused )
636647 if( this._propagateEvents ){
@@ -644,10 +655,10 @@
645656 * Used to update the media duration to
646657 * accurately reflect the src duration
647658 */
648 - onloadedmetadata: function() {
 659+ _onloadedmetadata: function() {
649660 this.getPlayerElement();
650661 if ( this.playerElement && ! isNaN( this.playerElement.duration ) ) {
651 - mw.log( 'f:onloadedmetadata metadata ready Update duration:' + this.playerElement.duration + ' old dur: ' + this.getDuration() );
 662+ mw.log( 'EmbedPlayerNative :onloadedmetadata metadata ready Update duration:' + this.playerElement.duration + ' old dur: ' + this.getDuration() );
652663 this.duration = this.playerElement.duration;
653664 }
654665
@@ -672,7 +683,7 @@
673684 * Note: this way of updating buffer was only supported in Firefox 3.x and
674685 * not supported in Firefox 4.x
675686 */
676 - onprogress: function( event ) {
 687+ _onprogress: function( event ) {
677688 var e = event.originalEvent;
678689 if( e && e.loaded && e.total ) {
679690 this.bufferedPercent = e.loaded / e.total;
@@ -681,16 +692,15 @@
682693 },
683694
684695 /**
685 - * Local method for progress event
686 - * fired as the video is downloaded / buffered
687 - *
688 - * Used to update the bufferedPercent
 696+ * Local method for end of media event
689697 */
690 - onended: function() {
 698+ _onended: function() {
691699 var _this = this;
692 - mw.log( 'EmbedPlayer:native: onended:' + this.playerElement.currentTime + ' real dur:' + this.getDuration() + ' ended ' + this._propagateEvents );
693 - if( this._propagateEvents ){
694 - this.onClipDone();
 700+ if( this.getPlayerElement() ){
 701+ mw.log( 'EmbedPlayer:native: onended:' + this.playerElement.currentTime + ' real dur:' + this.getDuration() + ' ended ' + this._propagateEvents );
 702+ if( this._propagateEvents ){
 703+ this.onClipDone();
 704+ }
695705 }
696706 }
697707 };

Status & tagging log