Index: branches/MetavidWiki-exp/MetavidWiki/skins/mv_stream.js |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | * also assumes scriptaculus is included in the mv_embed distribution |
21 | 21 | * /skins/mv_embed/scriptaculous |
22 | 22 | */ |
23 | | -var org_vid_src = null; //stores the original video src |
| 23 | +var org_vid_time_req =null; //store the orginal time req: |
24 | 24 | var org_thum_src = null; //stores the original thumbnail src |
25 | 25 | var org_vid_title = null; //stores the original title |
26 | 26 | //store the original range request: |
— | — | @@ -91,30 +91,30 @@ |
92 | 92 | //set up the init values for mouse over restore: |
93 | 93 | org_vid_title = $j('#mv_stream_time').html(); |
94 | 94 | if(!$j('#embed_vid').get(0)){ |
95 | | - //no embed video present stop init |
| 95 | + //no embed video present stop init |
96 | 96 | return ''; |
97 | 97 | } |
98 | | - org_vid_src = $j('#embed_vid').get(0).src; |
| 98 | + org_vid_time_req = $j('#embed_vid').get(0).getTimeReq(); |
99 | 99 | 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 | + |
102 | 101 | //@@TODO override stop function in player: |
103 | 102 | |
104 | 103 | //current range or search parameter |
105 | 104 | 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 ); |
107 | 106 | |
108 | | - ebvid = $j('#embed_vid').get(0); |
109 | | - //extend stop button on mv_embed: |
| 107 | + ebvid = $j('#embed_vid').get(0); |
110 | 108 | ebvid['inheritEmbedOverride']=function(){ |
111 | 109 | 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();}'){ |
114 | 115 | 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()); |
119 | 119 | } |
120 | 120 | //call stop override |
121 | 121 | ebvid.inheritEmbedOverride(); |
— | — | @@ -132,6 +132,7 @@ |
133 | 133 | //unlock the interface updates once everything is setup: |
134 | 134 | mv_lock_vid_updates=false; |
135 | 135 | js_log('done with mv_init_inerface'); |
| 136 | + $j('#embed_vid').get(0).stop(); |
136 | 137 | this.interfaceLoaded=true; |
137 | 138 | }, |
138 | 139 | addHoverHooks:function(selector){ |
— | — | @@ -226,7 +227,8 @@ |
227 | 228 | //only restore if the cur_mvd = 'base' and interface updates are not locked |
228 | 229 | if(this.cur_mvd_id=='base'){ |
229 | 230 | 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); |
231 | 233 | $j('#mv_videoPlayerTime').html(org_vid_title); |
232 | 234 | } |
233 | 235 | } |
— | — | @@ -660,7 +662,7 @@ |
661 | 663 | //return false to prevent the form being submitted |
662 | 664 | return false; |
663 | 665 | } |
664 | | -function mv_do_stop(){ |
| 666 | +function mv_do_stop(){ |
665 | 667 | $j('#mv_videoPlayerTime').fadeIn('fast'); |
666 | 668 | //re-enable interface: |
667 | 669 | mv_lock_vid_updates=false; |
— | — | @@ -671,6 +673,7 @@ |
672 | 674 | //hide the controls thumbnail_disp |
673 | 675 | mv_disp_play_controls(false); |
674 | 676 | js_log('mv_do_stop'); |
| 677 | + //run the original stop: |
675 | 678 | $j('#embed_vid').get(0).org_eb_stop(); |
676 | 679 | //re-rewrite the play button: |
677 | 680 | $j('#big_play_link_embed_vid').attr('href', 'javascript:mv_do_play();'); |
— | — | @@ -788,13 +791,7 @@ |
789 | 792 | if(mv_lock_vid_updates==false){ |
790 | 793 | //update the vid title: |
791 | 794 | $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); |
799 | 796 | do_update_thumb(mvd_id, start_time); |
800 | 797 | } |
801 | 798 | } |
Index: branches/MetavidWiki-exp/MetavidWiki/skins/mv_embed/mv_embed.js |
— | — | @@ -290,9 +290,7 @@ |
291 | 291 | { |
292 | 292 | players : null, |
293 | 293 | preference : null, |
294 | | - |
295 | | - default_players : null, |
296 | | - |
| 294 | + default_players : null, |
297 | 295 | init : function() |
298 | 296 | { |
299 | 297 | this.players = new Array(); |
— | — | @@ -863,11 +861,10 @@ |
864 | 862 | scrollTimerId:0, |
865 | 863 | availableTracks:{}, |
866 | 864 | init:function(parentEmbed){ |
| 865 | + //set the parent embed object: |
867 | 866 | this.pe=parentEmbed; |
868 | | - //parse roe if not already done: |
869 | | - |
| 867 | + //parse roe if not already done: |
870 | 868 | this.getParseCMML(); |
871 | | - |
872 | 869 | //start the autoscroll timer: |
873 | 870 | this.setAutoScroll(true); |
874 | 871 | }, |
— | — | @@ -1142,8 +1139,7 @@ |
1143 | 1140 | /** Duration of the requested segment (NaN if not known) */ |
1144 | 1141 | duration:NaN, |
1145 | 1142 | |
1146 | | - id:null, |
1147 | | - |
| 1143 | + id:null, |
1148 | 1144 | start_ntp:null, |
1149 | 1145 | end_ntp:null, |
1150 | 1146 | |
— | — | @@ -1175,6 +1171,28 @@ |
1176 | 1172 | js_log('Adding mediaSource of type ' + this.mime_type + ' and uri ' + this.uri + ' and title ' + this.title); |
1177 | 1173 | this.parseURLDuration(); |
1178 | 1174 | }, |
| 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 | + }, |
1179 | 1197 | /** MIME type accessor function. |
1180 | 1198 | @return the MIME type of the source. |
1181 | 1199 | @type String |
— | — | @@ -1209,8 +1227,8 @@ |
1210 | 1228 | }, |
1211 | 1229 | /* |
1212 | 1230 | * 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 |
1215 | 1233 | */ |
1216 | 1234 | parseURLDuration : function(){ |
1217 | 1235 | //js_log('get duration for:' + this.uri); |
— | — | @@ -1218,7 +1236,7 @@ |
1219 | 1237 | if(this.uri.indexOf('?t=')!=-1)index_time_val='?t='; |
1220 | 1238 | if(this.uri.indexOf('&t=')!=-1)index_time_val='&t='; |
1221 | 1239 | 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)? |
1223 | 1241 | this.uri.length: |
1224 | 1242 | this.uri.indexOf('&', this.uri.indexOf(index_time_val)); |
1225 | 1243 | this.start_ntp = this.uri.substring( |
— | — | @@ -1279,8 +1297,7 @@ |
1280 | 1298 | /** @private */ |
1281 | 1299 | init:function(video_element) |
1282 | 1300 | { |
1283 | | - var _this = this; |
1284 | | - |
| 1301 | + var _this = this; |
1285 | 1302 | js_log('Initializing mediaElement...'); |
1286 | 1303 | this.sources = new Array(); |
1287 | 1304 | this.thumbnail = mv_default_thumb_url; |
— | — | @@ -1296,12 +1313,14 @@ |
1297 | 1314 | { |
1298 | 1315 | _this.tryAddSource(inner_source); |
1299 | 1316 | }); |
1300 | | - // Process the provided ROE file if any |
| 1317 | + // Process the provided ROE file... if we don't yet have sources or a thumbnail |
1301 | 1318 | 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 | + } |
1306 | 1325 | // Select the default source |
1307 | 1326 | for (var source in this.sources) |
1308 | 1327 | if(this.sources[source].marked_default) |
— | — | @@ -1313,6 +1332,14 @@ |
1314 | 1333 | this.selected_source = this.sources[0]; |
1315 | 1334 | } |
1316 | 1335 | }, |
| 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 | + }, |
1317 | 1344 | /** Returns the array of mediaSources of this element. |
1318 | 1345 | \returns {Array} Array of mediaSource elements. |
1319 | 1346 | */ |
— | — | @@ -1355,7 +1382,6 @@ |
1356 | 1383 | { |
1357 | 1384 | if (!element.hasAttribute('src')) |
1358 | 1385 | return; |
1359 | | - |
1360 | 1386 | this.sources.push(new mediaSource(element)); |
1361 | 1387 | }, |
1362 | 1388 | /** Imports media sources from ROE data. |
— | — | @@ -1469,14 +1495,16 @@ |
1470 | 1496 | //return this object: |
1471 | 1497 | return this; |
1472 | 1498 | }, |
| 1499 | + getTimeReq:function(){ |
| 1500 | + return this.media_element.selected_source.start_ntp+'/'+this.media_element.selected_source.end_ntp; |
| 1501 | + }, |
1473 | 1502 | getDuration:function(){ |
1474 | 1503 | return this.media_element.selected_source.duration; |
1475 | 1504 | }, |
1476 | 1505 | /* get the duration in ntp format */ |
1477 | 1506 | getDurationNTP:function(){ |
1478 | 1507 | return seconds2ntp(this.getDuration()/1000); |
1479 | | - }, |
1480 | | - |
| 1508 | + }, |
1481 | 1509 | doEmbedHTML:function() |
1482 | 1510 | { |
1483 | 1511 | this.inheritEmbedObj(); |
— | — | @@ -1538,8 +1566,17 @@ |
1539 | 1567 | } |
1540 | 1568 | return out + '</div>'; |
1541 | 1569 | }, |
| 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 | + }, |
1542 | 1578 | //updates the video src |
1543 | 1579 | updateVideoSrc : function(src){ |
| 1580 | + js_log("UPDATE SRC:"+src); |
1544 | 1581 | this.src = src; |
1545 | 1582 | }, |
1546 | 1583 | //updates the thumbnail if the thumbnail is being displayed |