Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js |
— | — | @@ -978,8 +978,7 @@ |
979 | 979 | }, |
980 | 980 | |
981 | 981 | /** |
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 |
984 | 983 | */ |
985 | 984 | autoSelectSource: function() { |
986 | 985 | mw.log( 'EmbedPlayer::mediaElement::autoSelectSource' ); |
— | — | @@ -1005,6 +1004,13 @@ |
1006 | 1005 | return true; |
1007 | 1006 | } |
1008 | 1007 | } |
| 1008 | + |
| 1009 | + // Set via module driven preference: |
| 1010 | + $j(this).trigger( 'AutoSelectSource', [ playableSources ] ); |
| 1011 | + if( _this.selectedSource ){ |
| 1012 | + return true; |
| 1013 | + } |
| 1014 | + |
1009 | 1015 | |
1010 | 1016 | // Set via marked default: |
1011 | 1017 | for ( var source = 0; source < playableSources.length; source++ ) { |
Index: branches/MwEmbedStandAlone/modules/P2PNextTransport/mw.P2PNextTransport.js |
— | — | @@ -34,14 +34,34 @@ |
35 | 35 | $j( mw ).bind( 'newEmbedPlayerEvent', function( event, embedPlayer ) { |
36 | 36 | // Setup the "embedCode" binding to swap in an updated url |
37 | 37 | $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 | + |
38 | 56 | // Confirm P2PNextTransport add-on is available |
| 57 | + |
39 | 58 | if( _this.getTransportObjects().length ){ |
40 | 59 | // Add the swarm source |
41 | | - _this.addTransportSources( embedPlayer, function( status ){ |
| 60 | + _this.addTransportSources( embedPlayer, function( status ){ |
42 | 61 | // Check if the status returned true |
43 | 62 | if( status ){ |
44 | 63 | // Update the source if paused |
45 | 64 | if( embedPlayer.paused ) { |
| 65 | + |
46 | 66 | // Re setup sources |
47 | 67 | embedPlayer.setupSourcePlayer(); |
48 | 68 | } |
— | — | @@ -121,8 +141,8 @@ |
122 | 142 | mw.log("Warning: addSwarmSource: could not find video/ogg source to generate torrent from"); |
123 | 143 | callback(); |
124 | 144 | return ; |
125 | | - } |
126 | | - $.each( this.getTransportObjects(), function(inx, transportObject ){ |
| 145 | + } |
| 146 | + $.each( this.getTransportObjects(), function( inx, transportObject ){ |
127 | 147 | // Setup function to run in context based on callback result |
128 | 148 | $j.getJSON( |
129 | 149 | transportObject.lookupUrl + '?jsonp=?', |
— | — | @@ -131,21 +151,16 @@ |
132 | 152 | }, |
133 | 153 | function( data ){ |
134 | 154 | // 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 "); |
137 | 157 | callback( false ); |
138 | 158 | 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 = ''; |
147 | 161 | // Set the source via transportObject type |
148 | 162 | if( transportObject.name == 'swift'){ |
149 | 163 | transportSrc = data.swift; |
| 164 | + |
150 | 165 | } else { |
151 | 166 | transportSrc = transportObject.protocol + data.torrent; |
152 | 167 | } |
— | — | @@ -155,14 +170,13 @@ |
156 | 171 | 'type' : transportObject.mime, |
157 | 172 | 'title': gM('mwe-' + transportObject.name + 'transport-stream-ogg' ), |
158 | 173 | 'src': transportSrc, |
159 | | - 'default' : true |
| 174 | + // Set default if "swift" |
| 175 | + 'default' :true |
160 | 176 | } ) |
161 | 177 | .get( 0 ) |
162 | 178 | ); |
163 | | - // XXX need to update preference |
164 | | - |
165 | 179 | callback( true ); |
166 | | - } |
| 180 | + } |
167 | 181 | ); |
168 | 182 | }) |
169 | 183 | }, |
Index: branches/MwEmbedStandAlone/remotes/mediaWiki.js |
— | — | @@ -4,7 +4,7 @@ |
5 | 5 | */ |
6 | 6 | var urlparts = getRemoteEmbedPath(); |
7 | 7 | var mwEmbedHostPath = urlparts[0]; |
8 | | -var mwRemoteVersion = 'r189'; |
| 8 | +var mwRemoteVersion = 'r190'; |
9 | 9 | |
10 | 10 | // Log the mwRemote version makes it easy to debug cache issues |
11 | 11 | if( window.console ){ |