r40111 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r40110‎ | r40111 | r40112 >
Date:21:44, 27 August 2008
Author:dale
Status:old
Tags:
Comment:
updates to mv_embed
better support for firefox native video
bug fixes
Modified paths:
  • /trunk/extensions/MetavidWiki/skins/mv_embed/embedLibs/mv_flashEmbed.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/embedLibs/mv_genericEmbed.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/embedLibs/mv_nativeEmbed.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/embedLibs/mv_vlcEmbed.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/example_usage/sample_page.php (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/mv_data_proxy.php (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/mv_embed.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/mv_playlist.js (modified) (history)

Diff [purge]

Index: trunk/extensions/MetavidWiki/skins/mv_embed/example_usage/sample_page.php
@@ -61,10 +61,9 @@
6262 $sample_embed[3]['desc'] = 'Demo2 of json ROE attribute';
6363
6464
65 -//$sample_embed[2]['tag'] = '<video id="v2" controls="true" roe="http://mammoth.dnip.net/mvWiki/index.php?title=Special:MvExportStream&feed_format=roe&stream_name=senate_11-14-05&t=0:42:14/0:42:56"></video>';
66 -//$sample_embed[2]['desc'] = 'video with controls and thumbnail';
 65+$sample_embed[2]['tag'] = '<video id="v2" controls="true" src="sample_fish.ogg" poster="sample_fish.jpg"></video>';
 66+$sample_embed[2]['desc'] = 'simple video with controls and thumbnail';
6767
68 -
6968 //playlist tags:
7069 $sample_embed[4]['tag'] = '<playlist id="playlist1" width="400" height="300"
7170 src="sample_xspf.xml" controls="true" embed_link="true"/>';
@@ -108,7 +107,6 @@
109108 $sample_embed[7]['desc'] = '<b>Inline Playlist:</b> for more info see <a href="http://metavid.ucsc.edu/wiki/index.php/Mv_embed">mv_embed wiki</a> page';
110109
111110 //real video sample:
112 -//
113111 $smilURL = 'sample_smil.smil.xml';
114112 $sample_embed[8]['tag']= '<playlist id="smil_pl" src="'.$smilURL.'">';
115113 $sample_embed[8]['desc']=' <br><b>Crossfading Videos</b><br/><a href="http://service.real.com/help/library/guides/realone/ProductionGuide/HTML/htmfiles/transit.htm">source</a>
@@ -126,10 +124,11 @@
127125 ?>
128126 <table border="1" cellpadding="6" width="600">
129127 <? foreach($sample_embed as $key=>$aval){
130 - if($key!=8 && $key!=3)continue;
 128+ //$key!=8
 129+ if($key!=2)continue;
131130 ?>
132131 <tr>
133 - <td><?=$aval['tag']?></td>
 132+ <td valign="top"><?=$aval['tag']?></td>
134133 <td valign="top"><b>Sample Embed <?=$key?></b><br />
135134 <?=$aval['desc']?><br />
136135 &lt;-- code used: <br />
Index: trunk/extensions/MetavidWiki/skins/mv_embed/embedLibs/mv_nativeEmbed.js
@@ -1,22 +1,57 @@
22
33 var nativeEmbed = {
44 instanceOf:'nativeEmbed',
 5+ canPlayThrough:false,
56 supports: {'play_head':true, 'play_or_pause':true, 'stop':true, 'fullscreen':true, 'time_display':true, 'volume_control':true},
67 getEmbedHTML : function (){
7 - setTimeout('document.getElementById(\''+this.id+'\').postEmbedJS()', 150);
 8+ setTimeout('$j(\'#'+this.id+'\').get(0).postEmbedJS()', 150);
89 //set a default duration of 30 seconds: cortao should detect duration.
9 - return this.wrapEmebedContainer( this.getEmbedObj() );
 10+ var embed_code = this.getEmbedObj();
 11+ js_log('EMBED CODE: ' + embed_code);
 12+ return this.wrapEmebedContainer( embed_code);
1013 },
1114 getEmbedObj:function(){
1215 return '<video " ' +
13 - 'id="'+this.pid + '" ' +
14 - 'style="width:'+this.width+';height:'+this.height+';" ' +
15 - 'src="'+this.media_element.selected_source.uri+'" >' +
 16+ 'id="'+this.pid + '" ' +
 17+ 'style="width:'+this.width+'px;height:'+this.height+'px;" ' +
 18+ 'src="'+this.media_element.selected_source.uri+'" ' +
 19+ 'controls="false" ' +
 20+ 'oncanplaythrough="$j(\'#'+this.id+'\').get(0).oncanplaythrough();return false;" ' +
 21+ 'onloadedmetadata="$j(\'#'+this.id+'\').get(0).onloadedmetadata();return false;" >' +
1622 '</video>';
1723 },
18 - postEmbedJS:function(){
19 - document.getElementById(this.pid).play();
 24+ //@@todo : loading progress
 25+ postEmbedJS:function(){
 26+ this.getVID();
 27+ if(this.vid){
 28+ this.vid.load();
 29+ setTimeout('$j(\'#'+this.id+'\').get(0).monitor()',100);
 30+ }else{
 31+ js_log('could not grab vid obj:' + typeof this.vid);
 32+ setTimeout('$j(\'#'+this.id+'\').get(0).postEmbedJS()',100);
 33+ }
 34+ },
 35+ monitor : function(){
 36+ this.getVID(); //make shure we have .vid obj
 37+ js_log('time loaded: ' + this.vid.TimeRanges() );
 38+ //update load progress and
 39+ if( ! this.monitorTimerId ){
 40+ if(document.getElementById(this.id)){
 41+ this.monitorTimerId = setInterval('$j(\'#'+this.id+'\').get(0).monitor()', 1000);
 42+ }
 43+ }
 44+ },
 45+ /*
 46+ * native callbacks for the video tag:
 47+ */
 48+ oncanplaythrough : function(){
 49+ js_log("f:oncanplaythrough start playback");
 50+ this.play();
2051 },
 52+ onloadedmetadata: function(){
 53+ js_log('f:onloadedmetadata get duration');
 54+ //this.
 55+ },
2156 pause : function(){
2257 document.getElementById(this.pid).pause();
2358 },
@@ -26,5 +61,9 @@
2762 }else{
2863 document.getElementById(this.pid).play();
2964 }
30 - }
 65+ },
 66+ // get the embed vlc object
 67+ getVID : function (){
 68+ this.vid = $j('#'+this.pid).get(0);
 69+ }
3170 }
\ No newline at end of file
Index: trunk/extensions/MetavidWiki/skins/mv_embed/embedLibs/mv_genericEmbed.js
@@ -1,7 +1,7 @@
22 /* the most simple implementation used for unknown application/ogg plugin */
33 var genericEmbed={
44 instanceOf:'genericEmbed',
5 - getEmbedObj:function(){
 5+ getEmbedHTML:function(){
66 return '<object type="application/ogg" '+
77 'width="'+this.width+'" height="'+this.height+'" ' +
88 'data="' + this.src + '"></object>';
Index: trunk/extensions/MetavidWiki/skins/mv_embed/embedLibs/mv_flashEmbed.js
@@ -318,10 +318,17 @@
319319 var flashEmbed = {
320320 instanceOf:'flashEmbed',
321321 monitorTimerId : 0,
322 - supports: {'play_head':true, 'play_or_pause':true, 'stop':true, 'fullscreen':true, 'time_display':true, 'volume_control':true},
323 - getPluginEmbedHTML : function (){
 322+ supports: {'play_head':true,
 323+ 'play_or_pause':true,
 324+ 'stop':true,
 325+ 'fullscreen':true,
 326+ 'time_display':true,
 327+ 'volume_control':true,
 328+ 'overlay':false
 329+ },
 330+ getEmbedHTML : function (){
324331 setTimeout('document.getElementById(\''+this.id+'\').postEmbedJS()', 150);
325 - return this.getEmbedObj();
 332+ return this.wrapEmebedContainer( this.getEmbedObj() );
326333 },
327334 getEmbedObj:function(){
328335 if(!this.duration)this.duration=30;
Index: trunk/extensions/MetavidWiki/skins/mv_embed/embedLibs/mv_vlcEmbed.js
@@ -6,12 +6,19 @@
77 */
88 var vlcEmbed = {
99 instanceOf:'vlcEmbed',
10 - supports: {'play_head':true, 'play_or_pause':true, 'stop':true, 'fullscreen':true, 'time_display':true, 'volume_control':true},
 10+ supports: {'play_head':true,
 11+ 'play_or_pause':true,
 12+ 'stop':true,
 13+ 'fullscreen':true,
 14+ 'time_display':true,
 15+ 'volume_control':false,
 16+ 'overlay':false
 17+ },
1118 //init vars:
1219 monitorTimerId : 0,
1320 prevState : 0,
1421 currentTime:0,
15 - duration:0,
 22+ duration:0,
1623 userSlide:false,
1724 getEmbedHTML : function(){
1825 //give VLC 150ms to initialize before we start playback
@@ -92,8 +99,8 @@
93100 var msgtype = msg.type.toString();
94101 if( (msg.severity == 1) && (msgtype == "input") )
95102 {
96 - js_log( msg.message );
97 - }
 103+ js_log( msg.message );
 104+ }
98105 }
99106 // clear the log once finished to avoid clogging
100107 this.vlc.log.messages.clear();
@@ -225,6 +232,7 @@
226233 },
227234 /* js hooks/controls */
228235 play : function(){
 236+ js_log('f:vlcPlay');
229237 this.getVLC();
230238 if(!this.vlc || this.thumbnail_disp){
231239 //call the parent
@@ -275,7 +283,7 @@
276284 },
277285 */
278286 // get the embed vlc object
279 - getVLC : function getVLC(){
 287+ getVLC : function(){
280288 this.vlc = this.getPluginEmbed();
281289 }
282290 }
Index: trunk/extensions/MetavidWiki/skins/mv_embed/mv_embed.js
@@ -39,9 +39,10 @@
4040 var debug_global_vid_ref=null;
4141 /*
4242 * its best if you just require all your external data sources to serve up json data.
43 - * mv_proxy is not such a good idea from security standpoint but if you know what your doing
44 - * ie mv_data_proxy should not be hosted on domain as with any other web services running...
45 - * you can enable it here )
 43+ * or
 44+ * have a limited set of domains that you accept data from
 45+ * enabling mv_proxy is not such a good idea from security standpoint but if you know what your doing
 46+ * you can enable it here (also you have to uncomment mv_data_proxy die(); line)
4647 */
4748 var MV_ENABLE_DATA_PROXY=false;
4849
@@ -442,7 +443,7 @@
443444 {
444445 var name_value = pairs[i].split('=');
445446 this.preference[name_value[0]]=name_value[1];
446 - js_log('setting preference for ' + name_value[0] + ' to ' + name_value[1]);
 447+ js_log('load preference for ' + name_value[0] + ' to ' + name_value[1]);
447448 }
448449 }
449450 },
@@ -903,8 +904,12 @@
904905 js_log('did swap');
905906 $j('#'+embed_video.id).get(0).on_dom_swap();
906907 // now that "embed_video" is stable, do more initialization (if we are ready)
907 - if($j('#'+embed_video.id).get(0).loading_external_data==false)
908 - $j('#'+embed_video.id).get(0).more_init();
 908+ if($j('#'+embed_video.id).get(0).loading_external_data==false &&
 909+ $j('#'+embed_video.id).get(0).init_with_sources_loadedDone==false){
 910+ js_log("NOT LOADING ext data jump to init with sources");
 911+ $j('#'+embed_video.id).get(0).init_with_sources_loaded();
 912+ }
 913+ //js_log(" isd: "+this.init_with_sources_loadedDone + ' ed:' + )
909914
910915 //js_log('vid elm:'+ $j(video_element).html() );
911916
@@ -1582,6 +1587,7 @@
15831588 media_element:null,
15841589 slider:null,
15851590 loading_external_data:false,
 1591+ init_with_sources_loadedDone:false,
15861592 inDOM:false,
15871593 supports:{},
15881594 //utility functions for property values:
@@ -1652,16 +1658,17 @@
16531659 {
16541660 //continue
16551661 _this.media_element.addROE(data);
1656 - js_log('added_roe::' + _this.media_element.sources);
1657 - _this.more_init();
1658 - js_log('done loading ROE '+_this.thumbnail_disp )
1659 - _this.loading_external_data=false;
 1662+ js_log('added_roe::' + _this.media_element.sources);
 1663+ js_log('done loading ROE '+_this.thumbnail_disp )
 1664+ _this.init_with_sources_loaded();
 1665+ js_log('set loading_external_data=false');
 1666+ _this.loading_external_data=false;
16601667 });
16611668 }
16621669 },
1663 - more_init : function(ready_callback)
 1670+ init_with_sources_loaded : function(ready_callback)
16641671 {
1665 - js_log('f:more_init');
 1672+ js_log('f:init_with_sources_loaded');
16661673 //autoseletct the source
16671674 this.media_element.autoSelectSource();
16681675 //auto select player based on prefrence or default order
@@ -1683,7 +1690,7 @@
16841691 * @@TODO lazy load plugin types
16851692 * override all relevant exported functions with the {embed_type} Object
16861693 * place the base functions in parent.{function name}
1687 - */
 1694+ */
16881695 this.inheritEmbedObj(ready_callback);
16891696
16901697 //update HTML
@@ -1691,13 +1698,16 @@
16921699
16931700 //js_log('HTML FROM IN OBJECT' + this.getHTML());
16941701 //return this object:
1695 - //return this;
 1702+ //return this;
 1703+ this.init_with_sources_loadedDone=true;
16961704 },
16971705 selectPlayer:function(player)
16981706 {
16991707 var _this = this;
1700 - this.selected_player = player;
1701 - this.inheritEmbedObj();
 1708+ if(this.selected_player.id != player.id){
 1709+ this.selected_player = player;
 1710+ this.inheritEmbedObj();
 1711+ }
17021712 },
17031713 getTimeReq:function(){
17041714 js_log('f:getTimeReq');
@@ -1717,20 +1727,27 @@
17181728 getDurationNTP:function(){
17191729 return seconds2ntp(this.getDuration()/1000);
17201730 },
 1731+ /*
 1732+ * wrapEmebedContainer
 1733+ * wraps the embed code into a container to better support playlist function
 1734+ * (where embed element is swapped for next clip
 1735+ * (where plugin method does not support playlsits)
 1736+ */
17211737 wrapEmebedContainer:function(embed_code){
17221738 //check if parent clip is set( ie we are in a playlist so name the embed container by playlistID)
17231739 var id = (this.pc!=null)?this.pc.pp.id:this.id;
17241740 return '<div id="mv_ebct_'+id+'" style="width:'+this.width+'px;height:'+this.height+'px;">' +
17251741 embed_code +
17261742 '</div>';
1727 - },
 1743+ },
17281744 getEmbedHTML : function(){
1729 - return this.wrapEmebedContainer( this.getPluginEmbedHTML() );
 1745+ //return this.wrapEmebedContainer( this.getEmbedObj() );
 1746+ return 'function getEmbedHTML should be overiten by embedLib ';
17301747 },
17311748 doEmbedHTML:function()
17321749 {
17331750 js_log('f:doEmbedHTML');
1734 - js_log('thum disp:'+this.thumbnail_disp);
 1751+ js_log('thum disp:'+this.thumbnail_disp);
17351752 var _this = this;
17361753 this.closeDisplayedHTML();
17371754
@@ -1904,20 +1921,21 @@
19051922 });
19061923 },
19071924 getHTML : function (){
1908 - //check if we have sources avaliable
 1925+ //@@todo check if we have sources avaliable
19091926 js_log('f:getHTML');
19101927 var html_code = '';
19111928
19121929 html_code = '<div style="width:'+this.width+'px;" class="videoPlayer">';
19131930 html_code += '<div id="mv_embedded_player_'+this.id+'">' +
1914 - this.getThumbnailHTML();
 1931+ this.getThumbnailHTML() +
19151932 '</div>';
19161933
19171934 if(this.controls)
19181935 {
19191936 html_code += '<div id="mv_embedded_controls_'+this.id+'" class="controls">';
1920 - html_code += this.getControlsHTML();
 1937+ html_code += this.getControlsHTML();
19211938 html_code += '</div>';
 1939+
19221940 var dlLink = 'javascript:$j(\'#'+this.id+'\').get(0).showVideoDownload();';
19231941 var source_link = 'javascript:$j(\'#'+this.id+'\').get(0).selectPlaybackMethod();';
19241942 var close_link = '$j(\'#mv_embedded_options_'+this.id+'\').hide();';
@@ -2033,7 +2051,6 @@
20342052 js_log("PLAY BUTTON: " + this.play_button);
20352053 if(this.play_button==true)
20362054 thumb_html+=this.getPlayButton();
2037 -22
20382055 thumb_html+='</div>';
20392056 return thumb_html;
20402057 },
@@ -2365,8 +2382,8 @@
23662383 * the play button calls
23672384 */
23682385 play : function(){
2369 - js_log("mv_embed play:"+this.id);
2370 - js_log('thum disp:'+this.thumbnail_disp);
 2386+ js_log("mv_embed play:"+this.id);
 2387+ js_log('thum disp:'+this.thumbnail_disp);
23712388 //check if thumbnail is being displayed and embed html
23722389 if(this.thumbnail_disp){
23732390 if(!this.selected_player){
@@ -2435,6 +2452,9 @@
24362453 this.update_interval = null;
24372454 }
24382455 },
 2456+ fullscreen:function(){
 2457+ js_log('fullscreen not supported for this plugin type');
 2458+ },
24392459 /* returns bool true if playing false if paused or stooped
24402460 */
24412461 isPlaying : function(){
Index: trunk/extensions/MetavidWiki/skins/mv_embed/mv_data_proxy.php
@@ -7,8 +7,9 @@
88 * (so that remote use of mv_embed can load remote xml )
99 */
1010
11 -//NOTE THIS IS DISABLED BY DEFAULT simply comment out the line below to enable;
12 -die('note mv_data_proxy is disabled by default, see var mv_data_proxy in mv_embed.js for more info');
 11+//NOTE THIS IS DISABLED BY DEFAULT FOR A RESON
 12+//See var mv_data_proxy in mv_embed.js for more info
 13+die('note mv_data_proxy is disabled by default');
1314
1415 if(isset($_POST['url'])){
1516 $req_url = $_POST['url'];
Index: trunk/extensions/MetavidWiki/skins/mv_embed/mv_playlist.js
@@ -290,8 +290,7 @@
291291 return ;
292292 }
293293 $j(this).html('<div id="dc_'+this.id+'" style="border:solid thin;width:'+this.width+'px;' +
294 - 'height:'+this.height+'px;position:relative;"></div>');
295 -
 294+ 'height:'+this.height+'px;position:relative;"></div>');
296295
297296 var plObj=this;
298297 //append all embed details
@@ -1449,12 +1448,19 @@
14501449 var smilPlaylist ={
14511450 transitions:{},
14521451 doParse:function(){
 1452+ var _this = this;
14531453 js_log('do parse smil'+ typeof this.transitions);
14541454 //@@todo get/parse meta:
1455 -
 1455+ var meta_tags = this.data.getElementsByTagName('meta');
 1456+ $j.each(meta_tags, function(i,meta_elm){
 1457+ if(meta_elm.hasAttribute('name') && meta_elm.hasAttribute('content')){
 1458+ if(meta_elm.getAttribute('name')=='title' ){
 1459+ _this.title = meta_elm.getAttribute('content');
 1460+ }
 1461+ }
 1462+ });
14561463 //add transition objects:
1457 - var transition_tags = this.data.getElementsByTagName('transition');
1458 - var _this = this;
 1464+ var transition_tags = this.data.getElementsByTagName('transition');
14591465 $j.each(transition_tags, function(i,trans_elm){
14601466 if(trans_elm.hasAttribute("id")){
14611467 _this.transitions[trans_elm.getAttribute("id")]= new transitionObj(trans_elm);
@@ -1463,7 +1469,6 @@
14641470 }
14651471 });
14661472 //add seq (latter we will have support than one)
1467 - var _this_pl = this;
14681473 var seq_tags = this.data.getElementsByTagName('seq');
14691474 $j.each(seq_tags, function(i,seq_elm){
14701475 var inx = 0;
@@ -1475,8 +1480,8 @@
14761481 //set up basic mvSMILClip send it the mediaElemnt & mvClip init:
14771482 var cur_clip = new mvSMILClip(mediaElemnt,
14781483 {
1479 - id:'p_' + _this_pl.id + '_c_'+inx,
1480 - pp:_this_pl,
 1484+ id:'p_' + _this.id + '_c_'+inx,
 1485+ pp:_this,
14811486 order:inx
14821487 }
14831488 );
@@ -1484,7 +1489,7 @@
14851490 //set up embed:
14861491 cur_clip.setUpEmbedObj();
14871492 //add clip to track:
1488 - _this_pl.addCliptoTrack(cur_clip);
 1493+ _this.addCliptoTrack(cur_clip);
14891494 //valid clip up the order inx:
14901495 inx++;
14911496 }