r36583 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r36582‎ | r36583 | r36584 >
Date:21:07, 23 June 2008
Author:stipe
Status:old
Tags:
Comment:
moved mediaSource construction code and ogg_chop_link modification to mediaSource init function
Modified paths:
  • /branches/MetavidWiki-exp/MetavidWiki/skins/mv_embed/mv_embed.js (modified) (history)

Diff [purge]

Index: branches/MetavidWiki-exp/MetavidWiki/skins/mv_embed/mv_embed.js
@@ -1133,15 +1133,9 @@
11341134 * @param {String} uri URI of the source.
11351135 * @constructor
11361136 */
1137 -function mediaSource(mime_type, uri, title, marked_default)
 1137+function mediaSource(element)
11381138 {
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);
11461140 }
11471141
11481142 mediaSource.prototype =
@@ -1162,7 +1156,32 @@
11631157 start_ntp:null,
11641158 end_ntp:null,
11651159
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+ },
11671186 /** MIME type accessor function.
11681187 @return the MIME type of the source.
11691188 @type String
@@ -1229,7 +1248,16 @@
12301249 getDurationNTP:function(){
12311250 return seconds2ntp(this.getDuration()/1000);
12321251 },
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+ }
12341262 };
12351263
12361264 /** A media element corresponding to a <video> element.
@@ -1338,29 +1366,7 @@
13391367 if (!element.hasAttribute('src'))
13401368 return;
13411369
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));
13651371 },
13661372 /** Imports media sources from ROE data.
13671373 @param roe_data ROE data.
@@ -1373,16 +1379,6 @@
13741380 _this.tryAddSource(source);
13751381 });
13761382 },
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 - }
13871383 };
13881384
13891385 function endsWith(str, suffix)
@@ -1763,12 +1759,11 @@
17641760 var out='<b style="color:white;">'+getMsg('download_from')+' '+parseUri(this.src).queryKey['t']+'</b><br>';
17651761 out+='<span style="color:white"><blockquote>';
17661762 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;
17731768 }else if(this.getMIMEType()=="text/cmml"){
17741769 dl_txt_list+=dl_line;
17751770 }else{

Status & tagging log