r81137 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81136‎ | r81137 | r81138 >
Date:16:43, 28 January 2011
Author:dale
Status:deferred
Tags:
Comment:
prefer swift over swarm transport ( added autoSelection of mediatype bind / trigger )
Modified paths:
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/P2PNextTransport/mw.P2PNextTransport.js (modified) (history)
  • /branches/MwEmbedStandAlone/remotes/mediaWiki.js (modified) (history)

Diff [purge]

Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js
@@ -978,8 +978,7 @@
979979 },
980980
981981 /**
982 - * Selects the default source via cookie preference, default marked, or by
983 - * id order
 982+ * Selects the default source via cookie preference, default marked, or by id order
984983 */
985984 autoSelectSource: function() {
986985 mw.log( 'EmbedPlayer::mediaElement::autoSelectSource' );
@@ -1005,6 +1004,13 @@
10061005 return true;
10071006 }
10081007 }
 1008+
 1009+ // Set via module driven preference:
 1010+ $j(this).trigger( 'AutoSelectSource', [ playableSources ] );
 1011+ if( _this.selectedSource ){
 1012+ return true;
 1013+ }
 1014+
10091015
10101016 // Set via marked default:
10111017 for ( var source = 0; source < playableSources.length; source++ ) {
Index: branches/MwEmbedStandAlone/modules/P2PNextTransport/mw.P2PNextTransport.js
@@ -34,14 +34,34 @@
3535 $j( mw ).bind( 'newEmbedPlayerEvent', function( event, embedPlayer ) {
3636 // Setup the "embedCode" binding to swap in an updated url
3737 $j( embedPlayer ).bind( 'checkPlayerSourcesEvent', function( event, callback ) {
 38+ // Add binding for source selection preference
 39+ $j( embedPlayer.mediaElement ).bind('AutoSelectSource', function( event, playableSources ){
 40+ // Check for swift and swarm ( prefer swift )
 41+ $j.each( playableSources, function(inx, source){
 42+ if( source.mimeType == 'video/swiftTransport'){
 43+ embedPlayer.mediaElement.selectedSource = source;
 44+ // break loop do no more checks
 45+ return false;
 46+ }
 47+ if( source.mimeType == 'video/swarmTransport'){
 48+ embedPlayer.mediaElement.selectedSource = source;
 49+ // continue looking for swift
 50+ return true;
 51+ }
 52+ });
 53+ });
 54+
 55+
3856 // Confirm P2PNextTransport add-on is available
 57+
3958 if( _this.getTransportObjects().length ){
4059 // Add the swarm source
41 - _this.addTransportSources( embedPlayer, function( status ){
 60+ _this.addTransportSources( embedPlayer, function( status ){
4261 // Check if the status returned true
4362 if( status ){
4463 // Update the source if paused
4564 if( embedPlayer.paused ) {
 65+
4666 // Re setup sources
4767 embedPlayer.setupSourcePlayer();
4868 }
@@ -121,8 +141,8 @@
122142 mw.log("Warning: addSwarmSource: could not find video/ogg source to generate torrent from");
123143 callback();
124144 return ;
125 - }
126 - $.each( this.getTransportObjects(), function(inx, transportObject ){
 145+ }
 146+ $.each( this.getTransportObjects(), function( inx, transportObject ){
127147 // Setup function to run in context based on callback result
128148 $j.getJSON(
129149 transportObject.lookupUrl + '?jsonp=?',
@@ -131,21 +151,16 @@
132152 },
133153 function( data ){
134154 // Check if the torrent is ready:
135 - if( !data.torrent && ! data ){
136 - mw.log( "P2PNext: ( " + transportObject.lookupUrl + " ) Torrent not ready status: " + data.status.text );
 155+ if( !data || !data.torrent || !data.swift ) {
 156+ mw.log( "P2PNext: ( " + transportObject.lookupUrl + " ) Not ready ");
137157 callback( false );
138158 return ;
139 - }
140 - if( !data.torrent || !data.swift ){
141 - mw.log( 'P2PNextTransport: could not get p2p source status:' + data.text );
142 - return ;
143 - }
144 - mw.log( 'P2PNextTransport: addSwarmSource for: ' + source.getSrc() + "\n\nGot:" + data.torrent );
145 -
146 - var transportSrc = '';
 159+ }
 160+ var transportSrc = '';
147161 // Set the source via transportObject type
148162 if( transportObject.name == 'swift'){
149163 transportSrc = data.swift;
 164+
150165 } else {
151166 transportSrc = transportObject.protocol + data.torrent;
152167 }
@@ -155,14 +170,13 @@
156171 'type' : transportObject.mime,
157172 'title': gM('mwe-' + transportObject.name + 'transport-stream-ogg' ),
158173 'src': transportSrc,
159 - 'default' : true
 174+ // Set default if "swift"
 175+ 'default' :true
160176 } )
161177 .get( 0 )
162178 );
163 - // XXX need to update preference
164 -
165179 callback( true );
166 - }
 180+ }
167181 );
168182 })
169183 },
Index: branches/MwEmbedStandAlone/remotes/mediaWiki.js
@@ -4,7 +4,7 @@
55 */
66 var urlparts = getRemoteEmbedPath();
77 var mwEmbedHostPath = urlparts[0];
8 -var mwRemoteVersion = 'r189';
 8+var mwRemoteVersion = 'r190';
99
1010 // Log the mwRemote version makes it easy to debug cache issues
1111 if( window.console ){

Status & tagging log