r37672 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r37671‎ | r37672 | r37673 >
Date:23:14, 14 July 2008
Author:dale
Status:old
Tags:
Comment:
restored mv_stream.js compatibility with mv_embed's multiple mediaStream format
Modified paths:
  • /branches/MetavidWiki-exp/MetavidWiki/skins/mv_embed/mv_embed.js (modified) (history)
  • /branches/MetavidWiki-exp/MetavidWiki/skins/mv_stream.js (modified) (history)

Diff [purge]

Index: branches/MetavidWiki-exp/MetavidWiki/skins/mv_stream.js
@@ -19,7 +19,7 @@
2020 * also assumes scriptaculus is included in the mv_embed distribution
2121 * /skins/mv_embed/scriptaculous
2222 */
23 -var org_vid_src = null; //stores the original video src
 23+var org_vid_time_req =null; //store the orginal time req:
2424 var org_thum_src = null; //stores the original thumbnail src
2525 var org_vid_title = null; //stores the original title
2626 //store the original range request:
@@ -91,30 +91,30 @@
9292 //set up the init values for mouse over restore:
9393 org_vid_title = $j('#mv_stream_time').html();
9494 if(!$j('#embed_vid').get(0)){
95 - //no embed video present stop init
 95+ //no embed video present stop init
9696 return '';
9797 }
98 - org_vid_src = $j('#embed_vid').get(0).src;
 98+ org_vid_time_req = $j('#embed_vid').get(0).getTimeReq();
9999 org_thum_src = $j('#embed_vid').get(0).thumbnail;
100 - //overide play button action to interface control:
101 - $j('#big_play_link_embed_vid').attr('href', 'javascript:mv_do_play();');
 100+
102101 //@@TODO override stop function in player:
103102
104103 //current range or search parameter
105104 stream_current_context =$j('#mv_stream_time').html();
106 - js_log('set org_vid_src: ' + org_vid_src + "\n" + $j('#embed_vid').attr('src'));
 105+ js_log('set org_vid_time_req: ' + org_vid_time_req );
107106
108 - ebvid = $j('#embed_vid').get(0);
109 - //extend stop button on mv_embed:
 107+ ebvid = $j('#embed_vid').get(0);
110108 ebvid['inheritEmbedOverride']=function(){
111109 js_log('inheritEmbedOverride');
112 - if(typeof ebvid['org_eb_stop']=='undefined'){
113 - //js_log("pre stop: " +ebvid['stop'].toString());
 110+ //overide play button action to interface control:
 111+ $j('#big_play_link_embed_vid').attr('href', 'javascript:mv_do_play();');
 112+ //extend stop button on mv_embed:
 113+ js_log("pre stop: " +ebvid['stop'].toString() );
 114+ if(ebvid['stop'].toString()!='function(){mv_do_stop();}'){
114115 ebvid['org_eb_stop'] = ebvid['stop'];
115 - ebvid['stop'] = function(){
116 - mv_do_stop();
117 - }
118 - }
 116+ ebvid['stop'] = function(){mv_do_stop();}
 117+ }
 118+ js_log("post stop: " +ebvid['stop'].toString());
119119 }
120120 //call stop override
121121 ebvid.inheritEmbedOverride();
@@ -132,6 +132,7 @@
133133 //unlock the interface updates once everything is setup:
134134 mv_lock_vid_updates=false;
135135 js_log('done with mv_init_inerface');
 136+ $j('#embed_vid').get(0).stop();
136137 this.interfaceLoaded=true;
137138 },
138139 addHoverHooks:function(selector){
@@ -226,7 +227,8 @@
227228 //only restore if the cur_mvd = 'base' and interface updates are not locked
228229 if(this.cur_mvd_id=='base'){
229230 vid_elm.updateThumbnail(org_thum_src);
230 - vid_elm.updateVideoSrc(org_vid_src);
 231+ vid_elm.updateVideoTimeReq(org_vid_time_req);
 232+ //vid_elm.updateVideoSrc(org_vid_src);
231233 $j('#mv_videoPlayerTime').html(org_vid_title);
232234 }
233235 }
@@ -660,7 +662,7 @@
661663 //return false to prevent the form being submitted
662664 return false;
663665 }
664 -function mv_do_stop(){
 666+function mv_do_stop(){
665667 $j('#mv_videoPlayerTime').fadeIn('fast');
666668 //re-enable interface:
667669 mv_lock_vid_updates=false;
@@ -671,6 +673,7 @@
672674 //hide the controls thumbnail_disp
673675 mv_disp_play_controls(false);
674676 js_log('mv_do_stop');
 677+ //run the original stop:
675678 $j('#embed_vid').get(0).org_eb_stop();
676679 //re-rewrite the play button:
677680 $j('#big_play_link_embed_vid').attr('href', 'javascript:mv_do_play();');
@@ -788,13 +791,7 @@
789792 if(mv_lock_vid_updates==false){
790793 //update the vid title:
791794 $j('#mv_videoPlayerTime').html( start_time + ' to ' + end_time );
792 - if(org_vid_src.indexOf('?')!=-1){
793 - var url = org_vid_src.split('?');
794 - var new_vid_url = url[0] + '?t=' + start_time+'/'+end_time;
795 - //js_log("new vid url:" +new_vid_url);
796 - if(new_vid_url!=$j('#embed_vid').attr('src'))
797 - $j('#embed_vid').get(0).updateVideoSrc(new_vid_url);
798 - }
 795+ $j('#embed_vid').get(0).updateVideoTime(start_time, end_time);
799796 do_update_thumb(mvd_id, start_time);
800797 }
801798 }
Index: branches/MetavidWiki-exp/MetavidWiki/skins/mv_embed/mv_embed.js
@@ -290,9 +290,7 @@
291291 {
292292 players : null,
293293 preference : null,
294 -
295 - default_players : null,
296 -
 294+ default_players : null,
297295 init : function()
298296 {
299297 this.players = new Array();
@@ -863,11 +861,10 @@
864862 scrollTimerId:0,
865863 availableTracks:{},
866864 init:function(parentEmbed){
 865+ //set the parent embed object:
867866 this.pe=parentEmbed;
868 - //parse roe if not already done:
869 -
 867+ //parse roe if not already done:
870868 this.getParseCMML();
871 -
872869 //start the autoscroll timer:
873870 this.setAutoScroll(true);
874871 },
@@ -1142,8 +1139,7 @@
11431140 /** Duration of the requested segment (NaN if not known) */
11441141 duration:NaN,
11451142
1146 - id:null,
1147 -
 1143+ id:null,
11481144 start_ntp:null,
11491145 end_ntp:null,
11501146
@@ -1175,6 +1171,28 @@
11761172 js_log('Adding mediaSource of type ' + this.mime_type + ' and uri ' + this.uri + ' and title ' + this.title);
11771173 this.parseURLDuration();
11781174 },
 1175+ /** updates the src time and start & end
 1176+ * @param {String} start_time in NTP format
 1177+ * @param {String} end_time in NTP format
 1178+ */
 1179+ updateSrcTime:function(start_ntp, end_ntp){
 1180+ js_log("UPDATE src time: "+ start_ntp+'/'+ end_ntp);
 1181+ js_log("pre uri:" + this.uri);
 1182+ //if we have time we can use:
 1183+ if(this.start_ntp!=null){
 1184+ var index_time_val = false;
 1185+ var time_req_delimitator = '';
 1186+ if(this.uri.indexOf('?t=')!=-1)index_time_val='?t=';
 1187+ if(this.uri.indexOf('&t=')!=-1)index_time_val='&t=';
 1188+ if(index_time_val){
 1189+ var end_req_string = (this.uri.indexOf('&', this.uri.indexOf(index_time_val)+3)==-1)?
 1190+ '':
 1191+ this.uri.indexOf('&', this.uri.indexOf(index_time_val));
 1192+ this.uri = this.uri.substring(0, this.uri.indexOf(index_time_val) ) + index_time_val + start_ntp + '/'+end_ntp + end_req_string;
 1193+ }
 1194+ }
 1195+ js_log("post uri:" + this.uri);
 1196+ },
11791197 /** MIME type accessor function.
11801198 @return the MIME type of the source.
11811199 @type String
@@ -1209,8 +1227,8 @@
12101228 },
12111229 /*
12121230 * function getDuration in milliseconds
1213 - * special case derive duration from request url (in float seconds) @@todo should be float seconds
1214 - * (for media_url?t=ntp_start/ntp_end url request format
 1231+ * special case derive duration from request url
 1232+ * supports media_url?t=ntp_start/ntp_end url request format
12151233 */
12161234 parseURLDuration : function(){
12171235 //js_log('get duration for:' + this.uri);
@@ -1218,7 +1236,7 @@
12191237 if(this.uri.indexOf('?t=')!=-1)index_time_val='?t=';
12201238 if(this.uri.indexOf('&t=')!=-1)index_time_val='&t=';
12211239 if(index_time_val){
1222 - var end_index = (this.uri.indexOf('&', this.uri.indexOf(index_time_val))==-1)?
 1240+ var end_index = (this.uri.indexOf('&', this.uri.indexOf(index_time_val)+3)==-1)?
12231241 this.uri.length:
12241242 this.uri.indexOf('&', this.uri.indexOf(index_time_val));
12251243 this.start_ntp = this.uri.substring(
@@ -1279,8 +1297,7 @@
12801298 /** @private */
12811299 init:function(video_element)
12821300 {
1283 - var _this = this;
1284 -
 1301+ var _this = this;
12851302 js_log('Initializing mediaElement...');
12861303 this.sources = new Array();
12871304 this.thumbnail = mv_default_thumb_url;
@@ -1296,12 +1313,14 @@
12971314 {
12981315 _this.tryAddSource(inner_source);
12991316 });
1300 - // Process the provided ROE file if any
 1317+ // Process the provided ROE file... if we don't yet have sources or a thumbnail
13011318 if(video_element.hasAttribute('roe'))
1302 - do_request(video_element.getAttribute('roe'), function(data)
1303 - {
1304 - _this.addROE(data);
1305 - });
 1319+ if(this.sources.length==0 ||this.thumbnail == mv_default_thumb_url ){
 1320+ do_request(video_element.getAttribute('roe'), function(data)
 1321+ {
 1322+ _this.addROE(data);
 1323+ });
 1324+ }
13061325 // Select the default source
13071326 for (var source in this.sources)
13081327 if(this.sources[source].marked_default)
@@ -1313,6 +1332,14 @@
13141333 this.selected_source = this.sources[0];
13151334 }
13161335 },
 1336+ /** Updates the time request for all sources that have a standard time request argument (ie &t=start_time/end_time)
 1337+ */
 1338+ updateSourceTimes:function(start_time, end_time){
 1339+ var _this = this;
 1340+ $j.each(this.sources, function(inx, mediaSource){
 1341+ mediaSource.updateSrcTime(start_time, end_time);
 1342+ });
 1343+ },
13171344 /** Returns the array of mediaSources of this element.
13181345 \returns {Array} Array of mediaSource elements.
13191346 */
@@ -1355,7 +1382,6 @@
13561383 {
13571384 if (!element.hasAttribute('src'))
13581385 return;
1359 -
13601386 this.sources.push(new mediaSource(element));
13611387 },
13621388 /** Imports media sources from ROE data.
@@ -1469,14 +1495,16 @@
14701496 //return this object:
14711497 return this;
14721498 },
 1499+ getTimeReq:function(){
 1500+ return this.media_element.selected_source.start_ntp+'/'+this.media_element.selected_source.end_ntp;
 1501+ },
14731502 getDuration:function(){
14741503 return this.media_element.selected_source.duration;
14751504 },
14761505 /* get the duration in ntp format */
14771506 getDurationNTP:function(){
14781507 return seconds2ntp(this.getDuration()/1000);
1479 - },
1480 -
 1508+ },
14811509 doEmbedHTML:function()
14821510 {
14831511 this.inheritEmbedObj();
@@ -1538,8 +1566,17 @@
15391567 }
15401568 return out + '</div>';
15411569 },
 1570+ updateVideoTimeReq:function(time_req){
 1571+ var time_parts =time_req.split('/');
 1572+ this.updateVideoTime(time_parts[0], time_parts[1]);
 1573+ },
 1574+ //update video time
 1575+ updateVideoTime:function(start_time, end_time){
 1576+ this.media_element.updateSourceTimes(start_time, end_time);
 1577+ },
15421578 //updates the video src
15431579 updateVideoSrc : function(src){
 1580+ js_log("UPDATE SRC:"+src);
15441581 this.src = src;
15451582 },
15461583 //updates the thumbnail if the thumbnail is being displayed

Status & tagging log