r41904 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r41903‎ | r41904 | r41905 >
Date:22:47, 9 October 2008
Author:stipe
Status:old
Tags:
Comment:
Flowplayer works with local seeking
Modified paths:
  • /trunk/extensions/MetavidWiki/skins/mv_embed/embedLibs/mv_flashEmbed.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/mv_embed.js (modified) (history)

Diff [purge]

Index: trunk/extensions/MetavidWiki/skins/mv_embed/embedLibs/mv_flashEmbed.js
@@ -169,20 +169,28 @@
170170 if(!this.fla['getTime'])
171171 return js_log('can not monitor without time');
172172
173 - this.currentTime = this.fla.getTime();
 173+ this.currentTime = this.fla.getTime();
174174
175175 if(this.currentTime > 1 && !this.startedTimedPlayback){
176176 this.startedTimedPlayback=true;
177 - js_log("time is "+ this.currentTime + " started playback");
178 - }
 177+ js_log("time is "+ this.currentTime + " started playback");
 178+ if(this.seek_time_sec != 0 && !this.media_element.selected_source.supports_url_time_encoding)
 179+ {
 180+ js_log('Seeking to ' + this.seek_time_sec);
 181+ this.fla.Seek(this.seek_time_sec);
 182+ this.seek_time_sec = 0;
 183+ }
 184+ }
179185
180 -
181 - //flash is giving bogus duration get from this (if available)
 186+ //flash is giving bogus duration get from this (if available)
 187+ if(!this.media_element.selected_source.end_ntp && this.fla.getDuration()>0)
 188+ this.media_element.selected_source.setDuration(this.fla.getDuration());
 189+
182190 var end_ntp = (this.media_element.selected_source.end_ntp)?
183 - this.media_element.selected_source.end_ntp :
184 - seconds2ntp( this.fla.getDuration() );
185 - var start_ntp = (this.media_element.selected_source.start_ntp)?
186 - this.media_element.selected_source.start_ntp : 0;
 191+ this.media_element.selected_source.end_ntp : seconds2ntp(0);
 192+ // selected_source.start_ntp is now guaranteed to exist
 193+ var start_ntp = this.media_element.selected_source.start_ntp;
 194+
187195 if(!this.userSlide){
188196 if((this.currentTime - ntp2seconds(start_ntp))<0){
189197 this.setStatus('buffering...');
@@ -193,7 +201,7 @@
194202 }
195203
196204 //super hackery to see if we have "probably" reached the end of playback:
197 - if(this.prevTime==this.currentTime && (this.currentTime > (ntp2seconds(end_ntp)-1)) ){
 205+ if(this.startedTimedPlayback && this.prevTime==this.currentTime && (this.currentTime > (ntp2seconds(end_ntp)-1)) ){
198206 js_log('probablly reached end of stream: '+this.currentTime);
199207 this.onClipDone();
200208 }
Index: trunk/extensions/MetavidWiki/skins/mv_embed/mv_embed.js
@@ -1481,6 +1481,8 @@
14821482 title:null,
14831483 /** True if the source has been marked as the default. */
14841484 marked_default:null,
 1485+ /** True if the source supports url specification of offset and duration */
 1486+ supports_url_time_encoding:null,
14851487 /** Start offset of the requested segment */
14861488 start_offset:null,
14871489 /** Duration of the requested segment (NaN if not known) */
@@ -1548,7 +1550,7 @@
15491551 js_log("f:updateSrcTime: "+ start_ntp+'/'+ end_ntp);
15501552 //js_log("pre uri:" + this.src);
15511553 //if we have time we can use:
1552 - if(this.start_ntp!=null){
 1554+ if(this.supports_url_time_encoding){
15531555 var index_time_val = false;
15541556 var time_req_delimitator = '';
15551557 if(this.src.indexOf('?t=')!=-1)index_time_val='?t=';
@@ -1559,11 +1561,17 @@
15601562 this.src.indexOf('&', this.src.indexOf(index_time_val));
15611563 this.src = this.src.substring(0, this.src.indexOf(index_time_val) ) + index_time_val + start_ntp + '/'+end_ntp + end_req_string;
15621564 }
 1565+ this.parseURLDuration();
15631566 }
 1567+
15641568 //update the duration
1565 - this.parseURLDuration();
15661569 //js_log("post uri:" + this.src);
15671570 },
 1571+ setDuration:function (duration)
 1572+ {
 1573+ this.duration = duration;
 1574+ this.end_ntp = seconds2ntp(this.start_offset + duration);
 1575+ },
15681576 /** MIME type accessor function.
15691577 @return the MIME type of the source.
15701578 @type String
@@ -1623,10 +1631,13 @@
16241632 this.duration = ntp2seconds( this.end_ntp ) - this.start_offset;
16251633
16261634 this.duration = this.duration;
 1635+ this.supports_url_time_encoding = true;
16271636 }else{
16281637 //else normal media request (can't predict the duration without the plugin reading it)
16291638 this.duration=null;
16301639 this.start_offset=0;
 1640+ this.start_ntp=seconds2ntp(this.start_offset);
 1641+ this.supports_url_time_encoding = false;
16311642 }
16321643 },
16331644 /** Attempts to detect the type of a media file based on the URI.
@@ -2089,7 +2100,7 @@
20902101 return default_time_req;
20912102 if(!this.media_element.selected_source)
20922103 return default_time_req;
2093 - if(!this.media_element.selected_source.start_ntp)
 2104+ if(!this.media_element.selected_source.end_ntp)
20942105 return default_time_req;
20952106 return this.media_element.selected_source.start_ntp+'/'+this.media_element.selected_source.end_ntp;
20962107 },
@@ -2437,7 +2448,10 @@
24382449 //reset slider
24392450 this.setSliderValue(0);
24402451 //reset seek_offset:
2441 - this.seek_time_sec=0;
 2452+ if(this.media_element.selected_source.supports_url_time_encoding)
 2453+ this.seek_time_sec=0;
 2454+ else
 2455+ this.seek_time_sec=ntp2seconds(start_time);
24422456 },
24432457 //updates the video src
24442458 updateVideoSrc : function(src){

Status & tagging log