Index: branches/MetavidWiki-exp/MetavidWiki/skins/mv_embed/mv_embed.js |
— | — | @@ -1133,15 +1133,9 @@ |
1134 | 1134 | * @param {String} uri URI of the source. |
1135 | 1135 | * @constructor |
1136 | 1136 | */ |
1137 | | -function mediaSource(mime_type, uri, title, marked_default) |
| 1137 | +function mediaSource(element) |
1138 | 1138 | { |
1139 | | - js_log('Adding mediaSource of type ' + mime_type + ' and uri ' + uri + ' and title ' + title); |
1140 | | - this.mime_type = mime_type; |
1141 | | - this.uri = uri; |
1142 | | - this.title = title; |
1143 | | - this.marked_default = marked_default; |
1144 | | - this.parseURLDuration(); |
1145 | | - return this; |
| 1139 | + this.init(element); |
1146 | 1140 | } |
1147 | 1141 | |
1148 | 1142 | mediaSource.prototype = |
— | — | @@ -1162,7 +1156,32 @@ |
1163 | 1157 | start_ntp:null, |
1164 | 1158 | end_ntp:null, |
1165 | 1159 | |
1166 | | - |
| 1160 | + init : function(element) |
| 1161 | + { |
| 1162 | + this.uri = element.getAttribute('src'); |
| 1163 | + if(ogg_chop_links) |
| 1164 | + this.uri = this.uri.replace(".anx", ''); |
| 1165 | + this.marked_default = false; |
| 1166 | + |
| 1167 | + var tag = element.tagName.toLowerCase(); |
| 1168 | + |
| 1169 | + if (tag == 'video') |
| 1170 | + this.marked_default = true; |
| 1171 | + |
| 1172 | + if (element.hasAttribute("title")) |
| 1173 | + this.title = element.getAttribute("title"); |
| 1174 | + else |
| 1175 | + this.title = this.uri; |
| 1176 | + |
| 1177 | + if (element.hasAttribute('type')) |
| 1178 | + this.mime_type = element.getAttribute('type'); |
| 1179 | + else if (element.hasAttribute('content-type')) |
| 1180 | + this.mime_type = element.getAttribute('content-type'); |
| 1181 | + else |
| 1182 | + this.mime_type = this.detectType(this.uri); |
| 1183 | + js_log('Adding mediaSource of type ' + this.mime_type + ' and uri ' + this.uri + ' and title ' + this.title); |
| 1184 | + this.parseURLDuration(); |
| 1185 | + }, |
1167 | 1186 | /** MIME type accessor function. |
1168 | 1187 | @return the MIME type of the source. |
1169 | 1188 | @type String |
— | — | @@ -1229,7 +1248,16 @@ |
1230 | 1249 | getDurationNTP:function(){ |
1231 | 1250 | return seconds2ntp(this.getDuration()/1000); |
1232 | 1251 | }, |
1233 | | - |
| 1252 | + /** Attempts to detect the type of a media file based on the URI. |
| 1253 | + @param {String} uri URI of the media file. |
| 1254 | + @returns The guessed MIME type of the file. |
| 1255 | + @type String |
| 1256 | + */ |
| 1257 | + detectType:function(uri) |
| 1258 | + { |
| 1259 | + if(endsWith(uri, '.flv')) |
| 1260 | + return 'video/x-flv'; |
| 1261 | + } |
1234 | 1262 | }; |
1235 | 1263 | |
1236 | 1264 | /** A media element corresponding to a <video> element. |
— | — | @@ -1338,29 +1366,7 @@ |
1339 | 1367 | if (!element.hasAttribute('src')) |
1340 | 1368 | return; |
1341 | 1369 | |
1342 | | - var src = element.getAttribute('src'); |
1343 | | - var title = null; |
1344 | | - var type = null; |
1345 | | - var marked_default = false; |
1346 | | - |
1347 | | - var tag = element.tagName.toLowerCase(); |
1348 | | - |
1349 | | - if (tag == 'src') |
1350 | | - marked_default = true; |
1351 | | - |
1352 | | - if (element.hasAttribute("title")) |
1353 | | - title = element.getAttribute("title"); |
1354 | | - else |
1355 | | - title = src; |
1356 | | - |
1357 | | - if (element.hasAttribute('type')) |
1358 | | - type = element.getAttribute('type'); |
1359 | | - else if (element.hasAttribute('content-type')) |
1360 | | - type = element.getAttribute('content-type'); |
1361 | | - else |
1362 | | - type = this.detectType(src); |
1363 | | - |
1364 | | - this.sources.push(new mediaSource(type, src, title, marked_default)); |
| 1370 | + this.sources.push(new mediaSource(element)); |
1365 | 1371 | }, |
1366 | 1372 | /** Imports media sources from ROE data. |
1367 | 1373 | @param roe_data ROE data. |
— | — | @@ -1373,16 +1379,6 @@ |
1374 | 1380 | _this.tryAddSource(source); |
1375 | 1381 | }); |
1376 | 1382 | }, |
1377 | | - /** Attempts to detect the type of a media file based on the URI. |
1378 | | - @param {String} uri URI of the media file. |
1379 | | - @returns The guessed MIME type of the file. |
1380 | | - @type String |
1381 | | - */ |
1382 | | - detectType:function(uri) |
1383 | | - { |
1384 | | - if(endsWith(uri, '.flv')) |
1385 | | - return 'video/x-flv'; |
1386 | | - } |
1387 | 1383 | }; |
1388 | 1384 | |
1389 | 1385 | function endsWith(str, suffix) |
— | — | @@ -1763,12 +1759,11 @@ |
1764 | 1760 | var out='<b style="color:white;">'+getMsg('download_from')+' '+parseUri(this.src).queryKey['t']+'</b><br>'; |
1765 | 1761 | out+='<span style="color:white"><blockquote>'; |
1766 | 1762 | var dl_list=dl_txt_list=''; |
1767 | | - $j.each(this.roe_xml.getElementsByTagName('mediaSource'), function(inx,n){ |
1768 | | - var dl_line = '<li><a style="color:white" href="' |
1769 | | - dl_line+=(ogg_chop_links)?n.getAttribute("src").replace(".anx", ''):n.getAttribute("src"); |
1770 | | - dl_line+='"> '+n.getAttribute("title")+'</a></li>'+"\n"; |
1771 | | - if(n.getAttribute("content-type")=="video/ogg"){ |
1772 | | - out+=dl_line; |
| 1763 | + $j.each(this.media_element.getSources(), function(index, source) |
| 1764 | + { |
| 1765 | + var dl_line = '<li>' + transform_function(index, source) + '</li>'+"\n"; |
| 1766 | + if(this.getMIMEType()=="video/ogg"){ |
| 1767 | + out+=dl_line; |
1773 | 1768 | }else if(this.getMIMEType()=="text/cmml"){ |
1774 | 1769 | dl_txt_list+=dl_line; |
1775 | 1770 | }else{ |