Index: trunk/extensions/MetavidWiki/skins/mv_embed/embedLibs/mv_flashEmbed.js |
— | — | @@ -169,20 +169,28 @@ |
170 | 170 | if(!this.fla['getTime']) |
171 | 171 | return js_log('can not monitor without time'); |
172 | 172 | |
173 | | - this.currentTime = this.fla.getTime(); |
| 173 | + this.currentTime = this.fla.getTime(); |
174 | 174 | |
175 | 175 | if(this.currentTime > 1 && !this.startedTimedPlayback){ |
176 | 176 | 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 | + } |
179 | 185 | |
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 | + |
182 | 190 | 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 | + |
187 | 195 | if(!this.userSlide){ |
188 | 196 | if((this.currentTime - ntp2seconds(start_ntp))<0){ |
189 | 197 | this.setStatus('buffering...'); |
— | — | @@ -193,7 +201,7 @@ |
194 | 202 | } |
195 | 203 | |
196 | 204 | //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)) ){ |
198 | 206 | js_log('probablly reached end of stream: '+this.currentTime); |
199 | 207 | this.onClipDone(); |
200 | 208 | } |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/mv_embed.js |
— | — | @@ -1481,6 +1481,8 @@ |
1482 | 1482 | title:null, |
1483 | 1483 | /** True if the source has been marked as the default. */ |
1484 | 1484 | marked_default:null, |
| 1485 | + /** True if the source supports url specification of offset and duration */ |
| 1486 | + supports_url_time_encoding:null, |
1485 | 1487 | /** Start offset of the requested segment */ |
1486 | 1488 | start_offset:null, |
1487 | 1489 | /** Duration of the requested segment (NaN if not known) */ |
— | — | @@ -1548,7 +1550,7 @@ |
1549 | 1551 | js_log("f:updateSrcTime: "+ start_ntp+'/'+ end_ntp); |
1550 | 1552 | //js_log("pre uri:" + this.src); |
1551 | 1553 | //if we have time we can use: |
1552 | | - if(this.start_ntp!=null){ |
| 1554 | + if(this.supports_url_time_encoding){ |
1553 | 1555 | var index_time_val = false; |
1554 | 1556 | var time_req_delimitator = ''; |
1555 | 1557 | if(this.src.indexOf('?t=')!=-1)index_time_val='?t='; |
— | — | @@ -1559,11 +1561,17 @@ |
1560 | 1562 | this.src.indexOf('&', this.src.indexOf(index_time_val)); |
1561 | 1563 | this.src = this.src.substring(0, this.src.indexOf(index_time_val) ) + index_time_val + start_ntp + '/'+end_ntp + end_req_string; |
1562 | 1564 | } |
| 1565 | + this.parseURLDuration(); |
1563 | 1566 | } |
| 1567 | + |
1564 | 1568 | //update the duration |
1565 | | - this.parseURLDuration(); |
1566 | 1569 | //js_log("post uri:" + this.src); |
1567 | 1570 | }, |
| 1571 | + setDuration:function (duration) |
| 1572 | + { |
| 1573 | + this.duration = duration; |
| 1574 | + this.end_ntp = seconds2ntp(this.start_offset + duration); |
| 1575 | + }, |
1568 | 1576 | /** MIME type accessor function. |
1569 | 1577 | @return the MIME type of the source. |
1570 | 1578 | @type String |
— | — | @@ -1623,10 +1631,13 @@ |
1624 | 1632 | this.duration = ntp2seconds( this.end_ntp ) - this.start_offset; |
1625 | 1633 | |
1626 | 1634 | this.duration = this.duration; |
| 1635 | + this.supports_url_time_encoding = true; |
1627 | 1636 | }else{ |
1628 | 1637 | //else normal media request (can't predict the duration without the plugin reading it) |
1629 | 1638 | this.duration=null; |
1630 | 1639 | this.start_offset=0; |
| 1640 | + this.start_ntp=seconds2ntp(this.start_offset); |
| 1641 | + this.supports_url_time_encoding = false; |
1631 | 1642 | } |
1632 | 1643 | }, |
1633 | 1644 | /** Attempts to detect the type of a media file based on the URI. |
— | — | @@ -2089,7 +2100,7 @@ |
2090 | 2101 | return default_time_req; |
2091 | 2102 | if(!this.media_element.selected_source) |
2092 | 2103 | return default_time_req; |
2093 | | - if(!this.media_element.selected_source.start_ntp) |
| 2104 | + if(!this.media_element.selected_source.end_ntp) |
2094 | 2105 | return default_time_req; |
2095 | 2106 | return this.media_element.selected_source.start_ntp+'/'+this.media_element.selected_source.end_ntp; |
2096 | 2107 | }, |
— | — | @@ -2437,7 +2448,10 @@ |
2438 | 2449 | //reset slider |
2439 | 2450 | this.setSliderValue(0); |
2440 | 2451 | //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); |
2442 | 2456 | }, |
2443 | 2457 | //updates the video src |
2444 | 2458 | updateVideoSrc : function(src){ |