Index: branches/MwEmbedStandAlone/modules/P2PNextTransport/mw.P2PTransport.js |
— | — | @@ -1,177 +0,0 @@ |
2 | | -/** |
3 | | - * Add the messages text: |
4 | | - */ |
5 | | - |
6 | | -mw.includeAllModuleMessages(); |
7 | | - |
8 | | -/** |
9 | | -* Define P2PNextTransport object: |
10 | | -*/ |
11 | | -mw.P2PNextTransport = { |
12 | | - // The transport objects |
13 | | - transportObjects: null |
14 | | - |
15 | | - addPlayerHooks: function(){ |
16 | | - var _this = this; |
17 | | - // Bind some hooks to every player: |
18 | | - $j( mw ).bind( 'newEmbedPlayerEvent', function( event, embedPlayer ) { |
19 | | - |
20 | | - // Setup the "embedCode" binding to swap in an updated url |
21 | | - $j( embedPlayer ).bind( 'checkPlayerSourcesEvent', function( event, callback ) { |
22 | | - // Confirm P2PNextTransport add-on is available ( defines swarmTransport var ) |
23 | | - if( _this.getTransportObjects().length ){ |
24 | | - // Add the swarm source |
25 | | - _this.addTransportSources( embedPlayer, function( status ){ |
26 | | - // Check if the status returned true |
27 | | - if( status ){ |
28 | | - // Update the source if paused |
29 | | - if( embedPlayer.paused ) { |
30 | | - // Re setup sources |
31 | | - embedPlayer.setupSourcePlayer(); |
32 | | - } |
33 | | - } |
34 | | - }); |
35 | | - } |
36 | | - // Don't block on swarm request, directly do the callback |
37 | | - callback(); |
38 | | - } ); |
39 | | - |
40 | | - // Check if we have a "recommend" binding and provide an xpi install link |
41 | | - mw.log('P2PNextTransport::bind:addControlBindingsEvent'); |
42 | | - $j( embedPlayer ).bind( 'addControlBindingsEvent', function(){ |
43 | | - if( mw.getConfig( 'P2PNextTransport.Recommend' ) && _this.getPluginLibrary() ){ |
44 | | - embedPlayer.controlBuilder.doWarningBindinng( |
45 | | - 'recommendSwarmTransport', |
46 | | - _this.getRecomendSwarmMessage() |
47 | | - ); |
48 | | - } |
49 | | - }); |
50 | | - |
51 | | - } ); |
52 | | - |
53 | | - |
54 | | - // Add the P2PNextTransport player to available player types: |
55 | | - $j( mw ).bind( 'EmbedPlayerManagerReady', function( event ) { |
56 | | - $.each( this.getTransportObjects(), function(na, transportObject ){ |
57 | | - |
58 | | - // Add the transportObject playerType |
59 | | - mw.EmbedTypes.getMediaPlayers().defaultPlayers[ transportObject.mime ] = [ transportObject.playerLib ]; |
60 | | - |
61 | | - // Build the Transport Player |
62 | | - var transportPlayer = new mediaPlayer( transportObject.name + 'TransportPlayer', [ transportObject.mime ], transportObject.playerLib ); |
63 | | - |
64 | | - // Add the P2PNextTransport "player" |
65 | | - mw.EmbedTypes.getMediaPlayers().addPlayer( transportPlayer ); |
66 | | - }); |
67 | | - |
68 | | - }); |
69 | | - |
70 | | - }, |
71 | | - // Gets what transport objects that holds all the custom methods per the transport type |
72 | | - // returns [] empty array if no transport object is found. |
73 | | - getTransportObjects: function(){ |
74 | | - if( this.transportObjects == null ){ |
75 | | - return this.transportObjects; |
76 | | - } |
77 | | - this.transportObjects = []; |
78 | | - // Build the transport object: |
79 | | - var baseSwarmObj = { |
80 | | - 'name' : 'swarm', |
81 | | - 'mime': 'video/swarmTransport', |
82 | | - 'playerLib' : 'Native', |
83 | | - 'lookupUrl' : mw.getConfig( 'SwarmTransport.TorrentLookupUrl' ), |
84 | | - 'protocol' : 'tribe://' |
85 | | - }; |
86 | | - if( typeof window['swarmTransport'] != 'undefined' ){ |
87 | | - this.transportObjects.push( baseSwarmObj ); |
88 | | - } |
89 | | - |
90 | | - // Look for vlc based swarm player: |
91 | | - try{ |
92 | | - if( mw.EmbedTypes.testActiveX( 'P2PNext.SwarmPlayer' ) ){ |
93 | | - this.transportObjects.push( |
94 | | - $j.extend( baseSwarmObj, { |
95 | | - 'playerLib': 'SwarmVlc' |
96 | | - }) |
97 | | - ); |
98 | | - } |
99 | | - } catch (e ){ |
100 | | - mw.log(" Error:: SwarmTransport:testActiveX( 'P2PNext.SwarmPlayer' failed "); |
101 | | - } |
102 | | - |
103 | | - // if tswift is supported it presently "overrides" 'swarm' |
104 | | - if( typeof window['tswiftTransport'] != 'undefined' ){ |
105 | | - this.transportObjects.push( |
106 | | - $j.extend( baseSwarmObj, { |
107 | | - 'name' : 'swift', |
108 | | - 'mime': 'video/swiftTransport', |
109 | | - 'lookupUrl' : mw.getConfig( 'TSwiftTransport.TorrentLookupUrl' ), |
110 | | - 'protocol' : 'tswift://' |
111 | | - }) |
112 | | - ); |
113 | | - } |
114 | | - |
115 | | - this.transportType = false; |
116 | | - return this.transportType; |
117 | | - }, |
118 | | - |
119 | | - addTransportSources: function( embedPlayer, callback ) { |
120 | | - var _this = this; |
121 | | - |
122 | | - // xxx todo: also grab the WebM source if supported. |
123 | | - var source = embedPlayer.mediaElement.getSources( 'video/ogg' )[0]; |
124 | | - if( ! source ){ |
125 | | - mw.log("Warning: addSwarmSource: could not find video/ogg source to generate torrent from"); |
126 | | - callback(); |
127 | | - return ; |
128 | | - } |
129 | | - $.each( this.getTransportObjects(), function(inx, transportObject ){ |
130 | | - // Setup the torrent request: |
131 | | - var torrentLookupRequest = { |
132 | | - 'url' : mw.absoluteUrl( source.getSrc() ) |
133 | | - }; |
134 | | - |
135 | | - mw.log( 'SwarmTransport:: lookup torrent url: ' + |
136 | | - mw.getConfig( 'SwarmTransport.TorrentLookupUrl' ) + "\n" + |
137 | | - mw.absoluteUrl( source.getSrc() ) |
138 | | - ); |
139 | | - transportLookupCount++; |
140 | | - |
141 | | - // Setup function to run in context based on callback result |
142 | | - $j.getJSON( |
143 | | - transportObject.lookupUrl + '?jsonp=?', |
144 | | - torrentLookupRequest, |
145 | | - function( data ){ |
146 | | - // Check if the torrent is ready: |
147 | | - if( !data.torrent ){ |
148 | | - mw.log( "SwarmTransport: Torrent not ready status: " + data.status.text ); |
149 | | - callback( false ); |
150 | | - return ; |
151 | | - } |
152 | | - mw.log( 'SwarmTransport: addSwarmSource for: ' + source.getSrc() + "\n\nGot:" + data.torrent ); |
153 | | - // XXX need to update preference |
154 | | - embedPlayer.mediaElement.tryAddSource( |
155 | | - $j('<source />') |
156 | | - .attr( { |
157 | | - 'type' : 'video/swarmTransport', |
158 | | - 'title': gM('mwe-swarmtransport-stream-ogg'), |
159 | | - 'src': torrentLookup.protocol + data.torrent, |
160 | | - 'default' : true |
161 | | - } ) |
162 | | - .get( 0 ) |
163 | | - ); |
164 | | - callback( true ); |
165 | | - } |
166 | | - ); |
167 | | - }) |
168 | | - }, |
169 | | - |
170 | | - getRecomendSwarmMessage: function(){ |
171 | | - //xxx an xpi link would be nice ( for now just link out to the web site ) |
172 | | - return gM( 'mwe-swarmtransport-recommend', 'http://wikipedia.p2p-next.org/download/' ); |
173 | | - } |
174 | | - |
175 | | -}; |
176 | | - |
177 | | -// Add player bindings for swarm Transport |
178 | | -mw.P2PNextTransport.addPlayerHooks(); |
\ No newline at end of file |
Index: branches/MwEmbedStandAlone/modules/P2PNextTransport/PNextTransport.i18n.php |
— | — | @@ -1,16 +0,0 @@ |
2 | | -<?php |
3 | | -/** |
4 | | - * Internationalisation for EmbedPlayer |
5 | | - * |
6 | | - * @file |
7 | | - * @ingroup Extensions |
8 | | - */ |
9 | | - |
10 | | -$messages = array(); |
11 | | -$messages['en'] = array( |
12 | | - "mwe-swarmtransport-stream-ogg" => "Swarm Transport p2p Ogg stream", |
13 | | - "mwe-swiftransport-stream-ogg" => "Swift Transport p2p Ogg stream", |
14 | | - "mwe-swarmtransport-recommend" => "To save bandwidth, please consider installing the P2P [$1 swarm transport add on]", |
15 | | - "mwe-embedplayer-ogg-player-swarmTransportPlayer" => "Swarm Transport player", |
16 | | - "mwe-embedplayer-ogg-player-swiftTransportPlayer" => "Swift Transport player", |
17 | | -); |
Index: branches/MwEmbedStandAlone/modules/P2PNextTransport/P2PNextTransport.i18n.php |
— | — | @@ -0,0 +1,16 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Internationalisation for EmbedPlayer |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + */ |
| 9 | + |
| 10 | +$messages = array(); |
| 11 | +$messages['en'] = array( |
| 12 | + "mwe-swarmtransport-stream-ogg" => "Swarm Transport p2p Ogg stream", |
| 13 | + "mwe-swiftransport-stream-ogg" => "Swift Transport p2p Ogg stream", |
| 14 | + "mwe-swarmtransport-recommend" => "To save bandwidth, please consider installing the P2P [$1 swarm transport add on]", |
| 15 | + "mwe-embedplayer-ogg-player-swarmTransportPlayer" => "Swarm Transport player", |
| 16 | + "mwe-embedplayer-ogg-player-swiftTransportPlayer" => "Swift Transport player", |
| 17 | +); |
Property changes on: branches/MwEmbedStandAlone/modules/P2PNextTransport/P2PNextTransport.i18n.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 18 | + native |
Index: branches/MwEmbedStandAlone/modules/P2PNextTransport/loader.js |
— | — | @@ -8,7 +8,7 @@ |
9 | 9 | ( function( mw ) { |
10 | 10 | |
11 | 11 | mw.addResourcePaths( { |
12 | | - "mw.P2PNextTransport" : "mw.P2PTransport.js", |
| 12 | + "mw.P2PNextTransport" : "mw.P2PNextTransport.js", |
13 | 13 | "mw.EmbedPlayerSwarmVlc" : "mw.EmbedPlayerSwarmVlc.js" |
14 | 14 | }); |
15 | 15 | |
— | — | @@ -27,12 +27,12 @@ |
28 | 28 | /** |
29 | 29 | * Swarm Lookup service url |
30 | 30 | */ |
31 | | - 'SwarmTransport.TorrentLookupUrl': 'http://url2torrent.net/get/', |
| 31 | + 'P2PNextTransport.SwarmLookupUrl': 'http://url2torrent.net/get/', |
32 | 32 | |
33 | 33 | /** |
34 | 34 | * TSwift Swarm Lookup service url |
35 | 35 | */ |
36 | | - 'TSwiftTransport.TorrentLookupUrl': 'http://url2torrent.p2p-next.org/get/' |
| 36 | + 'P2PNextTransport.SwiftLookupUrl': 'http://url2torrent.p2p-next.org/get/' |
37 | 37 | }); |
38 | 38 | |
39 | 39 | // Add the mw.SwarmTransport to the embedPlayer loader: |
Index: branches/MwEmbedStandAlone/modules/P2PNextTransport/mw.P2PNextTransport.js |
— | — | @@ -0,0 +1,166 @@ |
| 2 | +/** |
| 3 | + * Add the messages text: |
| 4 | + */ |
| 5 | + |
| 6 | +mw.includeAllModuleMessages(); |
| 7 | + |
| 8 | +/** |
| 9 | +* Define P2PNextTransport object: |
| 10 | +*/ |
| 11 | +mw.P2PNextTransport = { |
| 12 | + // The transport objects |
| 13 | + transportObjects: null, |
| 14 | + |
| 15 | + addPlayerHooks: function(){ |
| 16 | + var _this = this; |
| 17 | + |
| 18 | + // Add the P2PNextTransport player to available player types: |
| 19 | + $j( mw ).bind( 'EmbedPlayerManagerReady', function( event ) { |
| 20 | + $.each( _this.getTransportObjects(), function(na, transportObject ){ |
| 21 | + |
| 22 | + // Add the transportObject playerType |
| 23 | + mw.EmbedTypes.getMediaPlayers().defaultPlayers[ transportObject.mime ] = [ transportObject.playerLib ]; |
| 24 | + |
| 25 | + // Build the Transport Player |
| 26 | + var transportPlayer = new mediaPlayer( transportObject.name + 'TransportPlayer', [ transportObject.mime ], transportObject.playerLib ); |
| 27 | + |
| 28 | + // Add the P2PNextTransport "player" |
| 29 | + mw.EmbedTypes.getMediaPlayers().addPlayer( transportPlayer ); |
| 30 | + }); |
| 31 | + }); |
| 32 | + |
| 33 | + |
| 34 | + // Bind some hooks to every player: |
| 35 | + $j( mw ).bind( 'newEmbedPlayerEvent', function( event, embedPlayer ) { |
| 36 | + |
| 37 | + // Setup the "embedCode" binding to swap in an updated url |
| 38 | + $j( embedPlayer ).bind( 'checkPlayerSourcesEvent', function( event, callback ) { |
| 39 | + // Confirm P2PNextTransport add-on is available |
| 40 | + if( _this.getTransportObjects().length ){ |
| 41 | + // Add the swarm source |
| 42 | + _this.addTransportSources( embedPlayer, function( status ){ |
| 43 | + // Check if the status returned true |
| 44 | + if( status ){ |
| 45 | + // Update the source if paused |
| 46 | + if( embedPlayer.paused ) { |
| 47 | + // Re setup sources |
| 48 | + embedPlayer.setupSourcePlayer(); |
| 49 | + } |
| 50 | + } |
| 51 | + }); |
| 52 | + } |
| 53 | + // Don't block on swarm request, directly do the callback |
| 54 | + callback(); |
| 55 | + } ); |
| 56 | + |
| 57 | + // Check if we have a "recommend" binding and provide an xpi install link |
| 58 | + mw.log('P2PNextTransport::bind:addControlBindingsEvent'); |
| 59 | + $j( embedPlayer ).bind( 'addControlBindingsEvent', function(){ |
| 60 | + if( mw.getConfig( 'P2PNextTransport.Recommend' ) && _this.getPluginLibrary() ){ |
| 61 | + embedPlayer.controlBuilder.doWarningBindinng( |
| 62 | + 'recommendSwarmTransport', |
| 63 | + _this.getRecomendSwarmMessage() |
| 64 | + ); |
| 65 | + } |
| 66 | + }); |
| 67 | + |
| 68 | + } ); |
| 69 | + |
| 70 | + }, |
| 71 | + // Gets what transport objects that holds all the custom methods per the transport type |
| 72 | + // returns [] empty array if no transport object is found. |
| 73 | + getTransportObjects: function(){ |
| 74 | + if( this.transportObjects != null ){ |
| 75 | + return this.transportObjects; |
| 76 | + } |
| 77 | + this.transportObjects = []; |
| 78 | + // Build the transport object: |
| 79 | + var baseSwarmObj = { |
| 80 | + 'name' : 'swarm', |
| 81 | + 'mime': 'video/swarmTransport', |
| 82 | + 'playerLib' : 'Native', |
| 83 | + 'lookupUrl' : mw.getConfig( 'P2PNextTransport.SwarmLookupUrl' ), |
| 84 | + 'protocol' : 'tribe://' |
| 85 | + }; |
| 86 | + if( typeof window['swarmTransport'] != 'undefined' ){ |
| 87 | + this.transportObjects.push( baseSwarmObj ); |
| 88 | + } |
| 89 | + |
| 90 | + // Look for vlc based swarm player: |
| 91 | + try{ |
| 92 | + if( mw.EmbedTypes.testActiveX( 'P2PNext.SwarmPlayer' ) ){ |
| 93 | + this.transportObjects.push( |
| 94 | + $j.extend( {}, baseSwarmObj, { |
| 95 | + 'playerLib': 'SwarmVlc' |
| 96 | + }) |
| 97 | + ); |
| 98 | + } |
| 99 | + } catch (e ){ |
| 100 | + mw.log(" Error:: P2PNextTransport:testActiveX( 'P2PNext.SwarmPlayer' failed "); |
| 101 | + } |
| 102 | + |
| 103 | + // if tswift is supported it presently "overrides" 'swarm' |
| 104 | + if( typeof window['tswiftTransport'] != 'undefined' ){ |
| 105 | + this.transportObjects.push( |
| 106 | + $j.extend( {}, baseSwarmObj, { |
| 107 | + 'name' : 'swift', |
| 108 | + 'mime': 'video/swiftTransport', |
| 109 | + 'lookupUrl' : mw.getConfig( 'P2PNextTransport.SwiftLookupUrl' ), |
| 110 | + 'protocol' : 'tswift://' |
| 111 | + }) |
| 112 | + ); |
| 113 | + } |
| 114 | + return this.transportObjects; |
| 115 | + }, |
| 116 | + |
| 117 | + addTransportSources: function( embedPlayer, callback ) { |
| 118 | + var _this = this; |
| 119 | + |
| 120 | + // xxx todo: also grab the WebM source if supported. |
| 121 | + var source = embedPlayer.mediaElement.getSources( 'video/ogg' )[0]; |
| 122 | + if( ! source ){ |
| 123 | + mw.log("Warning: addSwarmSource: could not find video/ogg source to generate torrent from"); |
| 124 | + callback(); |
| 125 | + return ; |
| 126 | + } |
| 127 | + $.each( this.getTransportObjects(), function(inx, transportObject ){ |
| 128 | + // Setup function to run in context based on callback result |
| 129 | + $j.getJSON( |
| 130 | + transportObject.lookupUrl + '?jsonp=?', |
| 131 | + { |
| 132 | + 'url' : mw.absoluteUrl( source.getSrc() ) |
| 133 | + }, |
| 134 | + function( data ){ |
| 135 | + // Check if the torrent is ready: |
| 136 | + if( !data.torrent ){ |
| 137 | + mw.log( "P2PNext: ( " + transportObject.lookupUrl + " ) Torrent not ready status: " + data.status.text ); |
| 138 | + callback( false ); |
| 139 | + return ; |
| 140 | + } |
| 141 | + mw.log( 'SwarmTransport: addSwarmSource for: ' + source.getSrc() + "\n\nGot:" + data.torrent ); |
| 142 | + // XXX need to update preference |
| 143 | + embedPlayer.mediaElement.tryAddSource( |
| 144 | + $j('<source />') |
| 145 | + .attr( { |
| 146 | + 'type' : 'video/swarmTransport', |
| 147 | + 'title': gM('mwe-swarmtransport-stream-ogg'), |
| 148 | + 'src': transportObject.protocol + data.torrent, |
| 149 | + 'default' : true |
| 150 | + } ) |
| 151 | + .get( 0 ) |
| 152 | + ); |
| 153 | + callback( true ); |
| 154 | + } |
| 155 | + ); |
| 156 | + }) |
| 157 | + }, |
| 158 | + |
| 159 | + getRecomendSwarmMessage: function(){ |
| 160 | + //xxx an xpi link would be nice ( for now just link out to the web site ) |
| 161 | + return gM( 'mwe-swarmtransport-recommend', 'http://wikipedia.p2p-next.org/download/' ); |
| 162 | + } |
| 163 | + |
| 164 | +}; |
| 165 | + |
| 166 | +// Add player bindings for swarm Transport |
| 167 | +mw.P2PNextTransport.addPlayerHooks(); |
\ No newline at end of file |
Property changes on: branches/MwEmbedStandAlone/modules/P2PNextTransport/mw.P2PNextTransport.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 168 | + native |