Index: branches/MetavidWiki-exp/MetavidWiki/skins/mv_embed/mv_embed.js |
— | — | @@ -1138,6 +1138,7 @@ |
1139 | 1139 | start_offset:null, |
1140 | 1140 | /** Duration of the requested segment (NaN if not known) */ |
1141 | 1141 | duration:NaN, |
| 1142 | + is_playable:null, |
1142 | 1143 | |
1143 | 1144 | id:null, |
1144 | 1145 | start_ntp:null, |
— | — | @@ -1155,19 +1156,25 @@ |
1156 | 1157 | if (tag == 'video') |
1157 | 1158 | this.marked_default = true; |
1158 | 1159 | |
| 1160 | + if (element.hasAttribute('type')) |
| 1161 | + this.mime_type = element.getAttribute('type'); |
| 1162 | + else if (element.hasAttribute('content-type')) |
| 1163 | + this.mime_type = element.getAttribute('content-type'); |
| 1164 | + else |
| 1165 | + this.mime_type = this.detectType(this.uri); |
| 1166 | + |
1159 | 1167 | if (element.hasAttribute("title")) |
1160 | 1168 | this.title = element.getAttribute("title"); |
1161 | 1169 | else |
1162 | | - this.title = this.uri; |
| 1170 | + { |
| 1171 | + var parts = this.mime_type.split("/",2); |
| 1172 | + parts[0]=parts[0].replace('video', 'stream'); |
| 1173 | + parts[1]=parts[1].replace('x-flv', 'flash'); |
| 1174 | + this.title = parts[1] + ' ' + parts[0]; |
| 1175 | + } |
1163 | 1176 | if (element.hasAttribute("id")) |
1164 | 1177 | this.id = element.getAttribute("id"); |
1165 | 1178 | |
1166 | | - if (element.hasAttribute('type')) |
1167 | | - this.mime_type = element.getAttribute('type'); |
1168 | | - else if (element.hasAttribute('content-type')) |
1169 | | - this.mime_type = element.getAttribute('content-type'); |
1170 | | - else |
1171 | | - this.mime_type = this.detectType(this.uri); |
1172 | 1179 | js_log('Adding mediaSource of type ' + this.mime_type + ' and uri ' + this.uri + ' and title ' + this.title); |
1173 | 1180 | this.parseURLDuration(); |
1174 | 1181 | }, |
— | — | @@ -1289,6 +1296,8 @@ |
1290 | 1297 | { |
1291 | 1298 | /** The array of mediaSource elements. */ |
1292 | 1299 | sources:null, |
| 1300 | + /** Playable sources **/ |
| 1301 | + playable_sources:null, |
1293 | 1302 | /** Selected mediaSource element. */ |
1294 | 1303 | selected_source:null, |
1295 | 1304 | thumbnail:null, |
— | — | @@ -1300,6 +1309,7 @@ |
1301 | 1310 | var _this = this; |
1302 | 1311 | js_log('Initializing mediaElement...'); |
1303 | 1312 | this.sources = new Array(); |
| 1313 | + this.playable_sources = new Array(); |
1304 | 1314 | this.thumbnail = mv_default_thumb_url; |
1305 | 1315 | // Process the <video> element |
1306 | 1316 | this.tryAddSource(video_element); |
— | — | @@ -1322,14 +1332,14 @@ |
1323 | 1333 | }); |
1324 | 1334 | } |
1325 | 1335 | // Select the default source |
1326 | | - for (var source in this.sources) |
1327 | | - if(this.sources[source].marked_default) |
1328 | | - this.selected_source = this.sources[source]; |
| 1336 | + for (var source in this.playable_sources) |
| 1337 | + if(this.playable_sources[source].marked_default) |
| 1338 | + this.selected_source = this.playable_sources[source]; |
1329 | 1339 | // or the first source |
1330 | 1340 | if (!this.selected_source) |
1331 | 1341 | { |
1332 | 1342 | js_log('autoselecting first source'); |
1333 | | - this.selected_source = this.sources[0]; |
| 1343 | + this.selected_source = this.playable_sources[0]; |
1334 | 1344 | } |
1335 | 1345 | }, |
1336 | 1346 | /** Updates the time request for all sources that have a standard time request argument (ie &t=start_time/end_time) |
— | — | @@ -1374,6 +1384,10 @@ |
1375 | 1385 | } |
1376 | 1386 | return false; |
1377 | 1387 | }, |
| 1388 | + isPlayableType:function(mime_type) |
| 1389 | + { |
| 1390 | + return mime_type=='video/ogg' || mime_type=='video/annodex' || mime_type=='video/x-flv'; |
| 1391 | + }, |
1378 | 1392 | /** Adds a single mediaSource using the provided element if |
1379 | 1393 | the element has a 'src' attribute. |
1380 | 1394 | @param element {element} <video>, <source> or <mediaSource> element. |
— | — | @@ -1382,7 +1396,10 @@ |
1383 | 1397 | { |
1384 | 1398 | if (!element.hasAttribute('src')) |
1385 | 1399 | return; |
1386 | | - this.sources.push(new mediaSource(element)); |
| 1400 | + var source = new mediaSource(element); |
| 1401 | + this.sources.push(source); |
| 1402 | + if(this.isPlayableType(source.mime_type)) |
| 1403 | + this.playable_sources.push(source); |
1387 | 1404 | }, |
1388 | 1405 | /** Imports media sources from ROE data. |
1389 | 1406 | @param roe_data ROE data. |
— | — | @@ -1818,20 +1835,36 @@ |
1819 | 1836 | }, |
1820 | 1837 | selectPlaybackMethod:function(){ |
1821 | 1838 | var _this=this; |
1822 | | - var select_code=this.getDLlist(function(index, source) |
| 1839 | + var select_code=this.getPlaybackMethodList(function(index, source) |
1823 | 1840 | { |
1824 | 1841 | var default_player = embedTypes.players.defaultPlayer(source.getMIMEType()); |
1825 | 1842 | var source_select_code = 'document.getElementById(\''+_this.id+'\').closeDisplayedHTML(); document.getElementById(\''+_this.id+'\').media_element.selectSource(\''+index+'\');'; |
1826 | 1843 | var player_code = _this.getPlayerSelectList(source.getMIMEType(), index, source_select_code); |
| 1844 | + var is_not_selected = (source != _this.media_element.selected_source); |
1827 | 1845 | if (default_player) |
1828 | | - return '<a href="#" onClick="' + source_select_code + 'embedTypes.players.userSelectPlayer(\''+default_player.id+'\',\''+source.getMIMEType()+'\'); return false;">' |
1829 | | - + source.getTitle()+' - ' + default_player.getName() + '</a> ' |
1830 | | - + '(<a href="#" onClick=\'$j("#player_select_list_'+index+'").fadeIn("slow");return false;\'>choose player</a>)' + player_code; |
| 1846 | + { |
| 1847 | + var retval = ''; |
| 1848 | + if(is_not_selected) |
| 1849 | + retval+='<a href="#" onClick="' + source_select_code + 'embedTypes.players.userSelectPlayer(\''+default_player.id+'\',\''+source.getMIMEType()+'\'); return false;">'; |
| 1850 | + retval += source.getTitle()+' - ' + default_player.getName() + (is_not_selected?'</a>':'') + ' '; |
| 1851 | + retval += '(<a href="#" onClick=\'$j("#player_select_list_'+index+'").fadeIn("slow");return false;\'>choose player</a>)' + player_code; |
| 1852 | + return retval; |
| 1853 | + } |
1831 | 1854 | else |
1832 | 1855 | return source.getTitle() + ' - no player available'; |
1833 | 1856 | }); |
1834 | 1857 | this.displayHTML(select_code); |
1835 | 1858 | }, |
| 1859 | + getPlaybackMethodList:function(transform_function){ |
| 1860 | + var out='<span style="color:white"><blockquote>'; |
| 1861 | + var _this=this; |
| 1862 | + $j.each(this.media_element.playable_sources, function(index, source) |
| 1863 | + { |
| 1864 | + out+='<li>' + transform_function(index, source) + '</li>'+"\n"; |
| 1865 | + }); |
| 1866 | + out+='</blockquote></span>'; |
| 1867 | + return out; |
| 1868 | + }, |
1836 | 1869 | showVideoDownload:function(){ |
1837 | 1870 | var select_code=this.getDLlist(function(index, source) |
1838 | 1871 | { |
— | — | @@ -1840,11 +1873,8 @@ |
1841 | 1874 | }); |
1842 | 1875 | this.displayHTML(select_code); |
1843 | 1876 | }, |
1844 | | - /* |
1845 | | - * Its pretty confusing to merge getDLlist with selectPlaybackMethod |
1846 | | - */ |
1847 | 1877 | getDLlist:function(transform_function){ |
1848 | | - var out='<b style="color:white;">'+getMsg('download_from')+' '+parseUri(this.src).queryKey['t']+'</b><br>'; |
| 1878 | + var out='<b style="color:white;">'+getMsg('download_from')/*+' '+parseUri(this.src).queryKey['t']*/+'</b><br>'; |
1849 | 1879 | out+='<span style="color:white"><blockquote>'; |
1850 | 1880 | var dl_list=dl_txt_list=''; |
1851 | 1881 | $j.each(this.media_element.getSources(), function(index, source) |