r60496 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60495‎ | r60496 | r60497 >
Date:09:14, 30 December 2009
Author:dale
Status:deferred
Tags:
Comment:
* playlist player fixes
Modified paths:
  • /branches/js2-work/phase3/js/mwEmbed/modules/Sequencer/mw.PlayList.js (modified) (history)

Diff [purge]

Index: branches/js2-work/phase3/js/mwEmbed/modules/Sequencer/mw.PlayList.js
@@ -8,7 +8,7 @@
99 * @author: Michael Dale mdale@wikimedia.org
1010 * @license GPL2
1111 */
12 -var mv_default_playlist_attributes = {
 12+var mw_default_playlist_attributes = {
1313 // playlist attributes :
1414 "id":null,
1515 "title":null,
@@ -98,14 +98,17 @@
9999 this.default_track = this.tracks[0];
100100
101101 // get all the attributes:
102 - for ( var attr in mv_default_playlist_attributes ) {
 102+ for ( var attr in mw_default_playlist_attributes ) {
103103 if ( element.getAttribute( attr ) ) {
104104 this[attr] = element.getAttribute( attr );
105105 // mw.log('attr:' + attr + ' val: ' + video_attributes[attr] +" "+'elm_val:' + element.getAttribute(attr) + "\n (set by elm)");
106106 } else {
107 - this[attr] = mv_default_playlist_attributes[attr];
 107+ this[attr] = mw_default_playlist_attributes[attr];
108108 // mw.log('attr:' + attr + ' val: ' + video_attributes[attr] +" "+ 'elm_val:' + element.getAttribute(attr) + "\n (set by attr)");
109109 }
 110+ // Boolean -> string
 111+ if( this[attr] == 'false' ) this[attr] = false;
 112+ if( this[attr] == 'true' ) this[attr] = true;
110113 }
111114 // make sure height and width are int:
112115 this.width = parseInt( this.width );
@@ -120,10 +123,9 @@
121124 if ( this.controls === false ) {
122125 this.layout.control_height = 0;
123126 this.layout.title_bar_height = 0;
124 - } else {
125 - // setup the controlBuilder object:
126 - this.ctrlBuilder = new ctrlBuilder( this );
127 - }
 127+ }
 128+ // setup the controlBuilder object:
 129+ this.ctrlBuilder = new ctrlBuilder( this );
128130 },
129131 // run inheritEmbedPlayer on every clip (we have changed the playback method)
130132 inheritEmbedPlayer:function() {
@@ -465,8 +467,7 @@
466468 this.ctrlBuilder.addControls( );
467469 }
468470
469 - this.setupClipDisplay();
470 -
 471+ this.setupClipDisplay();
471472 // update the title and status bar
472473 this.updateBaseStatus();
473474 this.doSmilActions();
@@ -696,8 +697,7 @@
697698
698699 // Do swap:
699700 this.cur_clip = new_clip;
700 - $j( '#clipDesc_' + this.cur_clip.id ).show();
701 -
 701+ $j( '#clipDesc_' + this.cur_clip.id ).show();
702702 // Update the playhead:
703703 if( this.controls ){
704704 // Check if we have into_perc
@@ -706,7 +706,6 @@
707707 }else{
708708 var clip_time = this.cur_clip.dur_offset;
709709 }
710 -
711710 this.updatePlayHead( clip_time / this.getDuration() );
712711 }
713712 },
@@ -747,15 +746,11 @@
748747 var _this = this;
749748 mw.log( 'pl play' );
750749 // hide the playlist play button:
751 - this.$interface.find('.play-btn-large' ).hide();
 750+ this.$interface.find('.play-btn-large' ).hide();
752751
753752 // un-pause if paused:
754753 if ( this.paused )
755754 this.paused = false;
756 -
757 - // update the control:
758 - this.start_clip = this.cur_clip;
759 - this.start_clip_src = this.cur_clip.src;
760755
761756 if ( this.cur_clip.embed.supports['playlist_swap_loader'] ) {
762757 // set the cur_clip to active
@@ -797,13 +792,14 @@
798793 // start up the playlist monitor
799794 this.monitor();
800795 },
801 - /*
 796+
 797+ /**
802798 * the load function loads all the clips in order
803799 */
804800 load:function( callback ) {
805801 // do nothing right now)
806802 //alert('load pl');
807 - callback();
 803+ callback();
808804 },
809805 toggleMute:function() {
810806 this.cur_clip.embed.toggleMute();
@@ -821,6 +817,10 @@
822818 clip.embed.pause();
823819 } );
824820
 821+ this.updateUIPauseState();
 822+ },
 823+ updateUIPauseState:function(){
 824+ var _this = this;
825825 // Copied from embedPlayer.pause ( in the refactor this is not needed )
826826 // update the ctrl "paused state"
827827 this.$interface.find('.play-btn span' )
@@ -859,54 +859,9 @@
860860 },
861861 // playlist stops playback for the current clip (and resets state for start clips)
862862 stop:function() {
863 - var _this = this;
864 - /*mw.log("pl stop:"+ this.start_clip.id + ' c:'+this.cur_clip.id);
865 - //if start clip
866 - if(this.start_clip.id!=this.cur_clip.id){
867 - //restore clipDesc visibility & hide desc for start clip:
868 - $j('#clipDesc_'+this.start_clip.id).html('');
869 - this.start_clip.getDetail();
870 - $j('#clipDesc_'+this.start_clip.id).css({display:'none'});
871 - this.start_clip.setBaseEmbedDim(this.start_clip.embed);
872 - //equivalent of base stop
873 - $j('#'+this.start_clip.embed.id).html(this.start_clip.embed.getThumbnailHTML());
874 - this.start_clip.embed.thumbnail_disp=true;
875 - }
876 - //empty the play-back container
877 - $j('#mv_ebct_'+this.id).empty();*/
878 -
879 - // stop all the clips: monitor:
880 - window.clearInterval( this.smil_monitorTimerId );
881 - /*for (var i=0;i<this.clips.length;i++){
882 - var clip = this.clips[i];
883 - if(clip){
884 - clip.embed.stop();
885 - $j('#clipDesc_'+clip.id).hide();
886 - }
887 - }*/
888 - // stop, hide and remove all active clips:
889 - $j.each( this.activeClipList.getClipList(), function( inx, clip ) {
890 - if ( clip ) {
891 - clip.embed.stop();
892 - $j( '#clipDesc_' + clip.id ).hide();
893 - _this.activeClipList.remove( clip );
894 - }
895 - } );
896 - // set the current clip to the first clip:
897 - if ( this.start_clip ) {
898 - this.cur_clip = this.start_clip;
899 - // display the first clip thumb:
900 - this.cur_clip.embed.stop();
901 - // hide other clips:
902 - $j( '#' + this.id + ' .clip_container' ).hide();
903 - // show the first/current clip:
904 - $j( '#clipDesc_' + this.cur_clip.id ).show();
905 - }
906 - // reset the currentTime:
907 - this.currentTime = 0;
908 - // rest the sldier
909 - this.updatePlayHead( 0 );
910 - // FIXME still some issues with "stoping" and reseting the playlist
 863+ var _this = this;
 864+ mw.log("mw.PlayList stop:"+ this.start_clip.id + ' c:'+this.cur_clip.id);
 865+ this.setupClipDisplay();
911866 },
912867 doSeek:function( v ) {
913868 mw.log( 'pl:doSeek:' + v + ' sts:' + this.seek_time_sec );
@@ -932,7 +887,7 @@
933888 var clip_time = relative_perc * _this.cur_clip.embed.getDuration();
934889 _this.cur_clip.embed.setCurrentTime( clip_time, function() {
935890 //update the smil actions now that the seek is done
936 - _this.doSmilActions();
 891+ _this.doSmilActions();
937892 //say we are "ready"
938893 if ( callback )
939894 callback();
@@ -1068,47 +1023,20 @@
10691024 }
10701025 track.addClip( clipObj, pos );
10711026 },
1072 - swapClipDesc: function( req_clipID, callback ) {
1073 - // hide all but the requested
1074 - var _this = this;
1075 - mw.log( 'r:' + req_clipID + ' cur:' + _this.id );
1076 - if ( req_clipID == _this.cur_clip.id ) {
1077 - mw.log( 'no swap to same clip' );
1078 - } else {
1079 - // fade out clips
1080 - req_clip = null;
1081 - $j.each( this.default_track.clips, function( i, clip ) {
1082 - if ( clip.id != req_clipID ) {
1083 - // fade out if display!=none already
1084 - if ( $j( '#clipDesc_' + clip.id ).css( 'display' ) != 'none' ) {
1085 - $j( '#clipDesc_' + clip.id ).fadeOut( "slow" );
1086 - }
1087 - } else {
1088 - req_clip = clip;
1089 - }
1090 - } );
1091 - // fade in requested clip *and set req_clip to current
1092 - $j( '#clipDesc_' + req_clipID ).fadeIn( "slow", function() {
1093 - _this.cur_clip = req_clip;
1094 - if ( callback )
1095 - callback();
1096 - } );
1097 - }
1098 - },
10991027 run_transition: function( clip_inx, trans_type ) {
11001028 if ( typeof this.default_track.clips[ clip_inx ][ trans_type ] == 'undefined' )
11011029 clearInterval( this.default_track.clips[ clip_inx ].timerId );
11021030 else
11031031 this.default_track.clips[ clip_inx ][ trans_type ].run_transition();
11041032 },
1105 - getPlayerWidth : function(){
 1033+ getPlayerWidth: function(){
11061034 var player = $j( this ).get( 0 );
11071035 if ( typeof player != 'undefined' && player['offsetWidth'] )
11081036 return player.offsetWidth;
11091037 else
11101038 return parseInt( this.width );
11111039 },
1112 - getPlayerHeight : function(){
 1040+ getPlayerHeight: function(){
11131041 var player = $j( this ).get( 0 );
11141042 if ( typeof player != 'undefined' && player['offsetHeight'] )
11151043 return player.offsetHeight;
@@ -1346,8 +1274,8 @@
13471275 // go to next in playlist:
13481276 this.pc.pp.playNext();
13491277 },
1350 - stop:function() {
1351 - mw.log( 'pl:do stop' );
 1278+ stop: function() {
 1279+ mw.log( 'PlMvEmbed::do stop' );
13521280 // set up convenience pointer to parent playlist
13531281 var _this = this.pc.pp;
13541282
@@ -1593,8 +1521,7 @@
15941522 // do a _play next:
15951523 _clip.pp.playNext();
15961524 }
1597 - }
1598 - // @@todo could maybe generalize transIn with trasOut into one "flow" with a few scattered if statements
 1525+ }
15991526 // update/setup all transitions (will render current transition state)
16001527
16011528 // process actions per transition types:
@@ -1607,7 +1534,7 @@
16081535 * @param {string} tid the transition type [transIn|transOut]
16091536 * @param {function} callback the callback function passed onto doUPdate
16101537 */
1611 -mw.PlayList.prototype.procTranType = function( tid, callback){
 1538+mw.PlayList.prototype.procTranType = function( tid, callback){
16121539 // Setup local clip pointer:
16131540 var _clip = this.cur_clip;
16141541
@@ -1623,7 +1550,9 @@
16241551 in_range = ( _clip.embed.currentTime >= ( _clip.dur - tObj.dur ) ) ? true : false;
16251552
16261553 if ( in_range ) {
1627 - if ( this.userSlide || this.paused ) {
 1554+ tObj.animation_state = 0;
 1555+ tObj.run_transition();
 1556+ /*if ( this.userSlide || this.paused ) {
16281557 if ( tid == 'transIn' ){
16291558 mvTransLib.doUpdate( tObj,
16301559 ( _clip.embed.currentTime / tObj.dur ),
@@ -1637,7 +1566,7 @@
16381567 } else if ( tObj.animation_state == 0 ) {
16391568 mw.log( 'init/run_transition ' );
16401569 tObj.run_transition();
1641 - }
 1570+ }*/
16421571 } else {
16431572 // Close up transition if done & still onDispaly
16441573 if ( tObj.overlay_selector_id ) {
@@ -1645,8 +1574,9 @@
16461575 mvTransLib.doCloseTransition( tObj );
16471576 }
16481577 }
 1578+
16491579 // Run the callback::
1650 - if( callback )
 1580+ if( callback )
16511581 callback();
16521582 }
16531583
@@ -1712,7 +1642,7 @@
17131643 }
17141644
17151645 // all good call function with tObj param
1716 - mw.log( 'should call: ' + tObj.type + ' ' + tObj.subtype );
 1646+ //mw.log( 'should call: ' + tObj.type + ' ' + tObj.subtype );
17171647 this['type'][tObj.type][tObj.subtype].init( tObj );
17181648 },
17191649 doCloseTransition:function( tObj ) {
@@ -1727,7 +1657,7 @@
17281658 },
17291659 getOverlaySelector:function( tObj ) {
17301660 var overlay_selector_id = tObj.transAttrType + tObj.pClip.id;
1731 - mw.log( 'f:getOverlaySelector: ' + overlay_selector_id + ' append to: ' + '#videoPlayer_' + tObj.pClip.embed.id );
 1661+ //mw.log( 'f:getOverlaySelector: ' + overlay_selector_id + ' append to: ' + '#videoPlayer_' + tObj.pClip.embed.id );
17321662 // make sure overlay_selector_id not already here:
17331663 if ( $j( '#' + overlay_selector_id ).length == 0 ) {
17341664 $j( '#' + tObj.pClip.embed.id ).prepend( '' +
@@ -1876,7 +1806,7 @@
18771807 * Main animation loop called every MV_ANIMATION_CB_RATE or 34ms ~around 30frames per second~
18781808 */
18791809 run_transition: function() {
1880 - _this = this;
 1810+ _this = this;
18811811 // If we have the playerElement update the time per run_transition call
18821812 if ( this.pClip.embed.playerElement && this.pClip.embed.playerElement.currentTime ) {
18831813 this.pClip.embed.currentTime = this.pClip.embed.playerElement.currentTime;
@@ -1898,11 +1828,16 @@
18991829 this.animation_state = 1;
19001830 }
19011831
1902 - var percentage = this.pClip.embed.currentTime / this.dur;
 1832+ if( this.transAttrType=='transIn' ){
 1833+ var percentage = ( this.pClip.embed.currentTime / this.dur ) ;
 1834+ }
19031835
1904 - //mw.log('percentage = ct:'+this.pClip.embed.currentTime + ' + ic:'+this.interValCount +' * cb:'+MV_ANIMATION_CB_RATE +' / ' + this.dur + ' = ' + percentage );
1905 -
1906 -
 1836+ if( this.transAttrType=='transOut' ){
 1837+ var percentage = ( this.pClip.embed.currentTime -
 1838+ (this.pClip.dur - this.dur)
 1839+ )
 1840+ / this.dur ;
 1841+ }
19071842 // mw.log('cur percentage of transition: '+percentage);
19081843 // update state based on current time + cur_time_offset (for now just use pClip.embed.currentTime)
19091844 mvTransLib.doUpdate( this, percentage );

Status & tagging log