Index: branches/MwEmbedStandAlone/mwEmbedFrame.php |
— | — | @@ -35,7 +35,7 @@ |
36 | 36 | ); |
37 | 37 | var $playerIframeId = 'iframeVid'; |
38 | 38 | var $debug = false; |
39 | | - |
| 39 | + |
40 | 40 | // When used in direct source mode the source asset. |
41 | 41 | // NOTE: can be an array of sources in cases of "many" sources set |
42 | 42 | var $sources = array(); |
— | — | @@ -44,15 +44,15 @@ |
45 | 45 | //parse input: |
46 | 46 | $this->parseRequest(); |
47 | 47 | } |
48 | | - |
| 48 | + |
49 | 49 | // Parse the embedFrame request and sanitize input |
50 | 50 | private function parseRequest(){ |
51 | | - // Check for / attribute type request and update "REQUEST" global |
| 51 | + // Check for / attribute type request and update "REQUEST" global |
52 | 52 | // ( uses kaltura standard entry_id/{entryId} request ) |
53 | 53 | // normalize to the REQUEST object |
54 | | - // @@FIXME: this should be moved over to a kaltura specific iframe implementation |
| 54 | + // @@FIXME: this should be moved over to a kaltura specific iframe implementation |
55 | 55 | if( $_SERVER['REQUEST_URI'] ){ |
56 | | - $kalturaUrlMap = Array( |
| 56 | + $kalturaUrlMap = Array( |
57 | 57 | 'entry_id' => 'kentryid', |
58 | 58 | 'uiconf_id' => 'kuiconfid', |
59 | 59 | 'wid' => 'kwidgetid', |
— | — | @@ -78,7 +78,7 @@ |
79 | 79 | if( isset( $_REQUEST['debug'] ) ){ |
80 | 80 | $this->debug = true; |
81 | 81 | } |
82 | | - |
| 82 | + |
83 | 83 | // Process the special "src" attribute |
84 | 84 | if( isset( $_REQUEST['src'] ) ){ |
85 | 85 | if( is_array( $_REQUEST['src'] ) ){ |
— | — | @@ -89,10 +89,10 @@ |
90 | 90 | $this->sources = array( htmlspecialchars( $_REQUEST['src'] ) ); |
91 | 91 | } |
92 | 92 | } |
93 | | - |
| 93 | + |
94 | 94 | } |
95 | 95 | private function getVideoTag( ){ |
96 | | - // Add default video tag with 100% width / height |
| 96 | + // Add default video tag with 100% width / height |
97 | 97 | // ( parent embed is responsible for setting the iframe size ) |
98 | 98 | $o = '<video id="' . htmlspecialchars( $this->playerIframeId ) . '" style="width:100%;height:100%"'; |
99 | 99 | foreach( $this->playerAttributes as $attributeKey){ |
— | — | @@ -110,12 +110,12 @@ |
111 | 111 | } |
112 | 112 | $o.= '</video>'; |
113 | 113 | return $o; |
114 | | - } |
115 | | - |
| 114 | + } |
| 115 | + |
116 | 116 | function outputIFrame( ){ |
117 | 117 | // Setup the embed string based on attribute set: |
118 | 118 | $embedResourceList = 'window.jQuery,mwEmbed,mw.style.mwCommon,$j.fn.menu,mw.style.jquerymenu,mw.EmbedPlayer,mw.EmbedPlayerNative,mw.EmbedPlayerJava,mw.PlayerControlBuilder,$j.fn.hoverIntent,mw.style.EmbedPlayer,$j.cookie,$j.ui,mw.style.ui_redmond,$j.widget,$j.ui.mouse,mw.PlayerSkinKskin,mw.style.PlayerSkinKskin,mw.TimedText,mw.style.TimedText,$j.ui.slider'; |
119 | | - |
| 119 | + |
120 | 120 | if( isset( $this->kentryid ) ){ |
121 | 121 | $embedResourceList.= ',' . implode(',', array( |
122 | 122 | 'KalturaClientBase', |
— | — | @@ -125,7 +125,7 @@ |
126 | 126 | 'KalturaAccessControl', |
127 | 127 | 'MD5', |
128 | 128 | 'mw.KWidgetSupport', |
129 | | - 'mw.KAnalytics', |
| 129 | + 'mw.KAnalytics', |
130 | 130 | 'mw.KDPMapping', |
131 | 131 | 'mw.MobileAdTimeline', |
132 | 132 | 'mw.KAds' |
— | — | @@ -145,18 +145,18 @@ |
146 | 146 | left:0px; |
147 | 147 | bottom:0px; |
148 | 148 | right:0px; |
149 | | - |
| 149 | + |
150 | 150 | } |
151 | 151 | </style> |
152 | | - <script type="text/javascript" src="<?php echo str_replace( 'mwEmbedFrame.php', '', $_SERVER['SCRIPT_NAME'] ); ?>ResourceLoader.php?class=<?php |
153 | | - // @@TODO we should move this over to using the mwEmbedLoader.js so we don't have to mannage the resource list in two places. |
154 | | - // ( this will matter less once we migrate to the new mediaWiki resource loader framework) |
| 152 | + <script type="text/javascript" src="<?php echo str_replace( 'mwEmbedFrame.php', '', $_SERVER['SCRIPT_NAME'] ); ?>ResourceLoader.php?class=<?php |
| 153 | + // @@TODO we should move this over to using the mwEmbedLoader.js so we don't have to mannage the resource list in two places. |
| 154 | + // ( this will matter less once we migrate to the new mediaWiki resource loader framework) |
155 | 155 | echo $embedResourceList; |
156 | 156 | if( $this->debug ){ |
157 | 157 | echo '&debug=true'; |
158 | | - } |
| 158 | + } |
159 | 159 | ?>"></script> |
160 | | - |
| 160 | + |
161 | 161 | <script type="text/javascript"> |
162 | 162 | //Set some iframe embed config: |
163 | 163 | // We can't support full screen in object context since it requires outer page DOM control |
— | — | @@ -164,21 +164,21 @@ |
165 | 165 | |
166 | 166 | // Enable the iframe player server: |
167 | 167 | mw.setConfig( 'EmbedPlayer.EnableIFramePlayerServer', true ); |
168 | | - |
| 168 | + |
169 | 169 | mw.ready(function(){ |
170 | | - // Bind window resize to reize the player: |
| 170 | + // Bind window resize to reize the player: |
171 | 171 | $j(window).resize(function(){ |
172 | 172 | $j( '#<?php echo htmlspecialchars( $this->playerIframeId )?>' ) |
173 | 173 | .get(0).resizePlayer({ |
174 | 174 | 'width' : $j(window).width(), |
175 | 175 | 'height' : $j(window).height() |
176 | | - }); |
| 176 | + }); |
177 | 177 | }); |
178 | 178 | }); |
179 | 179 | </script> |
180 | | - |
| 180 | + |
181 | 181 | </head> |
182 | | - <body> |
| 182 | + <body> |
183 | 183 | <? |
184 | 184 | // Check if we have a way to get sources: |
185 | 185 | if( isset( $this->apiTitleKey ) || isset( $this->kentryid ) || count( $this->sources ) != 0 ) { |
— | — | @@ -186,7 +186,7 @@ |
187 | 187 | } else { |
188 | 188 | echo "Error: mwEmbedFrame missing required parameter for video sources</body></html>"; |
189 | 189 | exit(1); |
190 | | - } |
| 190 | + } |
191 | 191 | ?> |
192 | 192 | </body> |
193 | 193 | </html> |
Index: branches/MwEmbedStandAlone/mwEmbed.js |
— | — | @@ -84,7 +84,7 @@ |
85 | 85 | mwConfig[ name ] = value; |
86 | 86 | }; |
87 | 87 | /** |
88 | | - * Merge in a configuration value: |
| 88 | + * Merge in a configuration value: |
89 | 89 | */ |
90 | 90 | mw.mergeConfig = function( name, value ){ |
91 | 91 | if( typeof name == 'object' ) { |
— | — | @@ -97,7 +97,7 @@ |
98 | 98 | if( typeof value == 'object' && typeof mwConfig[ name ] == 'object' ) { |
99 | 99 | if ( value.constructor.toString().indexOf("Array") != -1 && |
100 | 100 | mwConfig[ name ].constructor.toString().indexOf("Array") != -1 ){ |
101 | | - // merge in the array |
| 101 | + // merge in the array |
102 | 102 | mwConfig[ name ] = $j.merge( mwConfig[ name ], value ); |
103 | 103 | } else { |
104 | 104 | for( var i in value ){ |
— | — | @@ -109,7 +109,7 @@ |
110 | 110 | // else do a normal setConfig |
111 | 111 | mwConfig[ name ] = value; |
112 | 112 | }; |
113 | | - |
| 113 | + |
114 | 114 | /** |
115 | 115 | * Set a default config value Will only update configuration if no value is |
116 | 116 | * present |
— | — | @@ -1161,15 +1161,15 @@ |
1162 | 1162 | |
1163 | 1163 | /** |
1164 | 1164 | * Fallforward system by default prefers flash. |
1165 | | - * |
| 1165 | + * |
1166 | 1166 | * This is separate from the EmbedPlayer library detection to provide package loading control |
1167 | 1167 | * NOTE: should be phased out in favor of browser feature detection where possible |
1168 | | - * |
| 1168 | + * |
1169 | 1169 | */ |
1170 | 1170 | mw.isHTML5FallForwardNative = function(){ |
1171 | 1171 | // Check for a mobile html5 user agent: |
1172 | 1172 | if ( (navigator.userAgent.indexOf('iPhone') != -1) || |
1173 | | - (navigator.userAgent.indexOf('iPod') != -1) || |
| 1173 | + (navigator.userAgent.indexOf('iPod') != -1) || |
1174 | 1174 | (navigator.userAgent.indexOf('iPad') != -1) || |
1175 | 1175 | (navigator.userAgent.indexOf('Android 2.') != -1) || |
1176 | 1176 | // to debug in chrome / desktop safari |
— | — | @@ -1177,7 +1177,7 @@ |
1178 | 1178 | ) { |
1179 | 1179 | return true; |
1180 | 1180 | } |
1181 | | - |
| 1181 | + |
1182 | 1182 | // Check if the client does not have flash and has the video tag |
1183 | 1183 | if ( navigator.mimeTypes && navigator.mimeTypes.length > 0 ) { |
1184 | 1184 | for ( var i = 0; i < navigator.mimeTypes.length; i++ ) { |
— | — | @@ -1192,8 +1192,8 @@ |
1193 | 1193 | } |
1194 | 1194 | } |
1195 | 1195 | } |
1196 | | - |
1197 | | - // For IE: |
| 1196 | + |
| 1197 | + // For IE: |
1198 | 1198 | var hasObj = true; |
1199 | 1199 | try { |
1200 | 1200 | var obj = new ActiveXObject( 'ShockwaveFlash.ShockwaveFlash' ); |
— | — | @@ -1212,7 +1212,7 @@ |
1213 | 1213 | // No video tag or flash, return false ( normal "install flash" user flow ) |
1214 | 1214 | return false; |
1215 | 1215 | } |
1216 | | - // Android 2 has some restrictions vs other mobile platforms |
| 1216 | + // Android 2 has some restrictions vs other mobile platforms |
1217 | 1217 | mw.isAndroid2 = function(){ |
1218 | 1218 | if ( navigator.userAgent.indexOf('Android 2.') != -1) { |
1219 | 1219 | return true; |
— | — | @@ -1583,7 +1583,7 @@ |
1584 | 1584 | |
1585 | 1585 | // Check for direct include of the mwEmbed.js |
1586 | 1586 | if ( src.indexOf( 'mwEmbed.js' ) !== -1 ) { |
1587 | | - mwpath = src.substr( 0, src.indexOf( 'mwEmbed.js' ) ); |
| 1587 | + mwpath = src.substr( 0, src.indexOf( 'mwEmbed.js' ) ); |
1588 | 1588 | } |
1589 | 1589 | |
1590 | 1590 | // Check for scriptLoader include of mwEmbed: |
— | — | @@ -1747,7 +1747,7 @@ |
1748 | 1748 | var src = js_elements[i].getAttribute( "src" ); |
1749 | 1749 | if ( src ) { |
1750 | 1750 | if ( // Check for mwEmbed.js ( debug mode ) |
1751 | | - ( src.indexOf( 'mwEmbed.js' ) !== -1 && src.indexOf( 'MediaWiki:Gadget') == -1 ) |
| 1751 | + ( src.indexOf( 'mwEmbed.js' ) !== -1 && src.indexOf( 'MediaWiki:Gadget') == -1 ) |
1752 | 1752 | || // Check for resource loader |
1753 | 1753 | ( |
1754 | 1754 | ( src.indexOf( 'mwResourceLoader.php' ) !== -1 || src.indexOf( 'ResourceLoader.php' ) !== -1 ) |
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/loader.js |
— | — | @@ -31,7 +31,7 @@ |
32 | 32 | // The attribution button |
33 | 33 | 'EmbedPlayer.AttributionButton' :{ |
34 | 34 | 'title' : 'Kaltura html5 video library', |
35 | | - 'href' : 'http://www.kaltura.org/project/HTML5_Video_Media_JavaScript_Library', |
| 35 | + 'href' : 'http://www.kaltura.org/project/HTML5_Video_Media_JavaScript_Library', |
36 | 36 | // Style icon to be applied |
37 | 37 | 'class' : 'kaltura-icon', |
38 | 38 | // An icon image url ( should be a 12x12 image or data url ) |
— | — | @@ -344,7 +344,7 @@ |
345 | 345 | if( !!document.createElement('video').canPlayType && !$j.browser.safari ) { |
346 | 346 | dependencyRequest[0].push( 'mw.EmbedPlayerNative' ) |
347 | 347 | } |
348 | | - |
| 348 | + |
349 | 349 | // Check if the iFrame player server is enabled: |
350 | 350 | if (mw.getConfig('EmbedPlayer.EnableIFramePlayerServer')) { |
351 | 351 | dependencyRequest.push('mw.EmbedPlayerNative'); |
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js |
— | — | @@ -1,7 +1,7 @@ |
2 | | -/** |
| 2 | +/** |
3 | 3 | * embedPlayer is the base class for html5 video tag javascript abstraction library |
4 | 4 | * embedPlayer include a few subclasses: |
5 | | -* |
| 5 | +* |
6 | 6 | * mediaPlayer Media player embed system ie: java, vlc or native. |
7 | 7 | * mediaElement Represents source media elements |
8 | 8 | * mw.PlayerControlBuilder Handles skinning of the player controls |
— | — | @@ -10,7 +10,7 @@ |
11 | 11 | /** |
12 | 12 | * Add the messages text: |
13 | 13 | */ |
14 | | - |
| 14 | + |
15 | 15 | mw.includeAllModuleMessages(); |
16 | 16 | |
17 | 17 | |
— | — | @@ -21,106 +21,106 @@ |
22 | 22 | mw.setDefaultConfig( 'EmbedPlayer.SourceAttributes', [ |
23 | 23 | // source id |
24 | 24 | 'id', |
25 | | - |
| 25 | + |
26 | 26 | // media url |
27 | 27 | 'src', |
28 | | - |
| 28 | + |
29 | 29 | // media codecs attribute ( if provided ) |
30 | 30 | 'codecs', |
31 | | - |
| 31 | + |
32 | 32 | // Title string for the source asset |
33 | 33 | 'title', |
34 | | - |
| 34 | + |
35 | 35 | // boolean if we support temporal url requests on the source media |
36 | 36 | 'URLTimeEncoding', |
37 | | - |
| 37 | + |
38 | 38 | // Media has a startOffset ( used for plugins that |
39 | 39 | // display ogg page time rather than presentation time |
40 | 40 | 'startOffset', |
41 | | - |
| 41 | + |
42 | 42 | // A hint to the duration of the media file so that duration |
43 | 43 | // can be displayed in the player without loading the media file |
44 | 44 | 'durationHint', |
45 | | - |
| 45 | + |
46 | 46 | // Media start time |
47 | 47 | 'start', |
48 | | - |
| 48 | + |
49 | 49 | // Media end time |
50 | 50 | 'end', |
51 | | - |
| 51 | + |
52 | 52 | // If the source is the default source |
53 | 53 | 'default', |
54 | | - |
| 54 | + |
55 | 55 | // Language key used for subtitle tracks |
56 | 56 | 'srclang', |
57 | | - |
| 57 | + |
58 | 58 | // titleKey ( used for api lookups ) |
59 | 59 | 'titleKey', |
60 | | - |
| 60 | + |
61 | 61 | // The provider type ( for what type of api query to make ) |
62 | 62 | 'provider_type', |
63 | | - |
| 63 | + |
64 | 64 | // The api url for the provider |
65 | | - 'provider_url' |
| 65 | + 'provider_url' |
66 | 66 | ] ); |
67 | 67 | |
68 | 68 | /** |
69 | 69 | * Adds jQuery binding for embedPlayer |
70 | 70 | */ |
71 | 71 | ( function( $ ) { |
72 | | - |
| 72 | + |
73 | 73 | /* |
74 | 74 | * embeds all players that match the rewrite player tags config Passes off |
75 | 75 | * request to the embedPlayer selector: |
76 | | - * |
| 76 | + * |
77 | 77 | * @param {Object} attributes Attributes to apply to embed players @param |
78 | 78 | * {Function} callback Function to call once embedding is done |
79 | 79 | */ |
80 | 80 | $.embedPlayers = function( attributes, callback) { |
81 | 81 | $j( mw.getConfig( 'EmbedPlayer.RewriteTags' ) ).embedPlayer( attributes, callback ); |
82 | 82 | }; |
83 | | - |
| 83 | + |
84 | 84 | /** |
85 | 85 | * Selector based embedPlayer jQuery binding |
86 | | - * |
| 86 | + * |
87 | 87 | * Rewrites all tags via a given selector |
88 | | - * |
| 88 | + * |
89 | 89 | * @param {object=} |
90 | 90 | * attributes Optional embedPlayer attributes for the given video |
91 | 91 | * interface. Attributes Object can include any key value pair |
92 | 92 | * that would otherwise be an attribute in the html element. |
93 | | - * |
| 93 | + * |
94 | 94 | * also see: mw.getConfig( 'EmbedPlayer.Attributes' ) |
95 | | - * |
| 95 | + * |
96 | 96 | * @param {Function=} |
97 | 97 | * callback Optional Function to be called once video interfaces |
98 | 98 | * are ready |
99 | | - * |
| 99 | + * |
100 | 100 | */ |
101 | 101 | $.fn.embedPlayer = function( attributes, callback ) { |
102 | 102 | mw.log( 'EmbedPlayer:: fn.embedPlayer' ); |
103 | 103 | var playerSelect = this.selector; |
104 | | - |
| 104 | + |
105 | 105 | // Define attributes if unset |
106 | 106 | if( !attributes ) { |
107 | 107 | attributes = {}; |
108 | 108 | } |
109 | | - |
| 109 | + |
110 | 110 | // Handle optional include of attributes argument: |
111 | 111 | if( typeof attributes == 'function' ){ |
112 | 112 | callback = attributes; |
113 | 113 | attributes = {}; |
114 | 114 | } |
115 | | - |
| 115 | + |
116 | 116 | $j( playerSelect ).each( function( index, playerElement) { |
117 | 117 | // make sure the playerElement has an id: |
118 | 118 | if( $j( playerElement ).attr('id') =='' ){ |
119 | 119 | $j( playerElement ).attr( "id", 'mwe_v' + ( index ) ); |
120 | 120 | } |
121 | | - |
| 121 | + |
122 | 122 | // If we are dynamically embedding on a "div" check if we can |
123 | 123 | // add a poster image behind the loader: |
124 | | - if( playerElement.nodeName.toLowerCase() == 'div' |
| 124 | + if( playerElement.nodeName.toLowerCase() == 'div' |
125 | 125 | && ( attributes.poster || $j(playerElement).attr( 'poster' ) ) ){ |
126 | 126 | var posterSrc = ( attributes.poster ) ? attributes.poster : $j(playerElement).attr( 'poster' ); |
127 | 127 | |
— | — | @@ -133,7 +133,7 @@ |
134 | 134 | if( !height ){ |
135 | 135 | var height = ( attributes.height )? attributes.height : '100%'; |
136 | 136 | } |
137 | | - |
| 137 | + |
138 | 138 | mw.log('EmbedPlayer:: set loading background: ' + posterSrc); |
139 | 139 | $j( playerElement ).append( |
140 | 140 | $j( '<img />' ) |
— | — | @@ -146,12 +146,12 @@ |
147 | 147 | ); |
148 | 148 | } |
149 | 149 | }); |
150 | | - |
| 150 | + |
151 | 151 | // If we have not detected browser plugin embed types do that now |
152 | 152 | if( ! mw.EmbedTypes.players ){ |
153 | 153 | mw.EmbedTypes.init(); |
154 | 154 | } |
155 | | - |
| 155 | + |
156 | 156 | // Create the Global Embed Player Manager ( if not already created ) |
157 | 157 | if( ! mw.playerManager ) { |
158 | 158 | mw.log( "EmbedPlayer::Create the player manager:" ); |
— | — | @@ -178,14 +178,14 @@ |
179 | 179 | // Add the player |
180 | 180 | mw.playerManager.addElement( playerElement, attributes); |
181 | 181 | } |
182 | | - |
| 182 | + |
183 | 183 | } ); |
184 | 184 | // run the callback directly if no players were added to the |
185 | 185 | // playerManager |
186 | 186 | if( !addedToPlayerManager && callback ){ |
187 | 187 | callback(); |
188 | 188 | } |
189 | | - |
| 189 | + |
190 | 190 | }); |
191 | 191 | }; |
192 | 192 | |
— | — | @@ -193,7 +193,7 @@ |
194 | 194 | |
195 | 195 | /** |
196 | 196 | * EmbedPlayerManager |
197 | | - * |
| 197 | + * |
198 | 198 | * Manages calls to embed video interfaces |
199 | 199 | */ |
200 | 200 | var EmbedPlayerManager = function( ) { |
— | — | @@ -201,12 +201,12 @@ |
202 | 202 | return this.init( ); |
203 | 203 | }; |
204 | 204 | EmbedPlayerManager.prototype = { |
205 | | - |
| 205 | + |
206 | 206 | // Functions to run after the video interface is ready |
207 | 207 | callbackFunctions : null, |
208 | | - |
| 208 | + |
209 | 209 | playerElementQueue: [], |
210 | | - |
| 210 | + |
211 | 211 | /** |
212 | 212 | * Constructor initializes callbackFunctions and playerList |
213 | 213 | */ |
— | — | @@ -214,11 +214,11 @@ |
215 | 215 | this.callbackFunctions = []; |
216 | 216 | this.playerList = []; |
217 | 217 | }, |
218 | | - |
| 218 | + |
219 | 219 | /** |
220 | 220 | * Adds a callback to the callbackFunctions list the callback functions are |
221 | 221 | * called once the players are ready. |
222 | | - * |
| 222 | + * |
223 | 223 | * @param {Function} |
224 | 224 | * callback Function to be called once players are ready |
225 | 225 | */ |
— | — | @@ -227,27 +227,27 @@ |
228 | 228 | this.callbackFunctions.push( callback ); |
229 | 229 | } |
230 | 230 | }, |
231 | | - |
| 231 | + |
232 | 232 | /** |
233 | 233 | * Get the list of players |
234 | 234 | */ |
235 | 235 | getPlayerList: function( ) { |
236 | 236 | return this.playerList; |
237 | 237 | }, |
238 | | - |
| 238 | + |
239 | 239 | /** |
240 | 240 | * Adds an Element for the embedPlayer to rewrite |
241 | | - * |
| 241 | + * |
242 | 242 | * uses embedPlayer interface on audio / video elements uses mvPlayList |
243 | 243 | * interface on playlist elements |
244 | | - * |
| 244 | + * |
245 | 245 | * Once a player interface is established the following chain of functions |
246 | 246 | * are called; |
247 | | - * |
| 247 | + * |
248 | 248 | * _this.checkPlayerSources() _this.checkForTimedText() |
249 | 249 | * _this.setupSourcePlayer() _this.inheritEmbedPlayer() |
250 | 250 | * _this.selectedPlayer.load() _this.showPlayer() |
251 | | - * |
| 251 | + * |
252 | 252 | * @param {Element} |
253 | 253 | * playerElement DOM element to be swapped |
254 | 254 | * @param {Object} |
— | — | @@ -256,58 +256,58 @@ |
257 | 257 | */ |
258 | 258 | addElement: function( playerElement, attributes ) { |
259 | 259 | var _this = this; |
260 | | - |
| 260 | + |
261 | 261 | if ( !playerElement.id || playerElement.id == '' ) { |
262 | 262 | // give the playerElement an id: |
263 | | - playerElement.id = 'vid' + ( this.playerList.length + 1 ); |
| 263 | + playerElement.id = 'vid' + ( this.playerList.length + 1 ); |
264 | 264 | } |
265 | 265 | mw.log('EmbedPlayerManager: addElement:: ' + playerElement.id ); |
266 | 266 | |
267 | 267 | // Add the element id to playerList |
268 | 268 | this.playerList.push( playerElement.id ); |
269 | | - |
| 269 | + |
270 | 270 | // Check for player attributes such as skins or plugins attributes |
271 | 271 | // that add to the request set |
272 | 272 | var playerDependencyRequest = []; |
273 | | - |
| 273 | + |
274 | 274 | // merge in any custom attributes |
275 | 275 | $j.extend( playerElement, attributes ); |
276 | | - |
| 276 | + |
277 | 277 | // Update the list of dependent libraries for the player |
278 | 278 | // ( allows extensions to add to the dependency list ) |
279 | 279 | mw.embedPlayerUpdateLibraryRequest( playerElement, playerDependencyRequest ); |
280 | | - |
| 280 | + |
281 | 281 | // Load any skins we need then swap in the interface |
282 | 282 | mw.load( playerDependencyRequest, function() { |
283 | 283 | var waitForMeta = true; |
284 | | - |
| 284 | + |
285 | 285 | // Be sure to "stop" the target ( sometimes firefox keeps playing |
286 | 286 | // the video even |
287 | 287 | // though its been removed from the DOM ) |
288 | 288 | if( playerElement.pause ){ |
289 | 289 | playerElement.pause(); |
290 | 290 | } |
291 | | - |
292 | | - |
| 291 | + |
| 292 | + |
293 | 293 | // Let extensions determine if its worthwhile to wait for metadata: |
294 | 294 | // We pass an object to the trigger to preserve reference values |
295 | | - var eventObject = { |
296 | | - 'playerElement' : playerElement, |
| 295 | + var eventObject = { |
| 296 | + 'playerElement' : playerElement, |
297 | 297 | 'waitForMeta' : waitForMeta |
298 | 298 | }; |
299 | 299 | $j( mw ).trigger( 'addElementWaitForMetaEvent', eventObject ); |
300 | | - |
| 300 | + |
301 | 301 | // update the waitForMeta |
302 | 302 | waitForMeta = eventObject[ 'waitForMeta' ]; |
303 | | - |
304 | | - |
| 303 | + |
| 304 | + |
305 | 305 | // Set the wait for meta flag if unset by extension |
306 | 306 | if( waitForMeta ){ |
307 | 307 | waitForMeta = _this.waitForMetaCheck( playerElement ); |
308 | 308 | } |
309 | | - |
| 309 | + |
310 | 310 | var ranPlayerSwapFlag = false; |
311 | | - |
| 311 | + |
312 | 312 | // Local callback to runPlayer swap once playerElement has metadata |
313 | 313 | function runPlayerSwap() { |
314 | 314 | if( ranPlayerSwapFlag ){ |
— | — | @@ -315,10 +315,10 @@ |
316 | 316 | } |
317 | 317 | ranPlayerSwapFlag = true; |
318 | 318 | mw.log("EmbedPlayer::runPlayerSwap::" + $j( playerElement ).attr('id') ); |
319 | | - |
| 319 | + |
320 | 320 | var playerInterface = new mw.EmbedPlayer( playerElement , attributes); |
321 | 321 | var swapPlayer = _this.swapEmbedPlayerElement( playerElement, playerInterface ); |
322 | | - |
| 322 | + |
323 | 323 | // Copy over any data attributes from the playerElement |
324 | 324 | if( mw.getConfig( 'EmbedPlayer.DataAttributes' ) ) { |
325 | 325 | var dataAttr = mw.getConfig( 'EmbedPlayer.DataAttributes' ); |
— | — | @@ -328,46 +328,46 @@ |
329 | 329 | } |
330 | 330 | } |
331 | 331 | } |
332 | | - |
| 332 | + |
333 | 333 | // Pass the id to any hook that needs to interface prior to |
334 | 334 | // checkPlayerSources |
335 | 335 | mw.log("EmbedPlayer::addElement :trigger " + playerInterface.id ); |
336 | 336 | $j( mw ).trigger ( 'newEmbedPlayerEvent', $j( '#' + playerInterface.id ).get(0) ); |
337 | | - |
| 337 | + |
338 | 338 | // Issue the checkPlayerSources call to the new player |
339 | 339 | // interface: |
340 | 340 | // make sure to use the element that is in the DOM: |
341 | 341 | $j( '#' + playerInterface.id ).get(0).checkPlayerSources(); |
342 | 342 | } |
343 | | - |
| 343 | + |
344 | 344 | if( waitForMeta ) { |
345 | | - mw.log('EmbedPlayer::WaitForMeta ( video missing height (' + |
346 | | - $j( playerElement ).attr('height') + '), width (' + |
| 345 | + mw.log('EmbedPlayer::WaitForMeta ( video missing height (' + |
| 346 | + $j( playerElement ).attr('height') + '), width (' + |
347 | 347 | $j( playerElement ).attr('width') + ') or duration: ' + |
348 | | - $j( playerElement ).attr('duration') |
| 348 | + $j( playerElement ).attr('duration') |
349 | 349 | ); |
350 | | - |
| 350 | + |
351 | 351 | playerElement.removeEventListener( "loadedmetadata", runPlayerSwap, true ); |
352 | 352 | playerElement.addEventListener( "loadedmetadata", runPlayerSwap, true ); |
353 | | - |
| 353 | + |
354 | 354 | // Time-out of 5 seconds ( maybe still playable but no timely |
355 | 355 | // metadata ) |
356 | 356 | setTimeout( runPlayerSwap, 5000 ); |
357 | 357 | return ; |
358 | | - } else { |
| 358 | + } else { |
359 | 359 | runPlayerSwap(); |
360 | 360 | return ; |
361 | | - } |
362 | | - }); |
| 361 | + } |
| 362 | + }); |
363 | 363 | }, |
364 | | - |
| 364 | + |
365 | 365 | /** |
366 | 366 | * Check for bogus resolutions of the media asset that has not loaded. |
367 | | - * |
| 367 | + * |
368 | 368 | * @return true if the resolution is "likely" to be updated by waiting for |
369 | 369 | * metadata false if the resolution has been set via an attribute or |
370 | 370 | * is already loaded |
371 | | - */ |
| 371 | + */ |
372 | 372 | waitForMetaCheck: function( playerElement ){ |
373 | 373 | var waitForMeta = false; |
374 | 374 | if( !playerElement ) |
— | — | @@ -378,19 +378,19 @@ |
379 | 379 | { |
380 | 380 | return false; |
381 | 381 | } |
382 | | - |
383 | | - |
| 382 | + |
| 383 | + |
384 | 384 | var width = $j( playerElement ).css( 'width' ); |
385 | 385 | var height = $j( playerElement ).css( 'height' ); |
386 | | - |
| 386 | + |
387 | 387 | // Css video defaults |
388 | | - if( $j( playerElement ).css( 'width' ) == '300px' && |
| 388 | + if( $j( playerElement ).css( 'width' ) == '300px' && |
389 | 389 | $j( playerElement ).css( 'height' ) == '150px' |
390 | 390 | ){ |
391 | 391 | waitForMeta = true; |
392 | 392 | } else { |
393 | 393 | // Check if we should wait for duration: |
394 | | - if( $j( playerElement ).attr( 'duration') || |
| 394 | + if( $j( playerElement ).attr( 'duration') || |
395 | 395 | $j( playerElement ).attr('durationHint') |
396 | 396 | ){ |
397 | 397 | // height, width and duration set; do not wait for meta data: |
— | — | @@ -399,31 +399,31 @@ |
400 | 400 | waitForMeta = true; |
401 | 401 | } |
402 | 402 | } |
403 | | - |
| 403 | + |
404 | 404 | // Firefox ~ sometimes ~ gives -1 for unloaded media |
405 | 405 | if ( $j(playerElement).attr( 'width' ) == -1 || $j(playerElement).attr( 'height' ) == -1 ) { |
406 | | - waitForMeta = true; |
| 406 | + waitForMeta = true; |
407 | 407 | } |
408 | | - |
| 408 | + |
409 | 409 | // Google Chrome / safari gives 0 width height for unloaded media |
410 | | - if( $j(playerElement).attr( 'width' ) === 0 || |
411 | | - $j(playerElement).attr( 'height' ) === 0 |
| 410 | + if( $j(playerElement).attr( 'width' ) === 0 || |
| 411 | + $j(playerElement).attr( 'height' ) === 0 |
412 | 412 | ) { |
413 | 413 | waitForMeta = true; |
414 | 414 | } |
415 | | - |
| 415 | + |
416 | 416 | // Firefox default width height is ~sometimes~ 150 / 300 |
417 | 417 | if( this.height == 150 && this.width == 300 ){ |
418 | | - waitForMeta = true; |
| 418 | + waitForMeta = true; |
419 | 419 | } |
420 | | - |
| 420 | + |
421 | 421 | // Make sure we have a src attribute or source child |
422 | 422 | // ( i.e not a video tag to be dynamically populated or looked up from |
423 | 423 | // xml resource description ) |
424 | | - if( waitForMeta && |
| 424 | + if( waitForMeta && |
425 | 425 | ( |
426 | 426 | $j( playerElement ).attr('src') || |
427 | | - $j( playerElement ).find("source[src]").length !== 0 |
| 427 | + $j( playerElement ).find("source[src]").length !== 0 |
428 | 428 | ) |
429 | 429 | ) { |
430 | 430 | // Detect src type ( if no type set ) |
— | — | @@ -431,15 +431,15 @@ |
432 | 432 | } else { |
433 | 433 | // playerElement is not likely to update its meta data ( no src ) |
434 | 434 | return false; |
435 | | - } |
| 435 | + } |
436 | 436 | }, |
437 | | - |
| 437 | + |
438 | 438 | /** |
439 | 439 | * swapEmbedPlayerElement |
440 | | - * |
| 440 | + * |
441 | 441 | * Takes a video element as input and swaps it out with an embed player |
442 | 442 | * interface |
443 | | - * |
| 443 | + * |
444 | 444 | * @param {Element} |
445 | 445 | * targetElement Element to be swapped |
446 | 446 | * @param {Object} |
— | — | @@ -449,7 +449,7 @@ |
450 | 450 | mw.log( 'EmbedPlayer::swapEmbedPlayerElement: ' + targetElement.id ); |
451 | 451 | // Create a new element to swap the player interface into |
452 | 452 | var swapPlayerElement = document.createElement('div'); |
453 | | - |
| 453 | + |
454 | 454 | // Get properties / methods from playerInterface |
455 | 455 | for ( var method in playerInterface ) { |
456 | 456 | if ( method != 'readyState' ) { // readyState crashes IE ( don't |
— | — | @@ -457,7 +457,7 @@ |
458 | 458 | swapPlayerElement[ method ] = playerInterface[ method ]; |
459 | 459 | } |
460 | 460 | } |
461 | | - |
| 461 | + |
462 | 462 | // Check if we are using native controls ( should keep the video embed |
463 | 463 | // around ) |
464 | 464 | if( playerInterface.useNativePlayerControls() ) { |
— | — | @@ -465,20 +465,20 @@ |
466 | 466 | .attr( 'id', playerInterface.pid ) |
467 | 467 | .addClass( 'nativeEmbedPlayerPid' ) |
468 | 468 | .show() |
469 | | - .after( |
| 469 | + .after( |
470 | 470 | $j( swapPlayerElement ).css( 'display', 'none' ) |
471 | 471 | ); |
472 | 472 | } else { |
473 | 473 | $j( targetElement ).replaceWith( swapPlayerElement ); |
474 | 474 | } |
475 | | - |
476 | | - |
| 475 | + |
| 476 | + |
477 | 477 | // Set swapPlayerElement has height / width set and set to loading: |
478 | 478 | $j( swapPlayerElement ).css( { |
479 | 479 | 'width' : playerInterface.width + 'px', |
480 | 480 | 'height' : playerInterface.height + 'px' |
481 | 481 | } ); |
482 | | - |
| 482 | + |
483 | 483 | // If we don't already have a loadSpiner add one: |
484 | 484 | if( $j('#loadingSpinner_' + playerInterface.id ).length == 0 ){ |
485 | 485 | if( playerInterface.useNativePlayerControls() ) { |
— | — | @@ -486,7 +486,7 @@ |
487 | 487 | .getAbsoluteOverlaySpinner() |
488 | 488 | .attr('id', 'loadingSpinner_' + playerInterface.id ); |
489 | 489 | }else{ |
490 | | - $j( swapPlayerElement ).append( |
| 490 | + $j( swapPlayerElement ).append( |
491 | 491 | $j('<div />') |
492 | 492 | .loadingSpinner() |
493 | 493 | ); |
— | — | @@ -494,14 +494,14 @@ |
495 | 495 | } |
496 | 496 | return swapPlayerElement; |
497 | 497 | }, |
498 | | - |
499 | | - |
| 498 | + |
| 499 | + |
500 | 500 | /** |
501 | 501 | * Player ready will run the global callbacks once players are "ready" |
502 | | - * |
| 502 | + * |
503 | 503 | * This enables mw.ready event to expose video tag elements as if the |
504 | 504 | * videotag was supported natively. |
505 | | - * |
| 505 | + * |
506 | 506 | * @param {Object} |
507 | 507 | * player The EmbedPlayer object |
508 | 508 | */ |
— | — | @@ -509,14 +509,14 @@ |
510 | 510 | var _this = this; |
511 | 511 | mw.log( 'EmbedPlayer::ReadyToPlay callback player:' + player.id ); |
512 | 512 | player.readyToPlay = true; |
513 | | - |
| 513 | + |
514 | 514 | // Remove the player loader spinner: |
515 | 515 | $j('#loadingSpinner_' + player.id ).remove(); |
516 | | - |
| 516 | + |
517 | 517 | // Run the player ready trigger |
518 | 518 | $j( player ).trigger( 'playerReady' ); |
519 | | - |
520 | | - var is_ready = true; |
| 519 | + |
| 520 | + var is_ready = true; |
521 | 521 | for ( var i = 0; i < this.playerList.length; i++ ) { |
522 | 522 | var currentPlayer = $j( '#' + this.playerList[i] ).get( 0 ); |
523 | 523 | if ( player ) { |
— | — | @@ -527,7 +527,7 @@ |
528 | 528 | if ( is_ready ) { |
529 | 529 | // Be sure to remove any player loader spinners |
530 | 530 | $j('.playerLoadingSpinner').remove(); |
531 | | - |
| 531 | + |
532 | 532 | mw.log( "EmbedPlayer::All on-page players ready run playerManager callbacks" ); |
533 | 533 | // Run queued functions |
534 | 534 | if( _this.callbackFunctions ) { |
— | — | @@ -541,7 +541,7 @@ |
542 | 542 | |
543 | 543 | /** |
544 | 544 | * mediaSource class represents a source for a media element. |
545 | | - * |
| 545 | + * |
546 | 546 | * @param {Element} |
547 | 547 | * element: MIME type of the source. |
548 | 548 | * @constructor |
— | — | @@ -553,50 +553,50 @@ |
554 | 554 | mediaSource.prototype = { |
555 | 555 | // MIME type of the source. |
556 | 556 | mimeType:null, |
557 | | - |
| 557 | + |
558 | 558 | // URI of the source. |
559 | 559 | uri:null, |
560 | | - |
| 560 | + |
561 | 561 | // Title of the source. |
562 | 562 | title: null, |
563 | | - |
| 563 | + |
564 | 564 | // True if the source has been marked as the default. |
565 | 565 | markedDefault: false, |
566 | | - |
| 566 | + |
567 | 567 | // True if the source supports url specification of offset and duration |
568 | 568 | URLTimeEncoding:false, |
569 | | - |
| 569 | + |
570 | 570 | // Start offset of the requested segment |
571 | 571 | startOffset: 0, |
572 | | - |
| 572 | + |
573 | 573 | // Duration of the requested segment (0 if not known) |
574 | 574 | duration:0, |
575 | | - |
| 575 | + |
576 | 576 | // Is the source playable |
577 | 577 | is_playable: null, |
578 | | - |
| 578 | + |
579 | 579 | // source id |
580 | 580 | id: null, |
581 | | - |
| 581 | + |
582 | 582 | // Start time in npt format |
583 | 583 | start_npt: null, |
584 | | - |
| 584 | + |
585 | 585 | // End time in npt format |
586 | 586 | end_npt: null, |
587 | | - |
| 587 | + |
588 | 588 | // A provider "id" to identify api request type |
589 | 589 | provider_type : null, |
590 | 590 | |
591 | 591 | // The api url for the provider |
592 | | - provider_url : null, |
593 | | - |
| 592 | + provider_url : null, |
| 593 | + |
594 | 594 | /** |
595 | 595 | * MediaSource constructor: |
596 | 596 | */ |
597 | 597 | init : function( element ) { |
598 | 598 | // mw.log('EmbedPlayer::adding mediaSource: ' + element); |
599 | 599 | this.src = $j( element ).attr( 'src' ); |
600 | | - |
| 600 | + |
601 | 601 | // Set default URLTimeEncoding if we have a time url: |
602 | 602 | // not ideal way to discover if content is on an oggz_chop server. |
603 | 603 | // should check some other way. |
— | — | @@ -604,9 +604,9 @@ |
605 | 605 | if ( typeof pUrl[ 'queryKey' ][ 't' ] != 'undefined' ) { |
606 | 606 | this.URLTimeEncoding = true; |
607 | 607 | } |
608 | | - |
| 608 | + |
609 | 609 | var sourceAttr = mw.getConfig( 'EmbedPlayer.SourceAttributes' ); |
610 | | - |
| 610 | + |
611 | 611 | for ( var i = 0; i < sourceAttr.length; i++ ) { // array loop: |
612 | 612 | var attr = sourceAttr[ i ]; |
613 | 613 | var attr_value = element.getAttribute( attr ); |
— | — | @@ -614,8 +614,8 @@ |
615 | 615 | this[ attr ] = attr_value; |
616 | 616 | } |
617 | 617 | } |
618 | | - |
619 | | - |
| 618 | + |
| 619 | + |
620 | 620 | // Set the content type: |
621 | 621 | if ( $j( element ).attr( 'type' ) ) { |
622 | 622 | this.mimeType = $j( element ).attr( 'type' ); |
— | — | @@ -627,32 +627,32 @@ |
628 | 628 | } else { |
629 | 629 | this.mimeType = this.detectType( this.src ); |
630 | 630 | } |
631 | | - |
| 631 | + |
632 | 632 | // Conform the mime type to ogg |
633 | 633 | if( this.mimeType == 'video/theora') { |
634 | 634 | this.mimeType = 'video/ogg'; |
635 | 635 | } |
636 | | - |
| 636 | + |
637 | 637 | if( this.mimeType == 'audio/vorbis') { |
638 | 638 | this.mimeType = 'audio/ogg'; |
639 | 639 | } |
640 | | - |
| 640 | + |
641 | 641 | // Check for parent elements ( supplies categories in "track" ) |
642 | 642 | if( $j( element ).parent().attr('category') ) { |
643 | 643 | this.category = $j( element ).parent().attr('category'); |
644 | 644 | } |
645 | | - |
| 645 | + |
646 | 646 | if( $j( element ).attr( 'default' ) ){ |
647 | 647 | this.markedDefault = true; |
648 | 648 | } |
649 | | - |
| 649 | + |
650 | 650 | // Get the url duration ( if applicable ) |
651 | 651 | this.getURLDuration(); |
652 | 652 | }, |
653 | | - |
| 653 | + |
654 | 654 | /** |
655 | 655 | * Update Source title via Element |
656 | | - * |
| 656 | + * |
657 | 657 | * @param {Element} |
658 | 658 | * element Source element to update attributes from |
659 | 659 | */ |
— | — | @@ -662,10 +662,10 @@ |
663 | 663 | this.title = $j( element ).attr( "title" ); |
664 | 664 | } |
665 | 665 | }, |
666 | | - |
| 666 | + |
667 | 667 | /** |
668 | 668 | * Updates the src time and start & end |
669 | | - * |
| 669 | + * |
670 | 670 | * @param {String} |
671 | 671 | * start_time: in NPT format |
672 | 672 | * @param {String} |
— | — | @@ -681,23 +681,23 @@ |
682 | 682 | if ( !mw.npt2seconds( start_npt ) ) { |
683 | 683 | start_npt = this.start_npt; |
684 | 684 | } |
685 | | - |
| 685 | + |
686 | 686 | if ( !mw.npt2seconds( end_npt ) ) { |
687 | 687 | end_npt = this.end_npt; |
688 | 688 | } |
689 | | - |
690 | | - this.src = mw.replaceUrlParams( this.src, { |
691 | | - 't': start_npt + '/' + end_npt |
| 689 | + |
| 690 | + this.src = mw.replaceUrlParams( this.src, { |
| 691 | + 't': start_npt + '/' + end_npt |
692 | 692 | }); |
693 | | - |
| 693 | + |
694 | 694 | // update the duration |
695 | 695 | this.getURLDuration(); |
696 | 696 | } |
697 | 697 | }, |
698 | | - |
| 698 | + |
699 | 699 | /** |
700 | 700 | * Sets the duration and sets the end time if unset |
701 | | - * |
| 701 | + * |
702 | 702 | * @param {Float} |
703 | 703 | * duration: in seconds |
704 | 704 | */ |
— | — | @@ -707,10 +707,10 @@ |
708 | 708 | this.end_npt = mw.seconds2npt( this.startOffset + duration ); |
709 | 709 | } |
710 | 710 | }, |
711 | | - |
| 711 | + |
712 | 712 | /** |
713 | 713 | * MIME type accessors function. |
714 | | - * |
| 714 | + * |
715 | 715 | * @return {String} the MIME type of the source. |
716 | 716 | */ |
717 | 717 | getMIMEType: function() { |
— | — | @@ -720,10 +720,10 @@ |
721 | 721 | this.mimeType = this.detectType( this.src ); |
722 | 722 | return this.mimeType; |
723 | 723 | }, |
724 | | - |
| 724 | + |
725 | 725 | /** |
726 | 726 | * URI function. |
727 | | - * |
| 727 | + * |
728 | 728 | * @param {Number} |
729 | 729 | * serverSeekTime Int: Used to adjust the URI for url based |
730 | 730 | * seeks) |
— | — | @@ -739,21 +739,21 @@ |
740 | 740 | } |
741 | 741 | return mw.replaceUrlParams( this.src, |
742 | 742 | { |
743 | | - 't': mw.seconds2npt( serverSeekTime ) + endvar |
| 743 | + 't': mw.seconds2npt( serverSeekTime ) + endvar |
744 | 744 | } |
745 | | - ); |
| 745 | + ); |
746 | 746 | }, |
747 | | - |
| 747 | + |
748 | 748 | /** |
749 | 749 | * Title accessor function. |
750 | | - * |
| 750 | + * |
751 | 751 | * @return {String} Title of the source. |
752 | 752 | */ |
753 | 753 | getTitle : function() { |
754 | 754 | if( this.title ){ |
755 | 755 | return this.title; |
756 | 756 | } |
757 | | - |
| 757 | + |
758 | 758 | // Return a Title based on mime type: |
759 | 759 | switch( this.getMIMEType() ) { |
760 | 760 | case 'video/h264' : |
— | — | @@ -775,21 +775,21 @@ |
776 | 776 | return 'AVI video'; // FIXME: i18n |
777 | 777 | break; |
778 | 778 | } |
779 | | - |
| 779 | + |
780 | 780 | // Return tilte based on file name: |
781 | 781 | var urlParts = mw.parseUri( this.getSrc() ); |
782 | 782 | if( urlParts.file ){ |
783 | 783 | return urlParts.file; |
784 | 784 | } |
785 | | - |
| 785 | + |
786 | 786 | // Return the mime type string if not known type. |
787 | 787 | return this.mimeType; |
788 | 788 | }, |
789 | | - |
| 789 | + |
790 | 790 | /** |
791 | | - * |
| 791 | + * |
792 | 792 | * Get Duration of the media in milliseconds from the source url. |
793 | | - * |
| 793 | + * |
794 | 794 | * Supports media_url?t=ntp_start/ntp_end url request format |
795 | 795 | */ |
796 | 796 | getURLDuration : function() { |
— | — | @@ -813,10 +813,10 @@ |
814 | 814 | } |
815 | 815 | } |
816 | 816 | }, |
817 | | - |
| 817 | + |
818 | 818 | /** |
819 | 819 | * Attempts to detect the type of a media file based on the URI. |
820 | | - * |
| 820 | + * |
821 | 821 | * @param {String} |
822 | 822 | * uri URI of the media file. |
823 | 823 | * @return {String} The guessed MIME type of the file. |
— | — | @@ -875,11 +875,11 @@ |
876 | 876 | |
877 | 877 | /** |
878 | 878 | * A media element corresponding to a <video> element. |
879 | | - * |
| 879 | + * |
880 | 880 | * It is implemented as a collection of mediaSource objects. The media sources |
881 | 881 | * will be initialized from the <video> element, its child <source> elements, |
882 | 882 | * and/or the ROE file referenced by the <video> element. |
883 | | - * |
| 883 | + * |
884 | 884 | * @param {element} |
885 | 885 | * videoElement <video> element used for initialization. |
886 | 886 | * @constructor |
— | — | @@ -889,28 +889,28 @@ |
890 | 890 | } |
891 | 891 | |
892 | 892 | mediaElement.prototype = { |
893 | | - |
| 893 | + |
894 | 894 | // The array of mediaSource elements. |
895 | 895 | sources: null, |
896 | | - |
| 896 | + |
897 | 897 | // flag for ROE data being added. |
898 | 898 | addedROEData: false, |
899 | | - |
| 899 | + |
900 | 900 | // Selected mediaSource element. |
901 | 901 | selectedSource: null, |
902 | | - |
| 902 | + |
903 | 903 | // Media element thumbnail |
904 | 904 | thumbnail: null, |
905 | | - |
| 905 | + |
906 | 906 | // Media element linkback |
907 | 907 | linkback: null, |
908 | 908 | |
909 | 909 | /** |
910 | 910 | * Media Element constructor |
911 | | - * |
| 911 | + * |
912 | 912 | * Sets up a mediaElement from a provided top level "video" element adds any |
913 | 913 | * child sources that are found |
914 | | - * |
| 914 | + * |
915 | 915 | * @param {Element} |
916 | 916 | * videoElement Element that has src attribute or has children |
917 | 917 | * source elements |
— | — | @@ -919,22 +919,22 @@ |
920 | 920 | var _this = this; |
921 | 921 | mw.log( "EmbedPlayer::mediaElement:init:" + videoElement.id ); |
922 | 922 | this.sources = new Array(); |
923 | | - |
| 923 | + |
924 | 924 | // Process the videoElement as a source element: |
925 | 925 | if ( $j( videoElement ).attr( "src" ) ) { |
926 | 926 | _this.tryAddSource( videoElement ); |
927 | 927 | } |
928 | | - |
| 928 | + |
929 | 929 | // Process elements source children |
930 | 930 | $j( videoElement ).find( 'source,track' ).each( function( ) { |
931 | 931 | _this.tryAddSource( this ); |
932 | 932 | } ); |
933 | 933 | }, |
934 | | - |
| 934 | + |
935 | 935 | /** |
936 | 936 | * Updates the time request for all sources that have a standard time |
937 | 937 | * request argument (ie &t=start_time/end_time) |
938 | | - * |
| 938 | + * |
939 | 939 | * @param {String} |
940 | 940 | * start_npt Start time in npt format |
941 | 941 | * @param {String} |
— | — | @@ -946,27 +946,27 @@ |
947 | 947 | mediaSource.updateSrcTime( start_npt, end_npt ); |
948 | 948 | } ); |
949 | 949 | }, |
950 | | - |
| 950 | + |
951 | 951 | /** |
952 | 952 | * Check for Timed Text tracks |
953 | | - * |
| 953 | + * |
954 | 954 | * @return {Boolean} True if text tracks exist, false if no text tracks are |
955 | 955 | * found |
956 | 956 | */ |
957 | 957 | textSourceExists: function() { |
958 | 958 | for ( var i = 0; i < this.sources.length; i++ ) { |
959 | | - if ( this.sources[i].mimeType == 'text/cmml' || |
960 | | - this.sources[i].mimeType == 'text/x-srt' ) |
| 959 | + if ( this.sources[i].mimeType == 'text/cmml' || |
| 960 | + this.sources[i].mimeType == 'text/x-srt' ) |
961 | 961 | { |
962 | 962 | return true; |
963 | 963 | } |
964 | 964 | }; |
965 | 965 | return false; |
966 | 966 | }, |
967 | | - |
| 967 | + |
968 | 968 | /** |
969 | 969 | * Returns the array of mediaSources of this element. |
970 | | - * |
| 970 | + * |
971 | 971 | * @param {String} |
972 | 972 | * [mimeFilter] Filter criteria for set of mediaSources to return |
973 | 973 | * @return {Array} mediaSource elements. |
— | — | @@ -979,17 +979,17 @@ |
980 | 980 | var source_set = new Array(); |
981 | 981 | for ( var i = 0; i < this.sources.length ; i++ ) { |
982 | 982 | if ( this.sources[i].mimeType && |
983 | | - this.sources[i].mimeType.indexOf( mimeFilter ) != -1 ) |
| 983 | + this.sources[i].mimeType.indexOf( mimeFilter ) != -1 ) |
984 | 984 | { |
985 | 985 | source_set.push( this.sources[i] ); |
986 | 986 | } |
987 | 987 | } |
988 | 988 | return source_set; |
989 | 989 | }, |
990 | | - |
| 990 | + |
991 | 991 | /** |
992 | 992 | * Selects a source by id |
993 | | - * |
| 993 | + * |
994 | 994 | * @param {String} |
995 | 995 | * source_id Id of the source to select. |
996 | 996 | * @return {MediaSource} The selected mediaSource or null if not found |
— | — | @@ -1002,10 +1002,10 @@ |
1003 | 1003 | } |
1004 | 1004 | return null; |
1005 | 1005 | }, |
1006 | | - |
| 1006 | + |
1007 | 1007 | /** |
1008 | 1008 | * Selects a particular source for playback updating the "selectedSource" |
1009 | | - * |
| 1009 | + * |
1010 | 1010 | * @param {Number} |
1011 | 1011 | * index Index of source element to set as selectedSource |
1012 | 1012 | */ |
— | — | @@ -1021,22 +1021,22 @@ |
1022 | 1022 | } |
1023 | 1023 | } |
1024 | 1024 | }, |
1025 | | - |
| 1025 | + |
1026 | 1026 | /** |
1027 | 1027 | * Selects the default source via cookie preference, default marked, or by |
1028 | 1028 | * id order |
1029 | 1029 | */ |
1030 | | - autoSelectSource: function() { |
| 1030 | + autoSelectSource: function() { |
1031 | 1031 | mw.log( 'EmbedPlayer::mediaElement::autoSelectSource' ); |
1032 | 1032 | // Select the default source |
1033 | 1033 | var playableSources = this.getPlayableSources(); |
1034 | 1034 | var flash_flag = ogg_flag = false; |
1035 | | - |
| 1035 | + |
1036 | 1036 | // Check if there are any playableSources |
1037 | 1037 | if( playableSources.length == 0 ){ |
1038 | 1038 | return false; |
1039 | 1039 | } |
1040 | | - |
| 1040 | + |
1041 | 1041 | // Set via user-preference |
1042 | 1042 | for ( var source = 0; source < playableSources.length; source++ ) { |
1043 | 1043 | var mimeType = playableSources[source].mimeType; |
— | — | @@ -1046,7 +1046,7 @@ |
1047 | 1047 | return true; |
1048 | 1048 | } |
1049 | 1049 | } |
1050 | | - |
| 1050 | + |
1051 | 1051 | // Set via marked default: |
1052 | 1052 | for ( var source = 0; source < playableSources.length; source++ ) { |
1053 | 1053 | if ( playableSources[ source ].markedDefault ) { |
— | — | @@ -1055,7 +1055,7 @@ |
1056 | 1056 | return true; |
1057 | 1057 | } |
1058 | 1058 | } |
1059 | | - |
| 1059 | + |
1060 | 1060 | // Prefer native playback |
1061 | 1061 | for ( var source = 0; source < playableSources.length; source++ ) { |
1062 | 1062 | var mimeType = playableSources[source].mimeType; |
— | — | @@ -1066,15 +1066,15 @@ |
1067 | 1067 | return true; |
1068 | 1068 | } |
1069 | 1069 | } |
1070 | | - |
| 1070 | + |
1071 | 1071 | // Set h264 via native or flash fallback |
1072 | 1072 | for ( var source = 0; source < playableSources.length; source++ ) { |
1073 | 1073 | var mimeType = playableSources[source].mimeType; |
1074 | 1074 | var player = mw.EmbedTypes.players.defaultPlayer( mimeType ); |
1075 | | - if ( mimeType == 'video/h264' |
1076 | | - && player |
1077 | | - && ( |
1078 | | - player.library == 'Native' |
| 1075 | + if ( mimeType == 'video/h264' |
| 1076 | + && player |
| 1077 | + && ( |
| 1078 | + player.library == 'Native' |
1079 | 1079 | || |
1080 | 1080 | player.library == 'Kplayer' |
1081 | 1081 | ) |
— | — | @@ -1084,7 +1084,7 @@ |
1085 | 1085 | return true; |
1086 | 1086 | } |
1087 | 1087 | }; |
1088 | | - |
| 1088 | + |
1089 | 1089 | // Else just select first source |
1090 | 1090 | if ( !this.selectedSource ) { |
1091 | 1091 | mw.log( 'set via first source:' + playableSources[0] ); |
— | — | @@ -1094,33 +1094,33 @@ |
1095 | 1095 | // No Source found so no source selected |
1096 | 1096 | return false; |
1097 | 1097 | }, |
1098 | | - |
| 1098 | + |
1099 | 1099 | /** |
1100 | 1100 | * check if the mime is ogg |
1101 | | - */ |
| 1101 | + */ |
1102 | 1102 | isOgg: function( mimeType ){ |
1103 | | - if ( mimeType == 'video/ogg' |
1104 | | - || mimeType == 'ogg/video' |
1105 | | - || mimeType == 'video/annodex' |
| 1103 | + if ( mimeType == 'video/ogg' |
| 1104 | + || mimeType == 'ogg/video' |
| 1105 | + || mimeType == 'video/annodex' |
1106 | 1106 | || mimeType == 'application/ogg' |
1107 | 1107 | ) { |
1108 | 1108 | return true; |
1109 | 1109 | } |
1110 | 1110 | return false; |
1111 | 1111 | }, |
1112 | | - |
| 1112 | + |
1113 | 1113 | /** |
1114 | 1114 | * Returns the thumbnail URL for the media element. |
1115 | | - * |
| 1115 | + * |
1116 | 1116 | * @returns {String} thumbnail URL |
1117 | 1117 | */ |
1118 | 1118 | getPosterSrc: function( ) { |
1119 | 1119 | return this.poster; |
1120 | 1120 | }, |
1121 | | - |
| 1121 | + |
1122 | 1122 | /** |
1123 | 1123 | * Checks whether there is a stream of a specified MIME type. |
1124 | | - * |
| 1124 | + * |
1125 | 1125 | * @param {String} |
1126 | 1126 | * mimeType MIME type to check. |
1127 | 1127 | * @return {Boolean} true if sources include MIME false if not. |
— | — | @@ -1135,7 +1135,7 @@ |
1136 | 1136 | } |
1137 | 1137 | return false; |
1138 | 1138 | }, |
1139 | | - |
| 1139 | + |
1140 | 1140 | /** |
1141 | 1141 | * Checks if media is a playable type |
1142 | 1142 | */ |
— | — | @@ -1146,11 +1146,11 @@ |
1147 | 1147 | return false; |
1148 | 1148 | } |
1149 | 1149 | }, |
1150 | | - |
| 1150 | + |
1151 | 1151 | /** |
1152 | 1152 | * Adds a single mediaSource using the provided element if the element has a |
1153 | 1153 | * 'src' attribute. |
1154 | | - * |
| 1154 | + * |
1155 | 1155 | * @param {Element} |
1156 | 1156 | * element <video>, <source> or <mediaSource> <text> element. |
1157 | 1157 | */ |
— | — | @@ -1170,20 +1170,20 @@ |
1171 | 1171 | } |
1172 | 1172 | // Create a new source |
1173 | 1173 | var source = new mediaSource( element ); |
1174 | | - |
| 1174 | + |
1175 | 1175 | this.sources.push( source ); |
1176 | 1176 | // mw.log( 'tryAddSource: added source ::' + source + 'sl:' + |
1177 | 1177 | // this.sources.length ); |
1178 | 1178 | return source; |
1179 | 1179 | }, |
1180 | | - |
| 1180 | + |
1181 | 1181 | /** |
1182 | 1182 | * Get playable sources |
1183 | | - * |
| 1183 | + * |
1184 | 1184 | * @returns {Array} of playable sources |
1185 | 1185 | */ |
1186 | 1186 | getPlayableSources: function() { |
1187 | | - var playableSources = []; |
| 1187 | + var playableSources = []; |
1188 | 1188 | for ( var i = 0; i < this.sources.length; i++ ) { |
1189 | 1189 | if ( this.isPlayableType( this.sources[i].mimeType ) ) { |
1190 | 1190 | playableSources.push( this.sources[i] ); |
— | — | @@ -1193,10 +1193,10 @@ |
1194 | 1194 | }; |
1195 | 1195 | return playableSources; |
1196 | 1196 | }, |
1197 | | - |
| 1197 | + |
1198 | 1198 | /** |
1199 | 1199 | * Imports media sources from ROE data. |
1200 | | - * |
| 1200 | + * |
1201 | 1201 | * @param roe_data |
1202 | 1202 | * ROE data. |
1203 | 1203 | */ |
— | — | @@ -1206,12 +1206,12 @@ |
1207 | 1207 | var _this = this; |
1208 | 1208 | if ( roe_data ) { |
1209 | 1209 | var $roeParsed = $j( roe_data.pay_load ); |
1210 | | - |
| 1210 | + |
1211 | 1211 | // Add media sources: |
1212 | 1212 | $roeParsed.find("mediaSource").each( function( inx, source ) { |
1213 | 1213 | _this.tryAddSource( source ); |
1214 | 1214 | } ); |
1215 | | - |
| 1215 | + |
1216 | 1216 | // Set the thumbnail: |
1217 | 1217 | $roeParsed.find( 'img' ).each( function( inx, n ) { |
1218 | 1218 | if ( $j( n ).attr( "id" ) == "stream_thumb" ) { |
— | — | @@ -1219,7 +1219,7 @@ |
1220 | 1220 | _this.poster = $j( n ).attr( "src" ); |
1221 | 1221 | } |
1222 | 1222 | } ); |
1223 | | - |
| 1223 | + |
1224 | 1224 | // Set the linkback: |
1225 | 1225 | $roeParsed.find( 'link' ).each( function( inx, n ) { |
1226 | 1226 | if ( $j( n ).attr( 'id' ) == 'html_linkback' ) { |
— | — | @@ -1236,7 +1236,7 @@ |
1237 | 1237 | |
1238 | 1238 | /** |
1239 | 1239 | * Base embedPlayer object |
1240 | | - * |
| 1240 | + * |
1241 | 1241 | * @param {Element} |
1242 | 1242 | * element, the element used for initialization. |
1243 | 1243 | * @param {Object} |
— | — | @@ -1249,63 +1249,63 @@ |
1250 | 1250 | }; |
1251 | 1251 | |
1252 | 1252 | mw.EmbedPlayer.prototype = { |
1253 | | - |
| 1253 | + |
1254 | 1254 | // The mediaElement object containing all mediaSource objects |
1255 | 1255 | 'mediaElement' : null, |
1256 | | - |
| 1256 | + |
1257 | 1257 | // Object that describes the supported feature set of the underling plugin / |
1258 | 1258 | // player |
1259 | 1259 | 'supports': { }, |
1260 | | - |
| 1260 | + |
1261 | 1261 | // Preview mode flag, |
1262 | 1262 | // some plugins don't seek accurately but in preview mode we need |
1263 | 1263 | // accurate seeks so we do tricks like hide the image until its ready |
1264 | 1264 | 'preview_mode' : false, |
1265 | | - |
| 1265 | + |
1266 | 1266 | // Ready to play |
1267 | 1267 | // NOTE: we should switch over to setting the html5 video ready state |
1268 | | - 'readyToPlay' : false, |
1269 | | - |
| 1268 | + 'readyToPlay' : false, |
| 1269 | + |
1270 | 1270 | // Stores the loading errors |
1271 | | - 'loadError' : false, |
1272 | | - |
| 1271 | + 'loadError' : false, |
| 1272 | + |
1273 | 1273 | // Thumbnail updating flag ( to avoid rewriting an thumbnail thats already |
1274 | 1274 | // being updated) |
1275 | 1275 | 'thumbnail_updating' : false, |
1276 | | - |
| 1276 | + |
1277 | 1277 | // Thumbnail display flag |
1278 | 1278 | 'thumbnail_disp' : true, |
1279 | | - |
| 1279 | + |
1280 | 1280 | // Local variable to hold CMML meeta data about the current clip |
1281 | 1281 | // for more on CMML see: http://wiki.xiph.org/CMML |
1282 | 1282 | 'cmmlData': null, |
1283 | | - |
| 1283 | + |
1284 | 1284 | // Stores the seek time request, Updated by the doSeek function |
1285 | 1285 | 'serverSeekTime' : 0, |
1286 | | - |
| 1286 | + |
1287 | 1287 | // If the embedPlayer is current 'seeking' |
1288 | 1288 | 'seeking' : false, |
1289 | | - |
| 1289 | + |
1290 | 1290 | // Percent of the clip buffered: |
1291 | 1291 | 'bufferedPercent' : 0, |
1292 | | - |
| 1292 | + |
1293 | 1293 | // Holds the timer interval function |
1294 | 1294 | 'monitorTimerId' : null, |
1295 | | - |
| 1295 | + |
1296 | 1296 | // Buffer flags |
1297 | 1297 | 'bufferStartFlag' : false, |
1298 | 1298 | 'bufferEndFlag' : false, |
1299 | | - |
| 1299 | + |
1300 | 1300 | // On done playing |
1301 | 1301 | 'donePlayingCount' : 0 |
1302 | 1302 | , |
1303 | 1303 | // if player events should be Propagated |
1304 | 1304 | '_propagateEvents': true, |
1305 | | - |
1306 | | - |
| 1305 | + |
| 1306 | + |
1307 | 1307 | /** |
1308 | 1308 | * embedPlayer constructor |
1309 | | - * |
| 1309 | + * |
1310 | 1310 | * @param {Element} |
1311 | 1311 | * element DOM element that we are building the player interface |
1312 | 1312 | * for. |
— | — | @@ -1319,7 +1319,7 @@ |
1320 | 1320 | if ( !customAttributes ) { |
1321 | 1321 | customAttributes = { }; |
1322 | 1322 | } |
1323 | | - |
| 1323 | + |
1324 | 1324 | var playerAttributes = mw.getConfig( 'EmbedPlayer.Attributes' ); |
1325 | 1325 | // Setup the player Interface from supported attributes: |
1326 | 1326 | for ( var attr in playerAttributes ) { |
— | — | @@ -1340,17 +1340,17 @@ |
1341 | 1341 | if( this[ attr ] == "true" ) this[attr] = true; |
1342 | 1342 | } |
1343 | 1343 | // |
1344 | | - |
1345 | | - |
| 1344 | + |
| 1345 | + |
1346 | 1346 | if( this.apiTitleKey ){ |
1347 | 1347 | this.apiTitleKey = decodeURI( this.apiTitleKey ); |
1348 | 1348 | } |
1349 | | - |
| 1349 | + |
1350 | 1350 | // Hide "controls" if using native player controls: |
1351 | 1351 | if( this.useNativePlayerControls() ){ |
1352 | 1352 | _this.controls = false; |
1353 | 1353 | } |
1354 | | - |
| 1354 | + |
1355 | 1355 | // Set the poster: |
1356 | 1356 | if ( $j( element ).attr( 'thumbnail' ) ) { |
1357 | 1357 | _this.poster = $j( element ).attr( 'thumbnail' ); |
— | — | @@ -1358,10 +1358,10 @@ |
1359 | 1359 | if ( $j( element ).attr( 'poster' ) ) { |
1360 | 1360 | _this.poster = $j( element ).attr( 'poster' ); |
1361 | 1361 | } |
1362 | | - |
| 1362 | + |
1363 | 1363 | // Set the skin name from the class |
1364 | 1364 | var sn = $j(element).attr( 'class' ); |
1365 | | - |
| 1365 | + |
1366 | 1366 | if ( sn && sn != '' ) { |
1367 | 1367 | for ( var n = 0; n < mw.validSkins.length; n++ ) { |
1368 | 1368 | if ( sn.indexOf( mw.validSkins[n].toLowerCase() ) !== -1 ) { |
— | — | @@ -1369,43 +1369,43 @@ |
1370 | 1370 | } |
1371 | 1371 | } |
1372 | 1372 | } |
1373 | | - |
| 1373 | + |
1374 | 1374 | // Set the default skin if unset: |
1375 | 1375 | if ( !this.skinName ) { |
1376 | 1376 | this.skinName = mw.getConfig( 'EmbedPlayer.SkinName' ); |
1377 | 1377 | } |
1378 | | - |
| 1378 | + |
1379 | 1379 | if( !this.monitorRate ){ |
1380 | 1380 | this.monitorRate = mw.getConfig( 'EmbedPlayer.MonitorRate' ); |
1381 | 1381 | } |
1382 | | - |
| 1382 | + |
1383 | 1383 | // Make sure startOffset is cast as an float: |
1384 | 1384 | if ( this.startOffset && this.startOffset.split( ':' ).length >= 2 ) { |
1385 | 1385 | this.startOffset = parseFloat( mw.npt2seconds( this.startOffset ) ); |
1386 | 1386 | } |
1387 | | - |
| 1387 | + |
1388 | 1388 | // Make sure offset is in float: |
1389 | 1389 | this.startOffset = parseFloat( this.startOffset ); |
1390 | | - |
| 1390 | + |
1391 | 1391 | // Set the source duration ( if provided in the element metaData or |
1392 | 1392 | // durationHint ) |
1393 | 1393 | if ( $j( element ).attr( 'duration' ) ) { |
1394 | 1394 | _this.duration = $j( element ).attr( 'duration' ); |
1395 | 1395 | } |
1396 | | - |
| 1396 | + |
1397 | 1397 | if ( !_this.duration && $j( element ).attr( 'durationHint' ) ) { |
1398 | 1398 | _this.durationHint = $j( element ).attr( 'durationHint' ); |
1399 | 1399 | // Convert duration hint if needed: |
1400 | 1400 | _this.duration = mw.npt2seconds( _this.durationHint ); |
1401 | | - } |
1402 | | - |
| 1401 | + } |
| 1402 | + |
1403 | 1403 | // Make sure duration is a float: |
1404 | 1404 | this.duration = parseFloat( this.duration ); |
1405 | 1405 | mw.log( 'EmbedPlayer::mediaElement:' + this.id + " duration is: " + this.duration ); |
1406 | | - |
| 1406 | + |
1407 | 1407 | // Set the player size attributes based loaded video element: |
1408 | | - this.setPlayerSize( element ); |
1409 | | - |
| 1408 | + this.setPlayerSize( element ); |
| 1409 | + |
1410 | 1410 | // Set the plugin id |
1411 | 1411 | this.pid = 'pid_' + this.id; |
1412 | 1412 | |
— | — | @@ -1415,10 +1415,10 @@ |
1416 | 1416 | // mw.log( 'innerHTML: ' + element.innerHTML ); |
1417 | 1417 | this.user_missing_plugin_html = element.innerHTML; |
1418 | 1418 | } |
1419 | | - |
| 1419 | + |
1420 | 1420 | // Add the mediaElement object with the elements sources: |
1421 | 1421 | this.mediaElement = new mediaElement( element ); |
1422 | | - |
| 1422 | + |
1423 | 1423 | // Process attribute "sources" for dynamic embedding |
1424 | 1424 | if( customAttributes.sources && customAttributes.sources.length ){ |
1425 | 1425 | for( var i =0; i < customAttributes.sources.length ; i ++ ){ |
— | — | @@ -1439,7 +1439,7 @@ |
1440 | 1440 | } |
1441 | 1441 | } |
1442 | 1442 | }, |
1443 | | - |
| 1443 | + |
1444 | 1444 | stopEventPropagation: function(){ |
1445 | 1445 | this._propagateEvents = false; |
1446 | 1446 | }, |
— | — | @@ -1452,24 +1452,24 @@ |
1453 | 1453 | updateFeatureSupport: function(){ |
1454 | 1454 | return ; |
1455 | 1455 | }, |
1456 | | - |
| 1456 | + |
1457 | 1457 | /** |
1458 | 1458 | * Set the width & height from css style attribute, element attribute, or by |
1459 | 1459 | * default value if no css or attribute is provided set a callback to |
1460 | 1460 | * resize. |
1461 | | - * |
| 1461 | + * |
1462 | 1462 | * Updates this.width & this.height |
1463 | | - * |
| 1463 | + * |
1464 | 1464 | * @param {Element} |
1465 | 1465 | * element Source element to grab size from |
1466 | 1466 | */ |
1467 | 1467 | setPlayerSize: function( element ) { |
1468 | 1468 | this.height = $j(element).css( 'height' ); |
1469 | 1469 | this.width = $j(element).css( 'width' ); |
1470 | | - |
| 1470 | + |
1471 | 1471 | // Set to parent size ( resize events will cause player size updates) |
1472 | 1472 | if( this.height.indexOf('100%') != -1 || this.width.indexOf('100%') != -1 ){ |
1473 | | - $relativeParent = $j(element).parents().filter(function() { |
| 1473 | + $relativeParent = $j(element).parents().filter(function() { |
1474 | 1474 | // reduce to only relative position or "body" elements |
1475 | 1475 | return $j(this).is('body') || $j(this).css('position') == 'relative'; |
1476 | 1476 | }).slice(0,1); // grab only the "first" |
— | — | @@ -1482,21 +1482,21 @@ |
1483 | 1483 | |
1484 | 1484 | // Set via attribute if CSS is zero or NaN and we have an attribute |
1485 | 1485 | // value: |
1486 | | - this.height = ( this.height==0 || isNaN( this.height ) |
1487 | | - && $j(element).attr( 'height' ) ) ? |
| 1486 | + this.height = ( this.height==0 || isNaN( this.height ) |
| 1487 | + && $j(element).attr( 'height' ) ) ? |
1488 | 1488 | parseInt( $j(element).attr( 'height' ) ): this.height; |
1489 | | - this.width = ( this.width == 0 || isNaN( this.width ) |
1490 | | - && $j(element).attr( 'width' ) )? |
| 1489 | + this.width = ( this.width == 0 || isNaN( this.width ) |
| 1490 | + && $j(element).attr( 'width' ) )? |
1491 | 1491 | parseInt( $j(element).attr( 'width' ) ): this.width; |
1492 | | - |
1493 | | - |
| 1492 | + |
| 1493 | + |
1494 | 1494 | // Special case for audio |
1495 | 1495 | // Firefox sets audio height to "0px" while webkit uses 32px .. force |
1496 | 1496 | // zero: |
1497 | 1497 | if( element.tagName.toLowerCase() == 'audio' && this.height == '32' ) { |
1498 | | - this.height = 0; |
| 1498 | + this.height = 0; |
1499 | 1499 | } |
1500 | | - |
| 1500 | + |
1501 | 1501 | // Use default aspect ration to get height or width ( if rewriting a |
1502 | 1502 | // non-audio player ) |
1503 | 1503 | if( element.tagName.toLowerCase() != 'audio' && this.videoAspect ) { |
— | — | @@ -1509,15 +1509,15 @@ |
1510 | 1510 | this.height = parseInt( this.width * ( aspect[1] / aspect[0] ) ); |
1511 | 1511 | } |
1512 | 1512 | } |
1513 | | - |
| 1513 | + |
1514 | 1514 | // On load sometimes attr is temporally -1 as we don't have video |
1515 | 1515 | // metadata yet. |
1516 | 1516 | // or in IE we get NaN for width height |
1517 | | - // |
| 1517 | + // |
1518 | 1518 | // NOTE: browsers that do support height width should set "waitForMeta" |
1519 | 1519 | // flag in addElement |
1520 | 1520 | if( ( isNaN( this.height ) && isNaN( this.width ) ) || |
1521 | | - ( this.height == -1 || this.width == -1 ) || |
| 1521 | + ( this.height == -1 || this.width == -1 ) || |
1522 | 1522 | // Check for firefox defaults |
1523 | 1523 | // Note: ideally firefox would not do random guesses at css |
1524 | 1524 | // values |
— | — | @@ -1525,7 +1525,7 @@ |
1526 | 1526 | ) { |
1527 | 1527 | var defaultSize = mw.getConfig( 'EmbedPlayer.DefaultSize' ).split( 'x' ); |
1528 | 1528 | this.width = defaultSize[0]; |
1529 | | - |
| 1529 | + |
1530 | 1530 | // Special height default for audio tag ( if not set ) |
1531 | 1531 | if( element.tagName.toLowerCase() == 'audio' ) { |
1532 | 1532 | this.height = 0; |
— | — | @@ -1533,7 +1533,7 @@ |
1534 | 1534 | this.height = defaultSize[1]; |
1535 | 1535 | } |
1536 | 1536 | } |
1537 | | - |
| 1537 | + |
1538 | 1538 | }, |
1539 | 1539 | /** |
1540 | 1540 | * Resize the player to a new size preserving aspect ratio Wraps the |
— | — | @@ -1541,7 +1541,7 @@ |
1542 | 1542 | */ |
1543 | 1543 | resizePlayer: function( size , animate){ |
1544 | 1544 | mw.log("EmbedPlayer::resizePlayer:" + size.width + ' x ' + size.height ); |
1545 | | - |
| 1545 | + |
1546 | 1546 | // Check if we are native display then resize the playerElement directly |
1547 | 1547 | if( this.useNativePlayerControls() ){ |
1548 | 1548 | if( animate ){ |
— | — | @@ -1553,19 +1553,19 @@ |
1554 | 1554 | this.controlBuilder.resizePlayer( size, animate); |
1555 | 1555 | } |
1556 | 1556 | }, |
1557 | | - |
| 1557 | + |
1558 | 1558 | /** |
1559 | 1559 | * Get the player pixel width not including controls |
1560 | | - * |
| 1560 | + * |
1561 | 1561 | * @return {Number} pixel height of the video |
1562 | 1562 | */ |
1563 | 1563 | getPlayerWidth: function() { |
1564 | 1564 | return $j( this ).width(); |
1565 | 1565 | }, |
1566 | | - |
| 1566 | + |
1567 | 1567 | /** |
1568 | 1568 | * Get the player pixel height not including controls |
1569 | | - * |
| 1569 | + * |
1570 | 1570 | * @return {Number} pixel height of the video |
1571 | 1571 | */ |
1572 | 1572 | getPlayerHeight: function() { |
— | — | @@ -1579,7 +1579,7 @@ |
1580 | 1580 | checkPlayerSources: function() { |
1581 | 1581 | mw.log( 'EmbedPlayer::checkPlayerSources: ' + this.id ); |
1582 | 1582 | var _this = this; |
1583 | | - |
| 1583 | + |
1584 | 1584 | // Scope the end of check for player sources so it can be called in a |
1585 | 1585 | // callback |
1586 | 1586 | var finishCheckPlayerSources = function(){ |
— | — | @@ -1588,7 +1588,7 @@ |
1589 | 1589 | _this.checkForTimedText(); |
1590 | 1590 | }); |
1591 | 1591 | }; |
1592 | | - |
| 1592 | + |
1593 | 1593 | // NOTE: Should could be moved to mediaWiki Api support module |
1594 | 1594 | // only load from api if sources are empty: |
1595 | 1595 | if ( _this.apiTitleKey && this.mediaElement.sources.length == 0) { |
— | — | @@ -1598,24 +1598,24 @@ |
1599 | 1599 | finishCheckPlayerSources(); |
1600 | 1600 | } ); |
1601 | 1601 | return ; |
1602 | | - } else { |
| 1602 | + } else { |
1603 | 1603 | finishCheckPlayerSources(); |
1604 | 1604 | } |
1605 | 1605 | }, |
1606 | | - |
| 1606 | + |
1607 | 1607 | /** |
1608 | 1608 | * Insert and play a video source ( useful for ads or bumper videos ) |
1609 | | - * |
| 1609 | + * |
1610 | 1610 | * Only works while video is in active play back. Only tested with native |
1611 | 1611 | * playback atm. |
1612 | 1612 | */ |
1613 | 1613 | insertAndPlaySource: function( source ){ |
1614 | 1614 | mw.log("Error: only native playback supports insertAndPlaySource right now"); |
1615 | 1615 | }, |
1616 | | - |
| 1616 | + |
1617 | 1617 | /** |
1618 | 1618 | * Load Source video info from mediaWiki Api title key ( this.apiTitleKey ) |
1619 | | - * |
| 1619 | + * |
1620 | 1620 | * @@todo move this to mediaWiki 'api' module |
1621 | 1621 | * @param {Function} |
1622 | 1622 | * callback Function called once loading is complete |
— | — | @@ -1626,12 +1626,12 @@ |
1627 | 1627 | mw.log( 'Error no apiTitleKey'); |
1628 | 1628 | return false; |
1629 | 1629 | } |
1630 | | - |
| 1630 | + |
1631 | 1631 | // Set local apiProvider via config if not defined |
1632 | 1632 | if( !_this.apiProvider ) { |
1633 | 1633 | _this.apiProvider = mw.getConfig( 'EmbedPlayer.ApiProvider' ); |
1634 | 1634 | } |
1635 | | - |
| 1635 | + |
1636 | 1636 | // Setup the request |
1637 | 1637 | var request = { |
1638 | 1638 | 'prop': 'imageinfo', |
— | — | @@ -1662,38 +1662,38 @@ |
1663 | 1663 | return ; |
1664 | 1664 | } |
1665 | 1665 | var imageinfo = page.imageinfo[0]; |
1666 | | - |
| 1666 | + |
1667 | 1667 | // Set the poster |
1668 | 1668 | _this.poster = imageinfo.thumburl; |
1669 | | - |
| 1669 | + |
1670 | 1670 | // Add the media src |
1671 | 1671 | _this.mediaElement.tryAddSource( |
1672 | 1672 | $j('<source />') |
1673 | 1673 | .attr( 'src', imageinfo.url ) |
1674 | 1674 | .get( 0 ) |
1675 | 1675 | ); |
1676 | | - |
| 1676 | + |
1677 | 1677 | // Set the duration |
1678 | 1678 | if( imageinfo.metadata[2]['name'] == 'length' ) { |
1679 | 1679 | _this.duration = imageinfo.metadata[2]['value']; |
1680 | 1680 | } |
1681 | | - |
| 1681 | + |
1682 | 1682 | // Set the width height |
1683 | 1683 | // Make sure we have an accurate aspect ratio |
1684 | 1684 | if( imageinfo.height != 0 && imageinfo.width != 0 ) { |
1685 | 1685 | _this.height = parseInt( _this.width * ( imageinfo.height / imageinfo.width ) ); |
1686 | 1686 | } |
1687 | | - |
| 1687 | + |
1688 | 1688 | // Update the css for the player interface |
1689 | 1689 | $j( _this ).css( 'height', _this.height); |
1690 | | - |
| 1690 | + |
1691 | 1691 | callback(); |
1692 | 1692 | }); |
1693 | 1693 | }, |
1694 | | - |
| 1694 | + |
1695 | 1695 | /** |
1696 | 1696 | * Check if we should load the timedText interface or not. |
1697 | | - * |
| 1697 | + * |
1698 | 1698 | * Note we check for text sources outside of |
1699 | 1699 | */ |
1700 | 1700 | isTimedTextSupported: function() { |
— | — | @@ -1705,7 +1705,7 @@ |
1706 | 1706 | return false; |
1707 | 1707 | } |
1708 | 1708 | }, |
1709 | | - |
| 1709 | + |
1710 | 1710 | /** |
1711 | 1711 | * Check for timed Text support and load necessary libraries |
1712 | 1712 | */ |
— | — | @@ -1722,19 +1722,19 @@ |
1723 | 1723 | } |
1724 | 1724 | _this.setupSourcePlayer(); |
1725 | 1725 | }, |
1726 | | - |
| 1726 | + |
1727 | 1727 | /** |
1728 | 1728 | * Set up the select source player |
1729 | | - * |
| 1729 | + * |
1730 | 1730 | * issues autoSelectSource call |
1731 | | - * |
| 1731 | + * |
1732 | 1732 | * Sets load error if no source is playable |
1733 | 1733 | */ |
1734 | 1734 | setupSourcePlayer: function() { |
1735 | 1735 | mw.log("EmbedPlayer::setupSourcePlayer: " + this.id + ' sources: ' + this.mediaElement.sources.length ); |
1736 | 1736 | // Autoseletct the media source |
1737 | 1737 | this.mediaElement.autoSelectSource(); |
1738 | | - |
| 1738 | + |
1739 | 1739 | // Auto select player based on default order |
1740 | 1740 | if ( !this.mediaElement.selectedSource ) { |
1741 | 1741 | // check for parent clip: |
— | — | @@ -1749,7 +1749,7 @@ |
1750 | 1750 | } else { |
1751 | 1751 | this.selectedPlayer = mw.EmbedTypes.players.defaultPlayer( this.mediaElement.selectedSource.mimeType ); |
1752 | 1752 | } |
1753 | | - |
| 1753 | + |
1754 | 1754 | if ( this.selectedPlayer ) { |
1755 | 1755 | // Inherit the playback system of the selected player: |
1756 | 1756 | this.inheritEmbedPlayer(); |
— | — | @@ -1757,17 +1757,17 @@ |
1758 | 1758 | this.showPluginMissingHTML(); |
1759 | 1759 | } |
1760 | 1760 | }, |
1761 | | - |
| 1761 | + |
1762 | 1762 | /** |
1763 | 1763 | * Load and inherit methods from the selected player interface |
1764 | | - * |
| 1764 | + * |
1765 | 1765 | * @param {Function} |
1766 | 1766 | * callback Function to be called once playback-system has been |
1767 | 1767 | * inherited |
1768 | 1768 | */ |
1769 | 1769 | inheritEmbedPlayer: function( callback ) { |
1770 | 1770 | mw.log( "EmbedPlayer::inheritEmbedPlayer:duration is: " + this.getDuration() + ' p: ' + this.id ); |
1771 | | - |
| 1771 | + |
1772 | 1772 | // Clear out any non-base embedObj methods: |
1773 | 1773 | if ( this.instanceOf ) { |
1774 | 1774 | eval( 'var tmpObj = mw.EmbedPlayer' + this.instanceOf ); |
— | — | @@ -1779,46 +1779,46 @@ |
1780 | 1780 | } |
1781 | 1781 | } |
1782 | 1782 | } |
1783 | | - |
| 1783 | + |
1784 | 1784 | // Set up the new embedObj |
1785 | 1785 | mw.log( 'EmbedPlayer::inheritEmbedPlayer: embedding with ' + this.selectedPlayer.library ); |
1786 | 1786 | var _this = this; |
1787 | | - |
| 1787 | + |
1788 | 1788 | // Load the selected player |
1789 | 1789 | this.selectedPlayer.load( function() { |
1790 | 1790 | mw.log( 'EmbedPlayer::inheritEmbedPlayer ' + _this.selectedPlayer.library + " player loaded for " + _this.id ); |
1791 | | - |
| 1791 | + |
1792 | 1792 | // Get embed library player Interface |
1793 | 1793 | var playerInterface = mw[ 'EmbedPlayer' + _this.selectedPlayer.library ]; |
1794 | | - |
1795 | | - for ( var method in playerInterface ) { |
| 1794 | + |
| 1795 | + for ( var method in playerInterface ) { |
1796 | 1796 | if ( _this[method] && !_this['parent_' + method] ) { |
1797 | 1797 | _this['parent_' + method] = _this[method]; |
1798 | 1798 | } |
1799 | 1799 | _this[ method ] = playerInterface[method]; |
1800 | 1800 | } |
1801 | | - |
| 1801 | + |
1802 | 1802 | // Update feature support |
1803 | 1803 | _this.updateFeatureSupport(); |
1804 | | - |
| 1804 | + |
1805 | 1805 | _this.getDuration(); |
1806 | | - |
| 1806 | + |
1807 | 1807 | _this.showPlayer(); |
1808 | | - |
| 1808 | + |
1809 | 1809 | // Call the global player manager to inform this video interface is |
1810 | 1810 | // ready: |
1811 | 1811 | mw.playerManager.playerReady( _this ); |
1812 | | - |
| 1812 | + |
1813 | 1813 | // Run the callback if provided |
1814 | 1814 | if ( typeof callback == 'function' ){ |
1815 | 1815 | callback(); |
1816 | 1816 | } |
1817 | 1817 | } ); |
1818 | 1818 | }, |
1819 | | - |
| 1819 | + |
1820 | 1820 | /** |
1821 | 1821 | * Select a player playback system |
1822 | | - * |
| 1822 | + * |
1823 | 1823 | * @param {Object} |
1824 | 1824 | * player Player playback system to be selected player playback |
1825 | 1825 | * system include vlc, native, java etc. |
— | — | @@ -1829,7 +1829,7 @@ |
1830 | 1830 | this.selectedPlayer = player; |
1831 | 1831 | this.inheritEmbedPlayer( function(){ |
1832 | 1832 | // Hide / remove track container |
1833 | | - _this.$interface.find( '.track' ).remove(); |
| 1833 | + _this.$interface.find( '.track' ).remove(); |
1834 | 1834 | // We have to re-bind hoverIntent ( has to happen in this scope |
1835 | 1835 | // ) |
1836 | 1836 | if( _this.controls && _this.controlBuilder.checkOverlayControls() ){ |
— | — | @@ -1848,10 +1848,10 @@ |
1849 | 1849 | }); |
1850 | 1850 | } |
1851 | 1851 | }, |
1852 | | - |
| 1852 | + |
1853 | 1853 | /** |
1854 | 1854 | * Get a time range from the media start and end time |
1855 | | - * |
| 1855 | + * |
1856 | 1856 | * @return start_npt and end_npt time if present |
1857 | 1857 | */ |
1858 | 1858 | getTimeRange: function() { |
— | — | @@ -1865,35 +1865,35 @@ |
1866 | 1866 | return default_time_range; |
1867 | 1867 | return this.mediaElement.selectedSource.start_npt + this.mediaElement.selectedSource.end_npt; |
1868 | 1868 | }, |
1869 | | - |
| 1869 | + |
1870 | 1870 | /** |
1871 | 1871 | * Get the duration of the embed player |
1872 | 1872 | */ |
1873 | 1873 | getDuration: function() { |
1874 | 1874 | return this.duration; |
1875 | 1875 | }, |
1876 | | - |
| 1876 | + |
1877 | 1877 | /** |
1878 | 1878 | * Get the player height |
1879 | 1879 | */ |
1880 | 1880 | getHeight: function() { |
1881 | 1881 | return this.height; |
1882 | 1882 | }, |
1883 | | - |
| 1883 | + |
1884 | 1884 | /** |
1885 | 1885 | * Get the player width |
1886 | 1886 | */ |
1887 | 1887 | getWidth: function(){ |
1888 | 1888 | return this.width; |
1889 | 1889 | }, |
1890 | | - |
| 1890 | + |
1891 | 1891 | /** |
1892 | 1892 | * Check if the selected source is an audio element: |
1893 | 1893 | */ |
1894 | 1894 | isAudio: function(){ |
1895 | 1895 | return ( this.mediaElement.selectedSource.mimeType.indexOf('audio/') !== -1 ); |
1896 | 1896 | }, |
1897 | | - |
| 1897 | + |
1898 | 1898 | /** |
1899 | 1899 | * Get the plugin embed html ( should be implemented by embed player |
1900 | 1900 | * interface ) |
— | — | @@ -1901,19 +1901,19 @@ |
1902 | 1902 | doEmbedHTML: function() { |
1903 | 1903 | return 'Error: function doEmbedHTML should be implemented by embed player interface '; |
1904 | 1904 | }, |
1905 | | - |
| 1905 | + |
1906 | 1906 | /** |
1907 | 1907 | * Seek function ( should be implemented by embedPlayer interface |
1908 | 1908 | * playerNative, playerKplayer etc. ) embedPlayer doSeek only handles URL |
1909 | 1909 | * time seeks |
1910 | | - */ |
| 1910 | + */ |
1911 | 1911 | doSeek: function( percent ) { |
1912 | 1912 | var _this = this; |
1913 | | - |
| 1913 | + |
1914 | 1914 | this.seeking = true; |
1915 | 1915 | // Run the seeking hook |
1916 | 1916 | $j( this.embedPlayer ).trigger( 'onSeek' ); |
1917 | | - |
| 1917 | + |
1918 | 1918 | // See if we should do a server side seek ( player independent ) |
1919 | 1919 | if ( this.supportsURLTimeEncoding() ) { |
1920 | 1920 | mw.log( 'EmbedPlayer::doSeek:: updated serverSeekTime: ' + mw.seconds2npt ( this.serverSeekTime ) ); |
— | — | @@ -1924,7 +1924,7 @@ |
1925 | 1925 | // Update the slider |
1926 | 1926 | this.updatePlayHead( percent ); |
1927 | 1927 | } |
1928 | | - |
| 1928 | + |
1929 | 1929 | // Do play request in 100ms ( give the dom time to swap out the embed |
1930 | 1930 | // player ) |
1931 | 1931 | setTimeout( function() { |
— | — | @@ -1932,13 +1932,13 @@ |
1933 | 1933 | _this.play() |
1934 | 1934 | _this.monitor(); |
1935 | 1935 | }, 100 ); |
1936 | | - |
| 1936 | + |
1937 | 1937 | // Run the onSeeking interface update |
1938 | 1938 | // NOTE controlBuilder should really bind to html5 events rather |
1939 | 1939 | // than explicitly calling it or inheriting stuff. |
1940 | | - this.controlBuilder.onSeek(); |
| 1940 | + this.controlBuilder.onSeek(); |
1941 | 1941 | }, |
1942 | | - |
| 1942 | + |
1943 | 1943 | /** |
1944 | 1944 | * Seeks to the requested time and issues a callback when ready (should be |
1945 | 1945 | * overwritten by client that supports frame serving) |
— | — | @@ -1946,81 +1946,81 @@ |
1947 | 1947 | setCurrentTime: function( time, callback ) { |
1948 | 1948 | mw.log( 'Error: base embed setCurrentTime can not frame serve (override via plugin)' ); |
1949 | 1949 | }, |
1950 | | - |
| 1950 | + |
1951 | 1951 | /** |
1952 | 1952 | * On clip done action. Called once a clip is done playing |
1953 | 1953 | */ |
1954 | 1954 | onClipDone: function() { |
1955 | 1955 | mw.log( 'EmbedPlayer::onClipDone:' + this.id + ' doneCount:' + this.donePlayingCount + ' stop state:' +this.isStopped() ); |
1956 | 1956 | var _this = this; |
1957 | | - |
| 1957 | + |
1958 | 1958 | // Only run stopped once: |
1959 | 1959 | if( !this.isStopped() ){ |
1960 | 1960 | // Stop the monitor: |
1961 | 1961 | this.stopMonitor(); |
1962 | | - |
| 1962 | + |
1963 | 1963 | // Show the control bar: |
1964 | 1964 | this.controlBuilder.showControlBar(); |
1965 | | - |
| 1965 | + |
1966 | 1966 | // Update the clip done playing count: |
1967 | 1967 | this.donePlayingCount ++; |
1968 | | - |
| 1968 | + |
1969 | 1969 | // Fire the html5 ended binding |
1970 | 1970 | var onDoneActionObject = { |
1971 | 1971 | 'runBaseControlDone' : true |
1972 | 1972 | } |
1973 | | - |
| 1973 | + |
1974 | 1974 | // Run the ended trigger ( allow the ended object to prevent default |
1975 | 1975 | // actions ) |
1976 | 1976 | mw.log("EmbedPlayer::onClipDone:Trigger ended"); |
1977 | 1977 | $j( this ).trigger( 'ended', onDoneActionObject ); |
1978 | | - |
| 1978 | + |
1979 | 1979 | if( onDoneActionObject.runBaseControlDone ){ |
1980 | | - |
| 1980 | + |
1981 | 1981 | // Check if we have the "loop" property set |
1982 | 1982 | if( this.loop ) { |
1983 | 1983 | this.stop(); |
1984 | 1984 | this.play(); |
1985 | | - return; |
| 1985 | + return; |
1986 | 1986 | } |
1987 | | - |
| 1987 | + |
1988 | 1988 | // Stop the clip (load the thumbnail etc) |
1989 | 1989 | this.stop(); |
1990 | 1990 | this.serverSeekTime = 0; |
1991 | 1991 | this.updatePlayHead( 0 ); |
1992 | | - |
| 1992 | + |
1993 | 1993 | // Make sure we are not in preview mode( no end clip actions in |
1994 | 1994 | // preview mode) |
1995 | 1995 | if ( this.preview_mode ) { |
1996 | 1996 | return ; |
1997 | 1997 | } |
1998 | | - |
| 1998 | + |
1999 | 1999 | // Do the controlBuilder onClip done interface |
2000 | 2000 | this.controlBuilder.onClipDone(); |
2001 | 2001 | } |
2002 | 2002 | } |
2003 | | - |
| 2003 | + |
2004 | 2004 | }, |
2005 | | - |
2006 | | - |
| 2005 | + |
| 2006 | + |
2007 | 2007 | /** |
2008 | 2008 | * Shows the video Thumbnail, updates pause state |
2009 | 2009 | */ |
2010 | 2010 | showThumbnail: function() { |
2011 | 2011 | var _this = this; |
2012 | 2012 | mw.log( 'EmbedPlayer::showThumbnail' + this.thumbnail_disp ); |
2013 | | - |
| 2013 | + |
2014 | 2014 | // Close Menu Overlay: |
2015 | 2015 | this.controlBuilder.closeMenuOverlay(); |
2016 | | - |
| 2016 | + |
2017 | 2017 | // update the thumbnail html: |
2018 | 2018 | this.updatePosterHTML(); |
2019 | | - |
| 2019 | + |
2020 | 2020 | this.paused = true; |
2021 | 2021 | this.thumbnail_disp = true; |
2022 | 2022 | // Make sure the controlBuilder bindings are up-to-date |
2023 | 2023 | this.controlBuilder.addControlBindings(); |
2024 | | - |
| 2024 | + |
2025 | 2025 | // Once the thumbnail is shown run the mediaReady trigger (if not using |
2026 | 2026 | // native controls) |
2027 | 2027 | if( !this.useNativePlayerControls() ){ |
— | — | @@ -2028,7 +2028,7 @@ |
2029 | 2029 | $j( this ).trigger( 'mediaLoaded' ); |
2030 | 2030 | } |
2031 | 2031 | }, |
2032 | | - |
| 2032 | + |
2033 | 2033 | /** |
2034 | 2034 | * Show the player |
2035 | 2035 | */ |
— | — | @@ -2038,11 +2038,11 @@ |
2039 | 2039 | // Set-up the local controlBuilder instance: |
2040 | 2040 | this.controlBuilder = new mw.PlayerControlBuilder( this ); |
2041 | 2041 | var _this = this; |
2042 | | - |
| 2042 | + |
2043 | 2043 | // Make sure we have mwplayer_interface |
2044 | 2044 | if( $j( this ).parent( '.mwplayer_interface' ).length == 0 ) { |
2045 | 2045 | // Select "player" |
2046 | | - $j( this ).wrap( |
| 2046 | + $j( this ).wrap( |
2047 | 2047 | $j('<div>') |
2048 | 2048 | .addClass( 'mwplayer_interface ' + this.controlBuilder.playerClass ) |
2049 | 2049 | .css({ |
— | — | @@ -2055,14 +2055,14 @@ |
2056 | 2056 | // position the "player" absolute inside the relative interface |
2057 | 2057 | // parent: |
2058 | 2058 | .css('position', 'absolute'); |
2059 | | - } |
2060 | | - |
| 2059 | + } |
| 2060 | + |
2061 | 2061 | // Set up local jQuery object reference to "mwplayer_interface" |
2062 | 2062 | this.$interface = $j( this ).parent( '.mwplayer_interface' ); |
2063 | | - |
| 2063 | + |
2064 | 2064 | // Update Thumbnail for the "player" |
2065 | 2065 | this.updatePosterHTML(); |
2066 | | - |
| 2066 | + |
2067 | 2067 | // Add controls if enabled: |
2068 | 2068 | if ( this.controls ) { |
2069 | 2069 | this.controlBuilder.addControls(); |
— | — | @@ -2071,7 +2071,7 @@ |
2072 | 2072 | // Interface is hidden if controls are "off" |
2073 | 2073 | this.$interface.hide(); |
2074 | 2074 | } |
2075 | | - |
| 2075 | + |
2076 | 2076 | if ( this.autoplay ) { |
2077 | 2077 | mw.log( 'EmbedPlayer::showPlayer::activating autoplay' ); |
2078 | 2078 | // Issue a non-blocking play request |
— | — | @@ -2079,12 +2079,12 @@ |
2080 | 2080 | _this.play(); |
2081 | 2081 | },0) |
2082 | 2082 | } |
2083 | | - |
| 2083 | + |
2084 | 2084 | }, |
2085 | | - |
| 2085 | + |
2086 | 2086 | /** |
2087 | 2087 | * Get missing plugin html (check for user included code) |
2088 | | - * |
| 2088 | + * |
2089 | 2089 | * @param {String} |
2090 | 2090 | * [misssingType] missing type mime |
2091 | 2091 | */ |
— | — | @@ -2098,7 +2098,7 @@ |
2099 | 2099 | } |
2100 | 2100 | // Remove the loading spinner if present: |
2101 | 2101 | $j('.playerLoadingSpinner').remove(); |
2102 | | - |
| 2102 | + |
2103 | 2103 | // If the native video is already displayed hide it: |
2104 | 2104 | if( $j( '#' + this.pid ).length != 0 ){ |
2105 | 2105 | $j('#loadingSpinner_' + this.id ).remove(); |
— | — | @@ -2108,7 +2108,7 @@ |
2109 | 2109 | // hide the pid if present: |
2110 | 2110 | $j( '#pid_' + this.id ).hide(); |
2111 | 2111 | $j( this ).show().html( |
2112 | | - $j('<span />').text( |
| 2112 | + $j('<span />').text( |
2113 | 2113 | gM('mwe-embedplayer-missing-source') |
2114 | 2114 | ) |
2115 | 2115 | ); |
— | — | @@ -2118,7 +2118,7 @@ |
2119 | 2119 | // Check if we have user defined missing html msg: |
2120 | 2120 | if ( this.user_missing_plugin_html ) { |
2121 | 2121 | $j( this ).html( this.user_missing_plugin_html ); |
2122 | | - } else { |
| 2122 | + } else { |
2123 | 2123 | $j( this ).html( |
2124 | 2124 | $j('<div />').append( |
2125 | 2125 | gM( 'mwe-embedplayer-generic_missing_plugin', missingType ), |
— | — | @@ -2134,10 +2134,10 @@ |
2135 | 2135 | } |
2136 | 2136 | // hide |
2137 | 2137 | }, |
2138 | | - |
| 2138 | + |
2139 | 2139 | /** |
2140 | 2140 | * Update the video time request via a time request string |
2141 | | - * |
| 2141 | + * |
2142 | 2142 | * @param {String} |
2143 | 2143 | * time_req |
2144 | 2144 | */ |
— | — | @@ -2146,10 +2146,10 @@ |
2147 | 2147 | var time_parts = time_req.split( '/' ); |
2148 | 2148 | this.updateVideoTime( time_parts[0], time_parts[1] ); |
2149 | 2149 | }, |
2150 | | - |
| 2150 | + |
2151 | 2151 | /** |
2152 | 2152 | * Update Video time from provided start_npt and end_npt values |
2153 | | - * |
| 2153 | + * |
2154 | 2154 | * @param {String} |
2155 | 2155 | * start_npt the new start time in npt format |
2156 | 2156 | * @pamra {String} end_npt the new end time in npt format |
— | — | @@ -2157,13 +2157,13 @@ |
2158 | 2158 | updateVideoTime: function( start_npt, end_npt ) { |
2159 | 2159 | // update media |
2160 | 2160 | this.mediaElement.updateSourceTimes( start_npt, end_npt ); |
2161 | | - |
| 2161 | + |
2162 | 2162 | // update mv_time |
2163 | 2163 | this.controlBuilder.setStatus( start_npt + '/' + end_npt ); |
2164 | | - |
| 2164 | + |
2165 | 2165 | // reset slider |
2166 | 2166 | this.updatePlayHead( 0 ); |
2167 | | - |
| 2167 | + |
2168 | 2168 | // reset seek_offset: |
2169 | 2169 | if ( this.mediaElement.selectedSource.URLTimeEncoding ) { |
2170 | 2170 | this.serverSeekTime = 0; |
— | — | @@ -2172,20 +2172,20 @@ |
2173 | 2173 | } |
2174 | 2174 | }, |
2175 | 2175 | |
2176 | | - |
| 2176 | + |
2177 | 2177 | /** |
2178 | 2178 | * Update Thumb time with npt formated time |
2179 | | - * |
| 2179 | + * |
2180 | 2180 | * @param {String} |
2181 | 2181 | * time NPT formated time to update thumbnail |
2182 | 2182 | */ |
2183 | 2183 | updateThumbTimeNPT: function( time ) { |
2184 | 2184 | this.updateThumbTime( mw.npt2seconds( time ) - parseInt( this.startOffset ) ); |
2185 | 2185 | }, |
2186 | | - |
| 2186 | + |
2187 | 2187 | /** |
2188 | 2188 | * Update the thumb with a new time |
2189 | | - * |
| 2189 | + * |
2190 | 2190 | * @param {Float} |
2191 | 2191 | * floatSeconds Time to update the thumb to |
2192 | 2192 | */ |
— | — | @@ -2197,8 +2197,8 @@ |
2198 | 2198 | } |
2199 | 2199 | if ( this.org_thum_src.indexOf( 't=' ) !== -1 ) { |
2200 | 2200 | this.last_thumb_url = mw.replaceUrlParams( this.org_thum_src, |
2201 | | - { |
2202 | | - 't' : mw.seconds2npt( floatSeconds + parseInt( this.startOffset ) ) |
| 2201 | + { |
| 2202 | + 't' : mw.seconds2npt( floatSeconds + parseInt( this.startOffset ) ) |
2203 | 2203 | } |
2204 | 2204 | ); |
2205 | 2205 | if ( !this.thumbnail_updating ) { |
— | — | @@ -2207,20 +2207,20 @@ |
2208 | 2208 | } |
2209 | 2209 | } |
2210 | 2210 | }, |
2211 | | - |
| 2211 | + |
2212 | 2212 | /** |
2213 | 2213 | * Updates the displayed thumbnail via percent of the stream |
2214 | | - * |
| 2214 | + * |
2215 | 2215 | * @param {Float} |
2216 | 2216 | * percent Percent of duration to update thumb |
2217 | 2217 | */ |
2218 | 2218 | updateThumbPerc:function( percent ) { |
2219 | 2219 | return this.updateThumbTime( ( this.getDuration() * percent ) ); |
2220 | 2220 | }, |
2221 | | - |
| 2221 | + |
2222 | 2222 | /** |
2223 | 2223 | * Updates the thumbnail if the thumbnail is being displayed |
2224 | | - * |
| 2224 | + * |
2225 | 2225 | * @param {String} |
2226 | 2226 | * src New src of thumbnail |
2227 | 2227 | * @param {Boolean} |
— | — | @@ -2234,9 +2234,9 @@ |
2235 | 2235 | // if we are already updating don't issue a new update: |
2236 | 2236 | if ( this.thumbnail_updating && $j( '#new_img_thumb_' + this.id ).attr( 'src' ) == src ) |
2237 | 2237 | return false; |
2238 | | - |
| 2238 | + |
2239 | 2239 | mw.log( 'update thumb: ' + src ); |
2240 | | - |
| 2240 | + |
2241 | 2241 | if ( quick_switch ) { |
2242 | 2242 | $j( '#img_thumb_' + this.id ).attr( 'src', src ); |
2243 | 2243 | } else { |
— | — | @@ -2244,11 +2244,11 @@ |
2245 | 2245 | // if still animating remove new_img_thumb_ |
2246 | 2246 | if ( this.thumbnail_updating == true ) |
2247 | 2247 | $j( '#new_img_thumb_' + this.id ).stop().remove(); |
2248 | | - |
| 2248 | + |
2249 | 2249 | if ( this.thumbnail_disp ) { |
2250 | 2250 | mw.log( 'set to thumb:' + src ); |
2251 | 2251 | this.thumbnail_updating = true; |
2252 | | - $j( this ).append( |
| 2252 | + $j( this ).append( |
2253 | 2253 | $j('<img />') |
2254 | 2254 | .attr({ |
2255 | 2255 | 'src' : src, |
— | — | @@ -2284,7 +2284,7 @@ |
2285 | 2285 | } |
2286 | 2286 | } |
2287 | 2287 | }, |
2288 | | - |
| 2288 | + |
2289 | 2289 | /** |
2290 | 2290 | * Returns the HTML code for the video when it is in thumbnail mode. |
2291 | 2291 | * playing, configuring the player, inline cmml display, HTML linkback, |
— | — | @@ -2295,17 +2295,17 @@ |
2296 | 2296 | var thumb_html = ''; |
2297 | 2297 | var class_atr = ''; |
2298 | 2298 | var style_atr = ''; |
2299 | | - |
2300 | | - |
| 2299 | + |
| 2300 | + |
2301 | 2301 | if( this.useNativePlayerControls() ){ |
2302 | 2302 | this.showNativePlayer(); |
2303 | 2303 | return ; |
2304 | 2304 | } |
2305 | | - |
| 2305 | + |
2306 | 2306 | // Set by default thumb value if not found |
2307 | | - var posterSrc = ( this.poster ) ? this.poster : |
| 2307 | + var posterSrc = ( this.poster ) ? this.poster : |
2308 | 2308 | mw.getConfig( 'imagesPath' ) + 'vid_default_thumb.jpg'; |
2309 | | - |
| 2309 | + |
2310 | 2310 | // Poster support is not very consistent in browsers |
2311 | 2311 | // use a jpg poster image: |
2312 | 2312 | $j( this ).html( |
— | — | @@ -2321,19 +2321,19 @@ |
2322 | 2322 | }) |
2323 | 2323 | .addClass( 'playerPoster' ) |
2324 | 2324 | ); |
2325 | | - |
2326 | | - if ( this.controls |
2327 | | - && this.height > this.controlBuilder.getComponentHeight( 'playButtonLarge' ) |
| 2325 | + |
| 2326 | + if ( this.controls |
| 2327 | + && this.height > this.controlBuilder.getComponentHeight( 'playButtonLarge' ) |
2328 | 2328 | ) { |
2329 | 2329 | $j( this ).append( |
2330 | 2330 | this.controlBuilder.getComponent( 'playButtonLarge' ) |
2331 | 2331 | ); |
2332 | 2332 | } |
2333 | 2333 | }, |
2334 | | - |
| 2334 | + |
2335 | 2335 | /** |
2336 | 2336 | * Checks if native controls should be used |
2337 | | - * |
| 2337 | + * |
2338 | 2338 | * @param [player] |
2339 | 2339 | * Object Optional player object to check controls attribute |
2340 | 2340 | * @returns boolean true if the mwEmbed player interface should be used |
— | — | @@ -2343,7 +2343,7 @@ |
2344 | 2344 | if( this.usenativecontrols === true ){ |
2345 | 2345 | return true; |
2346 | 2346 | } |
2347 | | - |
| 2347 | + |
2348 | 2348 | if( mw.getConfig('EmbedPlayer.NativeControls') === true ) { |
2349 | 2349 | return true; |
2350 | 2350 | } |
— | — | @@ -2351,14 +2351,14 @@ |
2352 | 2352 | mw.isHTML5FallForwardNative() |
2353 | 2353 | ){ |
2354 | 2354 | return true; |
2355 | | - } |
| 2355 | + } |
2356 | 2356 | return false; |
2357 | 2357 | }, |
2358 | | - |
2359 | | - |
| 2358 | + |
| 2359 | + |
2360 | 2360 | /** |
2361 | 2361 | * Show the native player embed code |
2362 | | - * |
| 2362 | + * |
2363 | 2363 | * This is for cases where the main library needs to "get out of the way" |
2364 | 2364 | * since the device only supports a limited subset of the html5 and won't |
2365 | 2365 | * work with an html javascirpt interface |
— | — | @@ -2367,14 +2367,14 @@ |
2368 | 2368 | var _this = this; |
2369 | 2369 | // Empty the player |
2370 | 2370 | $j(this).empty(); |
2371 | | - |
| 2371 | + |
2372 | 2372 | // Remove the player loader spinner if it exists |
2373 | 2373 | $j('#loadingSpinner_' + this.id ).remove(); |
2374 | | - |
2375 | | - |
| 2374 | + |
| 2375 | + |
2376 | 2376 | // Check if we need to refresh mobile safari |
2377 | 2377 | var mobileSafariNeedsRefresh = false; |
2378 | | - |
| 2378 | + |
2379 | 2379 | // Unhide the original video element if not part of a playerThemer embed |
2380 | 2380 | if( !$j( '#' + this.pid ).hasClass('PlayerThemer') ){ |
2381 | 2381 | $j( '#' + this.pid ) |
— | — | @@ -2383,10 +2383,10 @@ |
2384 | 2384 | } ) |
2385 | 2385 | .show() |
2386 | 2386 | .attr('controls', 'true'); |
2387 | | - |
| 2387 | + |
2388 | 2388 | mobileSafariNeedsRefresh = true; |
2389 | 2389 | } |
2390 | | - |
| 2390 | + |
2391 | 2391 | // iPad does not handle video tag update for attributes like "controls" |
2392 | 2392 | // so we have to do a full replace ( if controls are not included |
2393 | 2393 | // initially ) |
— | — | @@ -2397,14 +2397,14 @@ |
2398 | 2398 | mw.log( 'Warning: Your probably fakeing the iPhone userAgent ( no h.264 source )' ); |
2399 | 2399 | source = this.mediaElement.getSources( 'video/ogg' )[0]; |
2400 | 2400 | } |
2401 | | - |
| 2401 | + |
2402 | 2402 | var videoAttribues = { |
2403 | 2403 | 'id' : _this.pid, |
2404 | 2404 | 'poster': _this.poster, |
2405 | 2405 | 'src' : source.src, |
2406 | 2406 | 'controls' : 'true' |
2407 | 2407 | } |
2408 | | - |
| 2408 | + |
2409 | 2409 | if( this.loop ){ |
2410 | 2410 | videoAttribues[ 'loop' ] = 'true'; |
2411 | 2411 | } |
— | — | @@ -2412,7 +2412,7 @@ |
2413 | 2413 | 'width' : _this.width, |
2414 | 2414 | 'height' : _this.height |
2415 | 2415 | }; |
2416 | | - $j( '#' + this.pid ).replaceWith( |
| 2416 | + $j( '#' + this.pid ).replaceWith( |
2417 | 2417 | _this.getNativePlayerHtml( videoAttribues, cssStyle ) |
2418 | 2418 | ) |
2419 | 2419 | // Bind native events: |
— | — | @@ -2423,7 +2423,7 @@ |
2424 | 2424 | // and only with 'native display' |
2425 | 2425 | if( mw.isAndroid2() ){ |
2426 | 2426 | $j( '#' + _this.pid ).siblings('.play-btn-large').remove(); |
2427 | | - $j( '#' + _this.pid ).after( |
| 2427 | + $j( '#' + _this.pid ).after( |
2428 | 2428 | $j('<div />') |
2429 | 2429 | .css({ |
2430 | 2430 | 'position' : 'relative', |
— | — | @@ -2457,7 +2457,7 @@ |
2458 | 2458 | applyMediaElementBindings: function(){ |
2459 | 2459 | return ; |
2460 | 2460 | }, |
2461 | | - |
| 2461 | + |
2462 | 2462 | /** |
2463 | 2463 | * Gets code to embed the player remotely for "share" this player links |
2464 | 2464 | */ |
— | — | @@ -2471,25 +2471,25 @@ |
2472 | 2472 | break; |
2473 | 2473 | } |
2474 | 2474 | }, |
2475 | | - |
| 2475 | + |
2476 | 2476 | /** |
2477 | 2477 | * Get the share embed object code |
2478 | 2478 | * |
2479 | 2479 | * NOTE this could probably share a bit more code with getShareEmbedVideoJs |
2480 | 2480 | */ |
2481 | 2481 | getShareIframeObject: function(){ |
2482 | | - |
2483 | | - // If using a gadget do the new embed format: |
| 2482 | + |
| 2483 | + // If using a gadget do the new embed format: |
2484 | 2484 | // @@NOTE this should be factored out into mediaWiki gadget helper |
2485 | 2485 | if( typeof wgServer != 'undefined' && typeof mwCheckForGadget != 'undefined' ){ |
2486 | | - var iframeUrl = wgServer + wgArticlePath.replace( /\$1/, wgPageName ) + |
| 2486 | + var iframeUrl = wgServer + wgArticlePath.replace( /\$1/, wgPageName ) + |
2487 | 2487 | '?' + mw.getConfig( 'Mw.AppendWithJS' ) + |
2488 | 2488 | '&embedplayer=yes'; |
2489 | 2489 | } else { |
2490 | 2490 | // old style embed: |
2491 | 2491 | var iframeUrl = mw.getMwEmbedPath() + 'mwEmbedFrame.php?'; |
2492 | 2492 | var params = {}; |
2493 | | - |
| 2493 | + |
2494 | 2494 | if ( this.roe ) { |
2495 | 2495 | params.roe = this.roe; |
2496 | 2496 | } else if( this.apiTitleKey ) { |
— | — | @@ -2514,12 +2514,12 @@ |
2515 | 2515 | params.poster = this.poster; |
2516 | 2516 | } |
2517 | 2517 | } |
2518 | | - |
| 2518 | + |
2519 | 2519 | // Set the skin if set to something other than default |
2520 | 2520 | if( this.skinName ){ |
2521 | 2521 | params.skin = this.skinName; |
2522 | 2522 | } |
2523 | | - |
| 2523 | + |
2524 | 2524 | if( this.duration ) { |
2525 | 2525 | params.durationHint = parseFloat( this.duration ); |
2526 | 2526 | } |
— | — | @@ -2540,50 +2540,50 @@ |
2541 | 2541 | // Return the embed code |
2542 | 2542 | return embedCode; |
2543 | 2543 | }, |
2544 | | - |
| 2544 | + |
2545 | 2545 | /** |
2546 | 2546 | * Get the share embed Video tag code |
2547 | | - */ |
| 2547 | + */ |
2548 | 2548 | getShareEmbedVideoJs: function(){ |
2549 | | - |
| 2549 | + |
2550 | 2550 | // Set the embed tag type: |
2551 | 2551 | var embedtag = ( this.isAudio() )? 'audio': 'video'; |
2552 | | - |
| 2552 | + |
2553 | 2553 | // Set up the mwEmbed js include: |
2554 | 2554 | var embedCode = '<script type="text/javascript" ' + |
2555 | | - 'src="' + |
2556 | | - mw.escapeQuotesHTML( |
2557 | | - mw.absoluteUrl( |
2558 | | - mw.getMwEmbedSrc() |
| 2555 | + 'src="' + |
| 2556 | + mw.escapeQuotesHTML( |
| 2557 | + mw.absoluteUrl( |
| 2558 | + mw.getMwEmbedSrc() |
2559 | 2559 | ) |
2560 | 2560 | ) + '"></script>' + |
2561 | 2561 | '<' + embedtag + ' '; |
2562 | 2562 | |
2563 | 2563 | if( this.poster ) { |
2564 | 2564 | embedCode += 'poster="' + |
2565 | | - mw.escapeQuotesHTML( mw.absoluteUrl( this.poster ) ) + |
| 2565 | + mw.escapeQuotesHTML( mw.absoluteUrl( this.poster ) ) + |
2566 | 2566 | '" '; |
2567 | 2567 | } |
2568 | | - |
| 2568 | + |
2569 | 2569 | // Set the skin if set to something other than default |
2570 | 2570 | if( this.skinName ){ |
2571 | 2571 | embedCode += 'class="' + |
2572 | | - mw.escapeQuotesHTML( this.skinName ) + |
| 2572 | + mw.escapeQuotesHTML( this.skinName ) + |
2573 | 2573 | '" '; |
2574 | 2574 | } |
2575 | | - |
| 2575 | + |
2576 | 2576 | if( this.duration ) { |
2577 | 2577 | embedCode +='durationHint="' + parseFloat( this.duration ) + '" '; |
2578 | 2578 | } |
2579 | | - |
| 2579 | + |
2580 | 2580 | if( this.width || this.height ){ |
2581 | 2581 | embedCode +='style="'; |
2582 | 2582 | embedCode += ( this.width )? 'width:' + this.width +'px;': ''; |
2583 | 2583 | embedCode += ( this.height )? 'height:' + this.height +'px;': ''; |
2584 | 2584 | embedCode += '" '; |
2585 | 2585 | } |
2586 | | - |
2587 | | - |
| 2586 | + |
| 2587 | + |
2588 | 2588 | if ( this.roe ) { |
2589 | 2589 | embedCode += 'roe="' + mw.escapeQuotesHTML( this.roe ) + '" '; |
2590 | 2590 | } else if( this.apiTitleKey ) { |
— | — | @@ -2593,27 +2593,27 @@ |
2594 | 2594 | } |
2595 | 2595 | // close the video tag |
2596 | 2596 | embedCode += '></video>'; |
2597 | | - |
| 2597 | + |
2598 | 2598 | } else { |
2599 | 2599 | // Close the video attr |
2600 | 2600 | embedCode += '>'; |
2601 | | - |
| 2601 | + |
2602 | 2602 | // Output all the video sources: |
2603 | 2603 | for( var i=0; i < this.mediaElement.sources.length; i++ ){ |
2604 | 2604 | var source = this.mediaElement.sources[i]; |
2605 | 2605 | if( source.src ) { |
2606 | | - embedCode +='<source src="' + |
2607 | | - mw.absoluteUrl( source.src ) + |
| 2606 | + embedCode +='<source src="' + |
| 2607 | + mw.absoluteUrl( source.src ) + |
2608 | 2608 | '" ></source>'; |
2609 | 2609 | } |
2610 | 2610 | } |
2611 | 2611 | // Close the video tag |
2612 | 2612 | embedCode += '</video>'; |
2613 | 2613 | } |
2614 | | - |
| 2614 | + |
2615 | 2615 | return embedCode; |
2616 | 2616 | }, |
2617 | | - |
| 2617 | + |
2618 | 2618 | /** |
2619 | 2619 | * Follows a linkback. Loads the ROE xml if no linkback is found |
2620 | 2620 | */ |
— | — | @@ -2635,36 +2635,36 @@ |
2636 | 2636 | } |
2637 | 2637 | } |
2638 | 2638 | }, |
2639 | | - |
| 2639 | + |
2640 | 2640 | /** |
2641 | 2641 | * Base Embed Controls |
2642 | 2642 | */ |
2643 | | - |
| 2643 | + |
2644 | 2644 | /** |
2645 | 2645 | * The Play Action |
2646 | | - * |
| 2646 | + * |
2647 | 2647 | * Handles play requests, updates relevant states: seeking =false paused = |
2648 | 2648 | * false Updates pause button Starts the "monitor" |
2649 | 2649 | */ |
2650 | 2650 | play: function() { |
2651 | 2651 | var _this = this; |
2652 | | - |
| 2652 | + |
2653 | 2653 | if( this.paused && this.bubbleEventCheck() ){ |
2654 | 2654 | this.paused = false; |
2655 | | - mw.log("trigger play event::" + !this.paused); |
2656 | | - $j( this ).trigger( 'play' ); |
| 2655 | + mw.log("trigger play event::" + !this.paused); |
| 2656 | + $j( this ).trigger( 'play' ); |
2657 | 2657 | } |
2658 | 2658 | this.paused = false; |
2659 | | - |
2660 | | - mw.log( "EmbedPlayer:: play" ); |
| 2659 | + |
| 2660 | + mw.log( "EmbedPlayer:: play" ); |
2661 | 2661 | // Hide any overlay: |
2662 | 2662 | this.controlBuilder.closeMenuOverlay(); |
2663 | | - |
| 2663 | + |
2664 | 2664 | // Check if thumbnail is being displayed and embed html |
2665 | 2665 | if ( this.thumbnail_disp ) { |
2666 | 2666 | if ( !this.selectedPlayer ) { |
2667 | 2667 | this.showPluginMissingHTML(); |
2668 | | - return; |
| 2668 | + return; |
2669 | 2669 | } else { |
2670 | 2670 | this.thumbnail_disp = false; |
2671 | 2671 | this.doEmbedHTML(); |
— | — | @@ -2673,32 +2673,32 @@ |
2674 | 2674 | // the plugin is already being displayed |
2675 | 2675 | this.seeking = false; |
2676 | 2676 | } |
2677 | | - |
2678 | | - |
| 2677 | + |
| 2678 | + |
2679 | 2679 | this.$interface.find('.play-btn span') |
2680 | 2680 | .removeClass( 'ui-icon-play' ) |
2681 | 2681 | .addClass( 'ui-icon-pause' ); |
2682 | | - |
| 2682 | + |
2683 | 2683 | this.$interface.find( '.play-btn' ) |
2684 | 2684 | .unbind() |
2685 | 2685 | .buttonHover() |
2686 | 2686 | .click( function( ) { |
2687 | 2687 | _this.pause(); |
2688 | | - } ) |
2689 | | - .attr( 'title', gM( 'mwe-embedplayer-pause_clip' ) ); |
| 2688 | + } ) |
| 2689 | + .attr( 'title', gM( 'mwe-embedplayer-pause_clip' ) ); |
2690 | 2690 | |
2691 | 2691 | // Start the monitor if not already started |
2692 | 2692 | this.monitor(); |
2693 | | - |
2694 | | - // If we previously finished playing this clip run the "replay hook" |
2695 | | - if( this.donePlayingCount > 0 ) { |
2696 | | - mw.log("replayEvent"); |
2697 | | - $j( this ).trigger( 'replayEvent' ); |
2698 | | - } |
| 2693 | + |
| 2694 | + // If we previously finished playing this clip run the "replay hook" |
| 2695 | + if( this.donePlayingCount > 0 ) { |
| 2696 | + mw.log("replayEvent"); |
| 2697 | + $j( this ).trigger( 'replayEvent' ); |
| 2698 | + } |
2699 | 2699 | }, |
2700 | 2700 | /** |
2701 | 2701 | * Returns true if the event should be triggered or false if not |
2702 | | - * |
| 2702 | + * |
2703 | 2703 | * @@FIXME:: firefox nightlies now Do NOT bubble events. Once release tag |
2704 | 2704 | * every version after that |
2705 | 2705 | */ |
— | — | @@ -2708,7 +2708,7 @@ |
2709 | 2709 | } |
2710 | 2710 | return false; |
2711 | 2711 | }, |
2712 | | - |
| 2712 | + |
2713 | 2713 | /** |
2714 | 2714 | * Maps the html5 load request. There is no general way to "load" clips so |
2715 | 2715 | * underling plugin-player libs should override. |
— | — | @@ -2717,10 +2717,10 @@ |
2718 | 2718 | // should be done by child (no base way to pre-buffer video) |
2719 | 2719 | mw.log( 'baseEmbed:load call' ); |
2720 | 2720 | }, |
2721 | | - |
| 2721 | + |
2722 | 2722 | /** |
2723 | 2723 | * Base embed pause Updates the play/pause button state. |
2724 | | - * |
| 2724 | + * |
2725 | 2725 | * There is no general way to pause the video must be overwritten by embed |
2726 | 2726 | * object to support this functionality. |
2727 | 2727 | */ |
— | — | @@ -2734,12 +2734,12 @@ |
2735 | 2735 | $j( this ).trigger('pause' ); |
2736 | 2736 | } |
2737 | 2737 | this.paused = true; |
2738 | | - |
| 2738 | + |
2739 | 2739 | // update the ctrl "paused state" |
2740 | 2740 | this.$interface.find('.play-btn span' ) |
2741 | 2741 | .removeClass( 'ui-icon-pause' ) |
2742 | 2742 | .addClass( 'ui-icon-play' ); |
2743 | | - |
| 2743 | + |
2744 | 2744 | this.$interface.find('.play-btn' ) |
2745 | 2745 | .unbind() |
2746 | 2746 | .buttonHover() |
— | — | @@ -2748,23 +2748,23 @@ |
2749 | 2749 | } ) |
2750 | 2750 | .attr( 'title', gM( 'mwe-embedplayer-play_clip' ) ); |
2751 | 2751 | }, |
2752 | | - |
| 2752 | + |
2753 | 2753 | /** |
2754 | 2754 | * Base embed stop |
2755 | | - * |
| 2755 | + * |
2756 | 2756 | * Updates the player to the stop state shows Thumbnail resets Buffer resets |
2757 | 2757 | * Playhead slider resets Status |
2758 | 2758 | */ |
2759 | 2759 | stop: function() { |
2760 | 2760 | var _this = this; |
2761 | 2761 | mw.log( 'EmbedPlayer::stop:' + this.id ); |
2762 | | - |
| 2762 | + |
2763 | 2763 | // no longer seeking: |
2764 | 2764 | this.didSeekJump = false; |
2765 | | - |
| 2765 | + |
2766 | 2766 | // Reset current time and prev time and seek offset |
2767 | | - this.currentTime = this.previousTime = this.serverSeekTime = 0; |
2768 | | - |
| 2767 | + this.currentTime = this.previousTime = this.serverSeekTime = 0; |
| 2768 | + |
2769 | 2769 | // Issue pause to update interface (only call this parent) |
2770 | 2770 | if( !this.paused ){ |
2771 | 2771 | this.paused = true; |
— | — | @@ -2775,16 +2775,16 @@ |
2776 | 2776 | this.pause(); |
2777 | 2777 | } |
2778 | 2778 | } |
2779 | | - |
| 2779 | + |
2780 | 2780 | // Rewrite the html to thumbnail disp |
2781 | 2781 | this.showThumbnail(); |
2782 | 2782 | this.bufferedPercent = 0; // reset buffer state |
2783 | 2783 | this.controlBuilder.setStatus( this.getTimeRange() ); |
2784 | | - |
| 2784 | + |
2785 | 2785 | // Reset the playhead |
2786 | 2786 | mw.log("EmbedPlayer::Stop:: Reset play head") |
2787 | 2787 | this.updatePlayHead( 0 ); |
2788 | | - |
| 2788 | + |
2789 | 2789 | // Bind play-btn-large play |
2790 | 2790 | this.$interface.find( '.play-btn-large' ) |
2791 | 2791 | .unbind( 'click' ) |
— | — | @@ -2792,10 +2792,10 @@ |
2793 | 2793 | _this.play(); |
2794 | 2794 | } ); |
2795 | 2795 | }, |
2796 | | - |
| 2796 | + |
2797 | 2797 | /** |
2798 | 2798 | * Base Embed mute |
2799 | | - * |
| 2799 | + * |
2800 | 2800 | * Handles interface updates for toggling mute. Plug-in / player interface |
2801 | 2801 | * must handle the actual media player update |
2802 | 2802 | */ |
— | — | @@ -2813,10 +2813,10 @@ |
2814 | 2814 | // Update the interface |
2815 | 2815 | this.setInterfaceVolume( percent ); |
2816 | 2816 | }, |
2817 | | - |
| 2817 | + |
2818 | 2818 | /** |
2819 | 2819 | * Update volume function ( called from interface updates ) |
2820 | | - * |
| 2820 | + * |
2821 | 2821 | * @param {float} |
2822 | 2822 | * percent Percent of full volume |
2823 | 2823 | */ |
— | — | @@ -2827,34 +2827,34 @@ |
2828 | 2828 | } |
2829 | 2829 | // Set the local volume attribute |
2830 | 2830 | this.previousVolume = this.volume = percent; |
2831 | | - |
| 2831 | + |
2832 | 2832 | // Un-mute if setting positive volume |
2833 | 2833 | if( percent != 0 ){ |
2834 | 2834 | this.muted = false; |
2835 | 2835 | } |
2836 | | - |
| 2836 | + |
2837 | 2837 | // Update the playerElement volume |
2838 | 2838 | this.setPlayerElementVolume( percent ); |
2839 | | - |
| 2839 | + |
2840 | 2840 | // mw.log(" setVolume:: " + percent + ' this.volume is: ' + |
2841 | 2841 | // this.volume); |
2842 | 2842 | $j( this ).trigger('volumeChanged', percent ); |
2843 | 2843 | }, |
2844 | | - |
| 2844 | + |
2845 | 2845 | /** |
2846 | 2846 | * Updates the interface volume TODO should move to controlBuilder |
2847 | | - * |
| 2847 | + * |
2848 | 2848 | * @param {float} |
2849 | 2849 | * percent Percentage volume to update interface |
2850 | 2850 | */ |
2851 | 2851 | setInterfaceVolume: function( percent ) { |
2852 | | - if( this.supports[ 'volumeControl' ] && |
2853 | | - this.$interface.find( '.volume-slider' ).length |
| 2852 | + if( this.supports[ 'volumeControl' ] && |
| 2853 | + this.$interface.find( '.volume-slider' ).length |
2854 | 2854 | ) { |
2855 | 2855 | this.$interface.find( '.volume-slider' ).slider( 'value', percent * 100 ); |
2856 | 2856 | } |
2857 | 2857 | }, |
2858 | | - |
| 2858 | + |
2859 | 2859 | /** |
2860 | 2860 | * Abstract Update volume Method must be override by plug-in / player |
2861 | 2861 | * interface |
— | — | @@ -2862,7 +2862,7 @@ |
2863 | 2863 | setPlayerElementVolume: function( percent ) { |
2864 | 2864 | mw.log('Error player does not support volume adjustment' ); |
2865 | 2865 | }, |
2866 | | - |
| 2866 | + |
2867 | 2867 | /** |
2868 | 2868 | * Abstract get volume Method must be override by plug-in / player interface |
2869 | 2869 | * (if player does not override we return the abstract player value ) |
— | — | @@ -2871,7 +2871,7 @@ |
2872 | 2872 | // mw.log(' error player does not support getting volume property' ); |
2873 | 2873 | return this.volume; |
2874 | 2874 | }, |
2875 | | - |
| 2875 | + |
2876 | 2876 | /** |
2877 | 2877 | * Abstract get volume muted property must be overwritten by plug-in / |
2878 | 2878 | * player interface (if player does not override we return the abstract |
— | — | @@ -2881,14 +2881,14 @@ |
2882 | 2882 | // mw.log(' error player does not support getting mute property' ); |
2883 | 2883 | return this.muted; |
2884 | 2884 | }, |
2885 | | - |
| 2885 | + |
2886 | 2886 | /** |
2887 | 2887 | * Passes a fullscreen request to the controlBuilder interface |
2888 | 2888 | */ |
2889 | 2889 | fullscreen: function() { |
2890 | 2890 | this.controlBuilder.toggleFullscreen(); |
2891 | 2891 | }, |
2892 | | - |
| 2892 | + |
2893 | 2893 | /** |
2894 | 2894 | * Abstract method to be run post embedding the player Generally should be |
2895 | 2895 | * overwritten by the plug-in / player |
— | — | @@ -2896,10 +2896,10 @@ |
2897 | 2897 | postEmbedJS:function() { |
2898 | 2898 | return ; |
2899 | 2899 | }, |
2900 | | - |
| 2900 | + |
2901 | 2901 | /** |
2902 | 2902 | * Checks the player state based on thumbnail display & paused state |
2903 | | - * |
| 2903 | + * |
2904 | 2904 | * @return {Boolean} true if playing false if not playing |
2905 | 2905 | */ |
2906 | 2906 | isPlaying : function() { |
— | — | @@ -2913,30 +2913,30 @@ |
2914 | 2914 | return true; |
2915 | 2915 | } |
2916 | 2916 | }, |
2917 | | - |
| 2917 | + |
2918 | 2918 | /** |
2919 | 2919 | * Get paused state |
2920 | | - * |
| 2920 | + * |
2921 | 2921 | * @return {Boolean} true if playing false if not playing |
2922 | 2922 | */ |
2923 | 2923 | isPaused: function() { |
2924 | 2924 | return this.paused; |
2925 | 2925 | }, |
2926 | | - |
| 2926 | + |
2927 | 2927 | /** |
2928 | 2928 | * Get Stopped state |
2929 | | - * |
| 2929 | + * |
2930 | 2930 | * @return {Boolean} true if stopped false if playing |
2931 | 2931 | */ |
2932 | 2932 | isStopped: function() { |
2933 | 2933 | return this.thumbnail_disp; |
2934 | 2934 | }, |
2935 | | - |
| 2935 | + |
2936 | 2936 | // xxx temporary hack we need a better stop monitor system |
2937 | 2937 | stopMonitor: function(){ |
2938 | 2938 | this.thumbnail_disp = true; |
2939 | 2939 | }, |
2940 | | - |
| 2940 | + |
2941 | 2941 | /** |
2942 | 2942 | * Checks if the currentTime was updated outside of the getPlayerElementTime |
2943 | 2943 | * function |
— | — | @@ -2954,20 +2954,20 @@ |
2955 | 2955 | } |
2956 | 2956 | } |
2957 | 2957 | }, |
2958 | | - |
| 2958 | + |
2959 | 2959 | /** |
2960 | 2960 | * Monitor playback and update interface components. underling plugin |
2961 | 2961 | * objects are responsible for updating currentTime |
2962 | 2962 | */ |
2963 | 2963 | monitor: function() { |
2964 | 2964 | var _this = this; |
2965 | | - |
| 2965 | + |
2966 | 2966 | // Check for current time update outside of embed player |
2967 | 2967 | this.checkForCurrentTimeSeek(); |
2968 | | - |
| 2968 | + |
2969 | 2969 | // Update currentTime via embedPlayer |
2970 | 2970 | _this.currentTime = _this.getPlayerElementTime(); |
2971 | | - |
| 2971 | + |
2972 | 2972 | // Update any offsets from server seek |
2973 | 2973 | if( _this.serverSeekTime && _this.supportsURLTimeEncoding ){ |
2974 | 2974 | _this.currentTime = _this.serverSeekTime + _this.getPlayerElementTime() |
— | — | @@ -2976,8 +2976,8 @@ |
2977 | 2977 | // Update the previousTime ( so we can know if the user-javascript |
2978 | 2978 | // changed currentTime ) |
2979 | 2979 | _this.previousTime = _this.currentTime; |
2980 | | - |
2981 | | - |
| 2980 | + |
| 2981 | + |
2982 | 2982 | // Check if volume was set outside of embed player function |
2983 | 2983 | // mw.log( ' this.volume: ' + _this.volume + ' prev Volume:: ' + |
2984 | 2984 | // _this.previousVolume ); |
— | — | @@ -2985,21 +2985,21 @@ |
2986 | 2986 | _this.setInterfaceVolume( _this.volume ); |
2987 | 2987 | $j( this ).trigger('volumeChanged', _this.volume ); |
2988 | 2988 | } |
2989 | | - |
| 2989 | + |
2990 | 2990 | // Update the previous volume |
2991 | 2991 | _this.previousVolume = _this.volume; |
2992 | | - |
| 2992 | + |
2993 | 2993 | // Update the volume from the player element |
2994 | 2994 | _this.volume = this.getPlayerElementVolume(); |
2995 | | - |
| 2995 | + |
2996 | 2996 | // update the mute state from the player element |
2997 | 2997 | if( _this.muted != _this.getPlayerElementMuted() && ! _this.isStopped() ){ |
2998 | 2998 | mw.log( "EmbedPlayer::monitor: muted does not mach embed player" ); |
2999 | 2999 | _this.toggleMute(); |
3000 | 3000 | // Make sure they match: |
3001 | | - _this.muted = _this.getPlayerElementMuted(); |
| 3001 | + _this.muted = _this.getPlayerElementMuted(); |
3002 | 3002 | } |
3003 | | - |
| 3003 | + |
3004 | 3004 | // mw.log( 'Monitor:: ' + this.currentTime + ' duration: ' + ( parseInt( |
3005 | 3005 | // this.getDuration() ) + 1 ) + ' is seeking: ' + this.seeking ); |
3006 | 3006 | if ( this.currentTime >= 0 && this.duration ) { |
— | — | @@ -3037,16 +3037,16 @@ |
3038 | 3038 | this.controlBuilder.setStatus( this.getTimeRange() ); |
3039 | 3039 | } |
3040 | 3040 | } |
3041 | | - |
| 3041 | + |
3042 | 3042 | // Update buffer information |
3043 | 3043 | this.updateBufferStatus(); |
3044 | | - |
| 3044 | + |
3045 | 3045 | // run the "native" progress event on the virtual html5 object if set |
3046 | 3046 | if( this.progressEventData ) { |
3047 | 3047 | // mw.log("trigger:progress event on html5 proxy"); |
3048 | 3048 | $j( this ).trigger( 'progress', this.progressEventData ); |
3049 | 3049 | } |
3050 | | - |
| 3050 | + |
3051 | 3051 | // Call monitor at 250ms interval. ( use setInterval to avoid stacking |
3052 | 3052 | // monitor requests ) |
3053 | 3053 | if( ! this.isStopped() ) { |
— | — | @@ -3061,23 +3061,23 @@ |
3062 | 3062 | clearInterval( this.monitorInterval ); |
3063 | 3063 | this.monitorInterval = 0; |
3064 | 3064 | } |
3065 | | - |
| 3065 | + |
3066 | 3066 | // mw.log('trigger:monitor:: ' + this.currentTime ); |
3067 | 3067 | $j( this ).trigger( 'monitorEvent' ); |
3068 | 3068 | }, |
3069 | | - |
| 3069 | + |
3070 | 3070 | /** |
3071 | 3071 | * Abstract getPlayerElementTime function |
3072 | 3072 | */ |
3073 | 3073 | getPlayerElementTime: function(){ |
3074 | 3074 | mw.log("Error: getPlayerElementTime should be implemented by embed library"); |
3075 | 3075 | }, |
3076 | | - |
| 3076 | + |
3077 | 3077 | /** |
3078 | 3078 | * Update the Buffer status based on the local bufferedPercent var |
3079 | 3079 | */ |
3080 | 3080 | updateBufferStatus: function() { |
3081 | | - |
| 3081 | + |
3082 | 3082 | // Get the buffer target based for playlist vs clip |
3083 | 3083 | $buffer = this.$interface.find( '.mw_buffer' ); |
3084 | 3084 | //mw.log(' set bufferd %:' + this.bufferedPercent ); |
— | — | @@ -3087,7 +3087,7 @@ |
3088 | 3088 | // '% ' + $buffer.length ); |
3089 | 3089 | if ( this.bufferedPercent > 1 ){ |
3090 | 3090 | this.bufferedPercent = 1; |
3091 | | - } |
| 3091 | + } |
3092 | 3092 | $buffer.css({ |
3093 | 3093 | "width" : ( this.bufferedPercent * 100 ) + '%' |
3094 | 3094 | }); |
— | — | @@ -3095,24 +3095,24 @@ |
3096 | 3096 | } else { |
3097 | 3097 | $buffer.css( "width", '0px' ); |
3098 | 3098 | } |
3099 | | - |
| 3099 | + |
3100 | 3100 | // if we have not already run the buffer start hook |
3101 | 3101 | if( this.bufferedPercent > 0 && !this.bufferStartFlag ) { |
3102 | 3102 | this.bufferStartFlag = true; |
3103 | 3103 | mw.log("bufferStart"); |
3104 | 3104 | $j( this ).trigger( 'bufferStartEvent' ); |
3105 | 3105 | } |
3106 | | - |
| 3106 | + |
3107 | 3107 | // if we have not already run the buffer end hook |
3108 | 3108 | if( this.bufferedPercent == 1 && !this.bufferEndFlag){ |
3109 | 3109 | this.bufferEndFlag = true; |
3110 | 3110 | $j( this ).trigger( 'bufferEndEvent' ); |
3111 | 3111 | } |
3112 | 3112 | }, |
3113 | | - |
| 3113 | + |
3114 | 3114 | /** |
3115 | 3115 | * Update the player playhead |
3116 | | - * |
| 3116 | + * |
3117 | 3117 | * @param {Float} |
3118 | 3118 | * perc Value between 0 and 1 for position of playhead |
3119 | 3119 | */ |
— | — | @@ -3125,10 +3125,10 @@ |
3126 | 3126 | // @@todo should have 'progress' trigger the same as html5 |
3127 | 3127 | $j( this ).trigger('updatePlayHeadPercent', perc); |
3128 | 3128 | }, |
3129 | | - |
| 3129 | + |
3130 | 3130 | /** |
3131 | 3131 | * Highlight a section of video on the playhead |
3132 | | - * |
| 3132 | + * |
3133 | 3133 | * @param {Object} |
3134 | 3134 | * options Provides "start" time & "end" time to highlight |
3135 | 3135 | */ |
— | — | @@ -3141,7 +3141,7 @@ |
3142 | 3142 | // remove the startOffset if relevent: |
3143 | 3143 | if ( this.startOffset ) |
3144 | 3144 | rel_start_sec = rel_start_sec - this.startOffset |
3145 | | - |
| 3145 | + |
3146 | 3146 | var slider_perc = 0; |
3147 | 3147 | if ( rel_start_sec <= 0 ) { |
3148 | 3148 | left_perc = 0; |
— | — | @@ -3152,12 +3152,12 @@ |
3153 | 3153 | left_perc = parseInt( ( rel_start_sec / dur ) * 100 ) ; |
3154 | 3154 | slider_perc = ( left_perc / 100 ); |
3155 | 3155 | } |
3156 | | - |
| 3156 | + |
3157 | 3157 | mw.log( "slider perc:" + slider_perc ); |
3158 | 3158 | if ( ! this.isPlaying() ) { |
3159 | 3159 | this.updatePlayHead( slider_perc ); |
3160 | 3160 | } |
3161 | | - |
| 3161 | + |
3162 | 3162 | width_perc = parseInt( ( ( mw.npt2seconds( options['end'] ) - mw.npt2seconds( options['start'] ) ) / dur ) * 100 ) ; |
3163 | 3163 | if ( ( width_perc + left_perc ) > 100 ) { |
3164 | 3164 | width_perc = 100 - left_perc; |
— | — | @@ -3168,7 +3168,7 @@ |
3169 | 3169 | 'left' : left_perc + '%', |
3170 | 3170 | 'width' : width_perc + '%' |
3171 | 3171 | } ).show(); |
3172 | | - |
| 3172 | + |
3173 | 3173 | this.jump_time = options['start']; |
3174 | 3174 | this.serverSeekTime = mw.npt2seconds( options['start'] ); |
3175 | 3175 | // trim output to |
— | — | @@ -3176,7 +3176,7 @@ |
3177 | 3177 | mw.log( 'DO update: ' + this.jump_time ); |
3178 | 3178 | this.updateThumbTime( rel_start_sec ); |
3179 | 3179 | }, |
3180 | | - |
| 3180 | + |
3181 | 3181 | /** |
3182 | 3182 | * Hides the playhead highlight |
3183 | 3183 | */ |
— | — | @@ -3185,15 +3185,15 @@ |
3186 | 3186 | $j( '#mv_seeker_' + eid + ' .mv_highlight' ).hide(); |
3187 | 3187 | this.controlBuilder.setStatus( this.getTimeRange() ); |
3188 | 3188 | }, |
3189 | | - |
3190 | | - |
| 3189 | + |
| 3190 | + |
3191 | 3191 | /** |
3192 | 3192 | * Helper Functions for selected source |
3193 | 3193 | */ |
3194 | | - |
| 3194 | + |
3195 | 3195 | /** |
3196 | 3196 | * Get the current selected media source |
3197 | | - * |
| 3197 | + * |
3198 | 3198 | * @return src url |
3199 | 3199 | */ |
3200 | 3200 | getSrc: function() { |
— | — | @@ -3202,10 +3202,10 @@ |
3203 | 3203 | } |
3204 | 3204 | return false; |
3205 | 3205 | }, |
3206 | | - |
| 3206 | + |
3207 | 3207 | /** |
3208 | 3208 | * If the selected src supports URL time encoding |
3209 | | - * |
| 3209 | + * |
3210 | 3210 | * @return {Boolean} ture if the src supports url time requests false if the |
3211 | 3211 | * src does not support url time requests |
3212 | 3212 | */ |
— | — | @@ -3219,7 +3219,7 @@ |
3220 | 3220 | |
3221 | 3221 | /** |
3222 | 3222 | * mediaPlayer represents a media player plugin. |
3223 | | - * |
| 3223 | + * |
3224 | 3224 | * @param {String} |
3225 | 3225 | * id id used for the plugin. |
3226 | 3226 | * @param {Array} |
— | — | @@ -3240,24 +3240,24 @@ |
3241 | 3241 | mediaPlayer.prototype = { |
3242 | 3242 | // Id of the mediaPlayer |
3243 | 3243 | id:null, |
3244 | | - |
| 3244 | + |
3245 | 3245 | // Mime types supported by this player |
3246 | 3246 | supported_types:null, |
3247 | | - |
| 3247 | + |
3248 | 3248 | // Player library ie: native, vlc, java etc. |
3249 | 3249 | library:null, |
3250 | | - |
| 3250 | + |
3251 | 3251 | // Flag stores the mediaPlayer load state |
3252 | 3252 | loaded:false, |
3253 | | - |
| 3253 | + |
3254 | 3254 | /** |
3255 | 3255 | * Checks support for a given MIME type |
3256 | | - * |
| 3256 | + * |
3257 | 3257 | * @param {String} |
3258 | 3258 | * type Mime type to check against supported_types |
3259 | 3259 | * @return {Boolean} true if mime type is supported false if mime type is |
3260 | 3260 | * unsupported |
3261 | | - */ |
| 3261 | + */ |
3262 | 3262 | supportsMIMEType: function( type ) { |
3263 | 3263 | for ( var i = 0; i < this.supported_types.length; i++ ) { |
3264 | 3264 | if ( this.supported_types[i] == type ) |
— | — | @@ -3265,18 +3265,18 @@ |
3266 | 3266 | } |
3267 | 3267 | return false; |
3268 | 3268 | }, |
3269 | | - |
| 3269 | + |
3270 | 3270 | /** |
3271 | 3271 | * Get the "name" of the player from a predictable msg key |
3272 | 3272 | */ |
3273 | 3273 | getName: function() { |
3274 | 3274 | return gM( 'mwe-embedplayer-ogg-player-' + this.id ); |
3275 | 3275 | }, |
3276 | | - |
| 3276 | + |
3277 | 3277 | /** |
3278 | 3278 | * Loads the player library & player skin config ( if needed ) and then |
3279 | 3279 | * calls the callback. |
3280 | | - * |
| 3280 | + * |
3281 | 3281 | * @param {Function} |
3282 | 3282 | * callback Function to be called once player library is loaded. |
3283 | 3283 | */ |
— | — | @@ -3293,10 +3293,10 @@ |
3294 | 3294 | /** |
3295 | 3295 | * players and supported mime types In an ideal world we would query the plugin |
3296 | 3296 | * to get what mime types it supports in practice not always reliable/available |
3297 | | - * |
| 3297 | + * |
3298 | 3298 | * We can't cleanly store these values per library since player library is |
3299 | 3299 | * loaded post player detection |
3300 | | - * |
| 3300 | + * |
3301 | 3301 | */ |
3302 | 3302 | |
3303 | 3303 | // Flash based players: |
— | — | @@ -3324,7 +3324,7 @@ |
3325 | 3325 | |
3326 | 3326 | /** |
3327 | 3327 | * mediaPlayers is a collection of mediaPlayer objects supported by the client. |
3328 | | - * |
| 3328 | + * |
3329 | 3329 | * @constructor |
3330 | 3330 | */ |
3331 | 3331 | function mediaPlayers() |
— | — | @@ -3336,13 +3336,13 @@ |
3337 | 3337 | { |
3338 | 3338 | // The list of players supported |
3339 | 3339 | players : null, |
3340 | | - |
| 3340 | + |
3341 | 3341 | // Store per mime-type prefrences for players |
3342 | 3342 | preference : { }, |
3343 | | - |
| 3343 | + |
3344 | 3344 | // Stores the default set of players for a given mime type |
3345 | 3345 | defaultPlayers : { }, |
3346 | | - |
| 3346 | + |
3347 | 3347 | /** |
3348 | 3348 | * Initializartion function sets the default order for players for a given |
3349 | 3349 | * mime type |
— | — | @@ -3350,11 +3350,11 @@ |
3351 | 3351 | init: function() { |
3352 | 3352 | this.players = new Array(); |
3353 | 3353 | this.loadPreferences(); |
3354 | | - |
| 3354 | + |
3355 | 3355 | // set up default players order for each library type |
3356 | 3356 | this.defaultPlayers['video/x-flv'] = ['Kplayer', 'Vlc']; |
3357 | 3357 | this.defaultPlayers['video/h264'] = ['Native', 'Kplayer', 'Vlc']; |
3358 | | - |
| 3358 | + |
3359 | 3359 | this.defaultPlayers['video/ogg'] = ['Native', 'Vlc', 'Java', 'Generic']; |
3360 | 3360 | this.defaultPlayers['video/webm'] = ['Native', 'Vlc']; |
3361 | 3361 | this.defaultPlayers['application/ogg'] = ['Native', 'Vlc', 'Java', 'Generic']; |
— | — | @@ -3362,17 +3362,17 @@ |
3363 | 3363 | this.defaultPlayers['video/mp4'] = ['Vlc']; |
3364 | 3364 | this.defaultPlayers['video/mpeg'] = ['Vlc']; |
3365 | 3365 | this.defaultPlayers['video/x-msvideo'] = ['Vlc']; |
3366 | | - |
| 3366 | + |
3367 | 3367 | this.defaultPlayers['text/html'] = ['Html']; |
3368 | 3368 | this.defaultPlayers['image/jpeg'] = ['Html']; |
3369 | 3369 | this.defaultPlayers['image/png'] = ['Html']; |
3370 | 3370 | this.defaultPlayers['image/svg'] = ['Html']; |
3371 | | - |
| 3371 | + |
3372 | 3372 | }, |
3373 | | - |
| 3373 | + |
3374 | 3374 | /** |
3375 | 3375 | * Adds a Player to the player list |
3376 | | - * |
| 3376 | + * |
3377 | 3377 | * @param {Object} |
3378 | 3378 | * player Player object to be added |
3379 | 3379 | */ |
— | — | @@ -3383,12 +3383,12 @@ |
3384 | 3384 | return ; |
3385 | 3385 | } |
3386 | 3386 | } |
3387 | | - |
3388 | | - |
| 3387 | + |
| 3388 | + |
3389 | 3389 | // Add the player: |
3390 | 3390 | this.players.push( player ); |
3391 | 3391 | }, |
3392 | | - |
| 3392 | + |
3393 | 3393 | /** |
3394 | 3394 | * Checks if a player is supported by id |
3395 | 3395 | */ |
— | — | @@ -3400,10 +3400,10 @@ |
3401 | 3401 | } |
3402 | 3402 | return false; |
3403 | 3403 | }, |
3404 | | - |
| 3404 | + |
3405 | 3405 | /** |
3406 | 3406 | * get players that support a given mimeType |
3407 | | - * |
| 3407 | + * |
3408 | 3408 | * @param {String} |
3409 | 3409 | * mimeType Mime type of player set |
3410 | 3410 | * @return {Array} Array of players that support a the requested mime type |
— | — | @@ -3423,10 +3423,10 @@ |
3424 | 3424 | } |
3425 | 3425 | return mimePlayers; |
3426 | 3426 | }, |
3427 | | - |
| 3427 | + |
3428 | 3428 | /** |
3429 | 3429 | * Default player for a given mime type |
3430 | | - * |
| 3430 | + * |
3431 | 3431 | * @param {String} |
3432 | 3432 | * mimeType Mime type of the requested player |
3433 | 3433 | * @return Player for mime type null if no player found |
— | — | @@ -3448,21 +3448,21 @@ |
3449 | 3449 | // mw.log( 'No default player found for ' + mimeType ); |
3450 | 3450 | return null; |
3451 | 3451 | }, |
3452 | | - |
| 3452 | + |
3453 | 3453 | /** |
3454 | 3454 | * Sets the format preference. |
3455 | | - * |
| 3455 | + * |
3456 | 3456 | * @param {String} |
3457 | 3457 | * mimeFormat Prefered format |
3458 | 3458 | */ |
3459 | 3459 | setFormatPreference : function ( mimeFormat ) { |
3460 | 3460 | this.preference['format_preference'] = mimeFormat; |
3461 | | - mw.setUserConfig( 'playerPref', this.preference); |
| 3461 | + mw.setUserConfig( 'playerPref', this.preference); |
3462 | 3462 | }, |
3463 | | - |
| 3463 | + |
3464 | 3464 | /** |
3465 | 3465 | * Sets the player preference |
3466 | | - * |
| 3466 | + * |
3467 | 3467 | * @param {String} |
3468 | 3468 | * playerId Prefered player id |
3469 | 3469 | * @param {String} |
— | — | @@ -3481,7 +3481,7 @@ |
3482 | 3482 | } |
3483 | 3483 | // Update All the player instances: |
3484 | 3484 | if ( selectedPlayer ) { |
3485 | | - var playerList = mw.playerManager.getPlayerList(); |
| 3485 | + var playerList = mw.playerManager.getPlayerList(); |
3486 | 3486 | for ( var i = 0; i < playerList.length; i++ ) { |
3487 | 3487 | var embed = $j( '#' + playerList[i] ).get( 0 ); |
3488 | 3488 | if ( embed.mediaElement.selectedSource && ( embed.mediaElement.selectedSource.mimeType == mimeType ) ) |
— | — | @@ -3492,11 +3492,11 @@ |
3493 | 3493 | } |
3494 | 3494 | } |
3495 | 3495 | }, |
3496 | | - |
| 3496 | + |
3497 | 3497 | /** |
3498 | 3498 | * Loads the user preference settings from a cookie |
3499 | 3499 | */ |
3500 | | - loadPreferences : function ( ) { |
| 3500 | + loadPreferences : function ( ) { |
3501 | 3501 | this.preference = { }; |
3502 | 3502 | // see if we have a cookie set to a clientSupported type: |
3503 | 3503 | preferenceConfig = mw.getUserConfig( 'playerPref' ); |
— | — | @@ -3515,13 +3515,13 @@ |
3516 | 3516 | |
3517 | 3517 | // List of players supported |
3518 | 3518 | players: null, |
3519 | | - |
| 3519 | + |
3520 | 3520 | // Detect flag for completion |
3521 | 3521 | detect_done:false, |
3522 | | - |
| 3522 | + |
3523 | 3523 | /** |
3524 | 3524 | * Runs the detect method and update the detect_done flag |
3525 | | - * |
| 3525 | + * |
3526 | 3526 | * @constructor |
3527 | 3527 | */ |
3528 | 3528 | init: function() { |
— | — | @@ -3529,10 +3529,10 @@ |
3530 | 3530 | this.detect(); |
3531 | 3531 | this.detect_done = true; |
3532 | 3532 | }, |
3533 | | - |
| 3533 | + |
3534 | 3534 | /** |
3535 | 3535 | * If the browsers supports a given mimetype |
3536 | | - * |
| 3536 | + * |
3537 | 3537 | * @param {String} |
3538 | 3538 | * mimeType Mime type for browser plug-in check |
3539 | 3539 | */ |
— | — | @@ -3544,7 +3544,7 @@ |
3545 | 3545 | } |
3546 | 3546 | return false; |
3547 | 3547 | }, |
3548 | | - |
| 3548 | + |
3549 | 3549 | /** |
3550 | 3550 | * Detects what plug-ins the client supports |
3551 | 3551 | */ |
— | — | @@ -3559,11 +3559,11 @@ |
3560 | 3560 | try{ |
3561 | 3561 | var javaEnabled = navigator.javaEnabled(); |
3562 | 3562 | } catch ( e ){ |
3563 | | - |
| 3563 | + |
3564 | 3564 | } |
3565 | 3565 | // Some browsers filter out duplicate mime types, hiding some plugins |
3566 | 3566 | var uniqueMimesOnly = $j.browser.opera || $j.browser.safari; |
3567 | | - |
| 3567 | + |
3568 | 3568 | // Opera will switch off javaEnabled in preferences if java can't be |
3569 | 3569 | // found. |
3570 | 3570 | // And it doesn't register an application/x-java-applet mime type like |
— | — | @@ -3571,7 +3571,7 @@ |
3572 | 3572 | if ( javaEnabled && ( navigator.appName == 'Opera' ) ) { |
3573 | 3573 | this.players.addPlayer( cortadoPlayer ); |
3574 | 3574 | } |
3575 | | - |
| 3575 | + |
3576 | 3576 | // ActiveX plugins |
3577 | 3577 | if ( $j.browser.msie ) { |
3578 | 3578 | // check for flash |
— | — | @@ -3583,12 +3583,12 @@ |
3584 | 3584 | if ( this.testActiveX( 'VideoLAN.VLCPlugin.2' ) ) { |
3585 | 3585 | this.players.addPlayer( vlcPlayer ); |
3586 | 3586 | } |
3587 | | - |
| 3587 | + |
3588 | 3588 | // Java ActiveX |
3589 | 3589 | if ( this.testActiveX( 'JavaWebStart.isInstalled' ) ) { |
3590 | 3590 | this.players.addPlayer( cortadoPlayer ); |
3591 | 3591 | } |
3592 | | - |
| 3592 | + |
3593 | 3593 | // quicktime (currently off) |
3594 | 3594 | // if ( this.testActiveX( |
3595 | 3595 | // 'QuickTimeCheckObject.QuickTimeCheck.1' ) ) |
— | — | @@ -3604,9 +3604,9 @@ |
3605 | 3605 | if( dummyvid.canPlayType ) { |
3606 | 3606 | // Add the webm player |
3607 | 3607 | if( dummyvid.canPlayType('video/webm; codecs="vp8, vorbis"') ){ |
3608 | | - this.players.addPlayer( webmNativePlayer ); |
| 3608 | + this.players.addPlayer( webmNativePlayer ); |
3609 | 3609 | } |
3610 | | - |
| 3610 | + |
3611 | 3611 | // Test for h264: |
3612 | 3612 | if ( dummyvid.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"' ) ) { |
3613 | 3613 | this.players.addPlayer( h264NativePlayer ); |
— | — | @@ -3616,7 +3616,7 @@ |
3617 | 3617 | if ( mw.isAndroid2() ){ |
3618 | 3618 | this.players.addPlayer( h264NativePlayer ); |
3619 | 3619 | } |
3620 | | - |
| 3620 | + |
3621 | 3621 | // Test for ogg |
3622 | 3622 | if ( dummyvid.canPlayType( 'video/ogg; codecs="theora,vorbis"' ) ) { |
3623 | 3623 | this.players.addPlayer( oggNativePlayer ); |
— | — | @@ -3629,8 +3629,8 @@ |
3630 | 3630 | } catch ( e ) { |
3631 | 3631 | mw.log( 'could not run canPlayType ' + e ); |
3632 | 3632 | } |
3633 | | - } |
3634 | | - |
| 3633 | + } |
| 3634 | + |
3635 | 3635 | // "navigator" plugins |
3636 | 3636 | if ( navigator.mimeTypes && navigator.mimeTypes.length > 0 ) { |
3637 | 3637 | for ( var i = 0; i < navigator.mimeTypes.length; i++ ) { |
— | — | @@ -3649,17 +3649,17 @@ |
3650 | 3650 | this.players.addPlayer( vlcPlayer ); |
3651 | 3651 | continue; |
3652 | 3652 | } |
3653 | | - |
| 3653 | + |
3654 | 3654 | if ( type == 'application/x-java-applet' ) { |
3655 | 3655 | this.players.addPlayer( cortadoPlayer ); |
3656 | 3656 | continue; |
3657 | 3657 | } |
3658 | | - |
| 3658 | + |
3659 | 3659 | if ( (type == 'video/mpeg' || type=='video/x-msvideo') && |
3660 | | - pluginName.toLowerCase() == 'vlc multimedia plugin' ) { |
| 3660 | + pluginName.toLowerCase() == 'vlc multimedia plugin' ) { |
3661 | 3661 | this.players.addPlayer( vlcMozillaPlayer ); |
3662 | | - } |
3663 | | - |
| 3662 | + } |
| 3663 | + |
3664 | 3664 | if ( type == 'application/ogg' ) { |
3665 | 3665 | if ( pluginName.toLowerCase() == 'vlc multimedia plugin' ) { |
3666 | 3666 | this.players.addPlayer( vlcMozillaPlayer ); |
— | — | @@ -3678,12 +3678,12 @@ |
3679 | 3679 | continue; |
3680 | 3680 | } |
3681 | 3681 | } |
3682 | | - |
| 3682 | + |
3683 | 3683 | if ( type == 'application/x-shockwave-flash' ) { |
3684 | | - |
| 3684 | + |
3685 | 3685 | this.players.addPlayer( kplayer ); |
3686 | 3686 | // this.players.addPlayer( flowPlayer ); |
3687 | | - |
| 3687 | + |
3688 | 3688 | // check version to add omtk: |
3689 | 3689 | if( navigator.plugins["Shockwave Flash"] ){ |
3690 | 3690 | var flashDescription = navigator.plugins["Shockwave Flash"].description; |
— | — | @@ -3696,16 +3696,16 @@ |
3697 | 3697 | } |
3698 | 3698 | } |
3699 | 3699 | } |
3700 | | - |
| 3700 | + |
3701 | 3701 | // Allow extensions to detect and add their own "players" |
3702 | 3702 | mw.log("trigger::embedPlayerUpdateMediaPlayersEvent"); |
3703 | 3703 | $j( mw ).trigger( 'embedPlayerUpdateMediaPlayersEvent' , this.players ); |
3704 | | - |
| 3704 | + |
3705 | 3705 | }, |
3706 | | - |
| 3706 | + |
3707 | 3707 | /** |
3708 | 3708 | * Test IE for activeX by name |
3709 | | - * |
| 3709 | + * |
3710 | 3710 | * @param {String} |
3711 | 3711 | * name Name of ActiveXObject to look for |
3712 | 3712 | */ |
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.IFramePlayerApiClient.js |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | /** |
3 | | -* iFrame api mapping support |
4 | | -* |
5 | | -* Client side ( binds a given iFrames to expose the player api ) |
| 3 | +* iFrame api mapping support |
| 4 | +* |
| 5 | +* Client side ( binds a given iFrames to expose the player api ) |
6 | 6 | */ |
7 | 7 | mw.IFramePlayerApiClient = function( iframe, playerProxy, options ){ |
8 | 8 | return this.init( iframe , playerProxy, options); |
— | — | @@ -48,11 +48,11 @@ |
49 | 49 | //mw.log("IframePlayerApiClient:: hanldeReciveMsg "); |
50 | 50 | // Confirm the event is coming for the target host: |
51 | 51 | if( event.origin != this.iframeServer){ |
52 | | - mw.log("Skip msg from host does not match iFrame player: " + event.origin + |
| 52 | + mw.log("Skip msg from host does not match iFrame player: " + event.origin + |
53 | 53 | ' != iframe Server: ' + this.iframeServer ) |
54 | 54 | return ; |
55 | 55 | }; |
56 | | - // Decode the message |
| 56 | + // Decode the message |
57 | 57 | var msgObject = JSON.parse( event.data ); |
58 | 58 | var playerAttributes = mw.getConfig( 'EmbedPlayer.Attributes' ); |
59 | 59 | // Before we update local attributes check that the object has not been updated by user js |
— | — | @@ -60,7 +60,7 @@ |
61 | 61 | if( attrName != 'id' ){ |
62 | 62 | if( _this._prevPlayerProxy[ attrName ] != _this.playerProxy[ attrName ] ){ |
63 | 63 | mw.log( "IFramePlayerApiClient:: User js update:" + attrName + ' set to: ' + this.playerProxy[ attrName ] + ' != old: ' + _this._prevPlayerProxy[ attrName ] ); |
64 | | - // Send the updated attribute back to the iframe: |
| 64 | + // Send the updated attribute back to the iframe: |
65 | 65 | _this.postMessage({ |
66 | 66 | 'attrName' : attrName, |
67 | 67 | 'attrValue' : _this.playerProxy[ attrName ] |
— | — | @@ -81,7 +81,7 @@ |
82 | 82 | } |
83 | 83 | } |
84 | 84 | } |
85 | | - // Trigger any binding events |
| 85 | + // Trigger any binding events |
86 | 86 | if( typeof msgObject.triggerName != 'undefined' && msgObject.triggerArgs != 'undefined') { |
87 | 87 | mw.log('IFramePlayerApiClient:: trigger: ' + msgObject.triggerName ); |
88 | 88 | $j( _this.playerProxy ).trigger( msgObject.triggerName, msgObject.triggerArgs ); |
— | — | @@ -91,9 +91,9 @@ |
92 | 92 | 'postMessage': function( msgObj ){ |
93 | 93 | mw.log( "IFramePlayerApiClient:: postMessage(): " + JSON.stringify( msgObj ) ); |
94 | 94 | $j.postMessage( |
95 | | - JSON.stringify( msgObj ), |
96 | | - mw.absoluteUrl( $j( this.iframe ).attr('src') ), |
97 | | - this.iframe.contentWindow |
| 95 | + JSON.stringify( msgObj ), |
| 96 | + mw.absoluteUrl( $j( this.iframe ).attr('src') ), |
| 97 | + this.iframe.contentWindow |
98 | 98 | ); |
99 | 99 | } |
100 | 100 | }; |
— | — | @@ -107,7 +107,7 @@ |
108 | 108 | // Append '_ifp' ( iframe player ) to id of real iframe so that 'id', and 'src' attributes don't conflict |
109 | 109 | var originalIframeId = ( $( this.selector ).attr( 'id' ) )? $( this.selector ).attr( 'id' ) : Math.floor( 9999999 * Math.random() ); |
110 | 110 | var iframePlayerId = originalIframeId + '_ifp' ; // here we use random to generate a unique id |
111 | | - // Append the div element proxy after the iframe |
| 111 | + // Append the div element proxy after the iframe |
112 | 112 | $j( this.selector ) |
113 | 113 | .attr('id', iframePlayerId) |
114 | 114 | .after( |
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/skins/mw.PlayerControlBuilder.js |
— | — | @@ -147,8 +147,8 @@ |
148 | 148 | var $controlBar = embedPlayer.$interface.find( '.control-bar' ); |
149 | 149 | |
150 | 150 | this.available_width = embedPlayer.getPlayerWidth(); |
151 | | - |
152 | | - mw.log( 'PlayerControlsBuilder:: addControlComponents into:' + this.available_width ); |
| 151 | + |
| 152 | + mw.log( 'PlayerControlsBuilder:: addControlComponents into:' + this.available_width ); |
153 | 153 | // Build the supportedComponets list |
154 | 154 | this.supportedComponets = $j.extend( this.supportedComponets, embedPlayer.supports ); |
155 | 155 | |
— | — | @@ -200,33 +200,33 @@ |
201 | 201 | |
202 | 202 | /** |
203 | 203 | * Get a window size for the player while preserving aspect ratio: |
204 | | - * |
| 204 | + * |
205 | 205 | * @param {object} windowSize |
206 | 206 | * object that set { 'width': {width}, 'height':{height} } of target window |
207 | | - * @return {object} |
| 207 | + * @return {object} |
208 | 208 | * css settings for fullscreen player |
209 | | - */ |
| 209 | + */ |
210 | 210 | getAspectPlayerWindowCss: function( windowSize ) { |
211 | 211 | var embedPlayer = this.embedPlayer; |
212 | 212 | // Setup target height width based on max window size |
213 | 213 | if( !windowSize ){ |
214 | 214 | var windowSize = { |
215 | 215 | 'width' : $j( window ).width(), |
216 | | - 'height' : $j( window ).height() |
| 216 | + 'height' : $j( window ).height() |
217 | 217 | }; |
218 | 218 | } |
219 | 219 | // Set target width |
220 | 220 | var targetWidth = windowSize.width; |
221 | | - var targetHeight = targetWidth * ( embedPlayer.getHeight() / embedPlayer.getWidth() ); |
222 | | - // Check if it exceeds the height constraint: |
223 | | - if( targetHeight > windowSize.height ){ |
224 | | - targetHeight = windowSize.height; |
225 | | - targetWidth = targetHeight * ( embedPlayer.getWidth() / embedPlayer.getHeight() ); |
| 221 | + var targetHeight = targetWidth * ( embedPlayer.getHeight() / embedPlayer.getWidth() ); |
| 222 | + // Check if it exceeds the height constraint: |
| 223 | + if( targetHeight > windowSize.height ){ |
| 224 | + targetHeight = windowSize.height; |
| 225 | + targetWidth = targetHeight * ( embedPlayer.getWidth() / embedPlayer.getHeight() ); |
226 | 226 | } |
227 | 227 | var offsetTop = ( targetHeight < windowSize.height )? ( windowSize.height- targetHeight ) / 2 : 0; |
228 | 228 | var offsetLeft = ( targetWidth < windowSize.width )? ( windowSize.width- targetWidth ) / 2 : 0; |
229 | | - |
230 | | - //mw.log(" targetWidth: " + targetWidth + ' windowSize.width: ' + windowSize.width + ' :: ' + ( windowSize.width- targetWidth ) / 2 ); |
| 229 | + |
| 230 | + //mw.log(" targetWidth: " + targetWidth + ' windowSize.width: ' + windowSize.width + ' :: ' + ( windowSize.width- targetWidth ) / 2 ); |
231 | 231 | return { |
232 | 232 | 'height': targetHeight, |
233 | 233 | 'width' : targetWidth, |
— | — | @@ -345,37 +345,37 @@ |
346 | 346 | if( $interface.offsetParent().get(0).tagName.toLowerCase() != 'body' ) { |
347 | 347 | topOffset = -this.windowOffset.top + 'px'; |
348 | 348 | leftOffset = -this.windowOffset.left + 'px'; |
349 | | - } |
350 | | - |
| 349 | + } |
351 | 350 | |
352 | | - // Set the player height width: |
| 351 | + |
| 352 | + // Set the player height width: |
353 | 353 | $j( embedPlayer ).css( { |
354 | 354 | 'position' : 'relative' |
355 | 355 | } ); |
356 | | - |
357 | | - // Overflow hidden in fullscreen: |
| 356 | + |
| 357 | + // Overflow hidden in fullscreen: |
358 | 358 | $interface.css('overlow', 'hidden'); |
359 | | - |
360 | | - // Resize the player keeping aspect and with the widow scroll offset: |
361 | | - _this.resizePlayer({ |
| 359 | + |
| 360 | + // Resize the player keeping aspect and with the widow scroll offset: |
| 361 | + _this.resizePlayer({ |
362 | 362 | 'top' : topOffset, |
363 | 363 | 'left' : leftOffset, |
364 | 364 | 'width' : $j( window ).width(), |
365 | | - 'height' : $j( window ).height() |
| 365 | + 'height' : $j( window ).height() |
366 | 366 | }, true); |
367 | | - |
| 367 | + |
368 | 368 | // Remove absolute css of the interface parents |
369 | 369 | $interface.parents().each( function() { |
370 | | - //mw.log(' parent : ' + $j( this ).attr('id' ) + ' class: ' + $j( this ).attr('class') + ' pos: ' + $j( this ).css( 'position' ) ); |
371 | | - if( $j( this ).css( 'position' ) == 'absolute' ) { |
372 | | - _this.parentsAbsolute.push( $j( this ) ); |
| 370 | + //mw.log(' parent : ' + $j( this ).attr('id' ) + ' class: ' + $j( this ).attr('class') + ' pos: ' + $j( this ).css( 'position' ) ); |
| 371 | + if( $j( this ).css( 'position' ) == 'absolute' ) { |
| 372 | + _this.parentsAbsolute.push( $j( this ) ); |
373 | 373 | $j( this ).css( 'position', null ); |
374 | | - mw.log(' should update position: ' + $j( this ).css( 'position' ) ); |
| 374 | + mw.log(' should update position: ' + $j( this ).css( 'position' ) ); |
375 | 375 | } |
376 | 376 | } ); |
377 | | - |
378 | | - |
379 | 377 | |
| 378 | + |
| 379 | + |
380 | 380 | // Bind mouse move in interface to hide control bar |
381 | 381 | _this.mouseMovedFlag = false; |
382 | 382 | $interface.mousemove( function(e){ |
— | — | @@ -405,8 +405,8 @@ |
406 | 406 | if( _this.fullscreenMode ){ |
407 | 407 | _this.resizePlayer({ |
408 | 408 | 'width' : $j( window ).width(), |
409 | | - 'height' : $j( window ).height() |
410 | | - }) |
| 409 | + 'height' : $j( window ).height() |
| 410 | + }) |
411 | 411 | } |
412 | 412 | }); |
413 | 413 | |
— | — | @@ -423,36 +423,36 @@ |
424 | 424 | * Resize the player to a target size keeping aspect ratio |
425 | 425 | */ |
426 | 426 | resizePlayer: function( size, animate ){ |
427 | | - var _this = this; |
428 | | - // Update interface container: |
429 | | - var interfaceCss = { |
| 427 | + var _this = this; |
| 428 | + // Update interface container: |
| 429 | + var interfaceCss = { |
430 | 430 | 'top' : ( size.top ) ? size.top : '0px', |
431 | 431 | 'left' : ( size.left ) ? size.left : '0px', |
432 | 432 | 'width' : size.width, |
433 | | - 'height' : size.height |
| 433 | + 'height' : size.height |
434 | 434 | }; |
435 | | - // Set up local pointer to interface: |
| 435 | + // Set up local pointer to interface: |
436 | 436 | var embedPlayer = this.embedPlayer; |
437 | 437 | var $interface = embedPlayer.$interface; |
438 | 438 | if( animate ){ |
439 | 439 | $interface.animate( interfaceCss ); |
440 | | - // Update player size |
| 440 | + // Update player size |
441 | 441 | $j( embedPlayer ).animate( _this.getAspectPlayerWindowCss( size ) ); |
442 | 442 | // Update play button pos |
443 | | - $interface.find('.play-btn-large').animate( _this.getFullscreenPlayButtonCss( size ) ); |
444 | | - // Update the timed text size |
| 443 | + $interface.find('.play-btn-large').animate( _this.getFullscreenPlayButtonCss( size ) ); |
| 444 | + // Update the timed text size |
445 | 445 | $interface.find( '.track' ).animate( _this.getInterfaceSizeTextCss( size ) ); |
446 | 446 | } else { |
447 | 447 | $interface.css( interfaceCss ); |
448 | | - // Update player size |
| 448 | + // Update player size |
449 | 449 | $j( embedPlayer ).css( _this.getAspectPlayerWindowCss( size ) ); |
450 | 450 | // Update play button pos |
451 | | - $interface.find('.play-btn-large').css( _this.getFullscreenPlayButtonCss( size ) ); |
452 | | - // Update the timed text size |
| 451 | + $interface.find('.play-btn-large').css( _this.getFullscreenPlayButtonCss( size ) ); |
| 452 | + // Update the timed text size |
453 | 453 | $interface.find( '.track' ).css( _this.getInterfaceSizeTextCss( size ) ); |
454 | | - } |
| 454 | + } |
455 | 455 | }, |
456 | | - |
| 456 | + |
457 | 457 | /** |
458 | 458 | * Restore the window player |
459 | 459 | */ |
— | — | @@ -500,13 +500,13 @@ |
501 | 501 | |
502 | 502 | // Restore the body scroll bar |
503 | 503 | $j('body').css( 'overflow', 'auto' ); |
504 | | - |
505 | | - // Resize the timed text font size per window width |
| 504 | + |
| 505 | + // Resize the timed text font size per window width |
506 | 506 | $interface.find( '.track' ).css( _this.getInterfaceSizeTextCss({ |
507 | 507 | 'width' : embedPlayer.getWidth(), |
508 | 508 | 'height' : interfaceHeight |
509 | 509 | }) ); |
510 | | - |
| 510 | + |
511 | 511 | } ); |
512 | 512 | mw.log( 'restore embedPlayer:: ' + embedPlayer.getWidth() + ' h: ' + embedPlayer.getHeight()); |
513 | 513 | // Restore the player: |
— | — | @@ -715,17 +715,17 @@ |
716 | 716 | return false; |
717 | 717 | } |
718 | 718 | } |
719 | | - |
720 | | - // Chrome's webM support is oky though: |
721 | | - if( /chrome/.test(navigator.userAgent.toLowerCase() ) && |
| 719 | + |
| 720 | + // Chrome's webM support is oky though: |
| 721 | + if( /chrome/.test(navigator.userAgent.toLowerCase() ) && |
722 | 722 | mw.EmbedTypes.players.getMIMETypePlayers( 'video/webm' ).length ){ |
723 | 723 | return false; |
724 | 724 | } |
725 | | - |
726 | | - |
727 | | - // Check for h264 and or flash/flv source and playback support and don't show warning |
728 | | - if( |
729 | | - ( mw.EmbedTypes.players.getMIMETypePlayers( 'video/h264' ).length |
| 725 | + |
| 726 | + |
| 727 | + // Check for h264 and or flash/flv source and playback support and don't show warning |
| 728 | + if( |
| 729 | + ( mw.EmbedTypes.players.getMIMETypePlayers( 'video/h264' ).length |
730 | 730 | && this.embedPlayer.mediaElement.getSources( 'video/h264' ).length ) |
731 | 731 | || |
732 | 732 | ( mw.EmbedTypes.players.getMIMETypePlayers( 'video/x-flv' ).length |
— | — | @@ -1008,7 +1008,7 @@ |
1009 | 1009 | |
1010 | 1010 | this.displayOptionsMenuFlag = false; |
1011 | 1011 | //mw.log(' closeMenuOverlay: ' + this.displayOptionsMenuFlag); |
1012 | | - |
| 1012 | + |
1013 | 1013 | $overlay.fadeOut( "slow", function() { |
1014 | 1014 | $overlay.remove(); |
1015 | 1015 | } ); |
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayerNative.js |
— | — | @@ -1,34 +1,34 @@ |
2 | 2 | /** |
3 | 3 | * Native embed library: |
4 | | -* |
| 4 | +* |
5 | 5 | * Enables embedPlayer support for native html5 browser playback system |
6 | 6 | */ |
7 | 7 | mw.EmbedPlayerNative = { |
8 | 8 | |
9 | 9 | //Instance Name |
10 | 10 | instanceOf: 'Native', |
11 | | - |
12 | | - // Counts the number of times we tried to access the video element |
| 11 | + |
| 12 | + // Counts the number of times we tried to access the video element |
13 | 13 | grab_try_count:0, |
14 | | - |
15 | | - // Flag to only load the video ( not play it ) |
| 14 | + |
| 15 | + // Flag to only load the video ( not play it ) |
16 | 16 | onlyLoadFlag:false, |
17 | | - |
18 | | - //Callback fired once video is "loaded" |
| 17 | + |
| 18 | + //Callback fired once video is "loaded" |
19 | 19 | onLoadedCallback: null, |
20 | | - |
21 | | - // The previous "currentTime" to sniff seek actions |
| 20 | + |
| 21 | + // The previous "currentTime" to sniff seek actions |
22 | 22 | // NOTE the bug where onSeeked does not seem fire consistently may no longer be applicable |
23 | 23 | prevCurrentTime: -1, |
24 | | - |
| 24 | + |
25 | 25 | // Store the progress event ( updated during monitor ) |
26 | 26 | progressEventData: null, |
27 | | - |
28 | | - // If the media loaded event has been fired |
| 27 | + |
| 28 | + // If the media loaded event has been fired |
29 | 29 | mediaLoadedFlag: null, |
30 | | - |
31 | | - |
32 | | - // All the native events per: |
| 30 | + |
| 31 | + |
| 32 | + // All the native events per: |
33 | 33 | // http://www.w3.org/TR/html5/video.html#mediaevents |
34 | 34 | nativeEvents : [ |
35 | 35 | 'loadstart', |
— | — | @@ -65,8 +65,8 @@ |
66 | 66 | 'overlays' : true |
67 | 67 | }, |
68 | 68 | |
69 | | - /** |
70 | | - * Updates the supported features given the "type of player" |
| 69 | + /** |
| 70 | + * Updates the supported features given the "type of player" |
71 | 71 | */ |
72 | 72 | updateFeatureSupport: function(){ |
73 | 73 | // iWhatever devices appear to have a broken |
— | — | @@ -75,39 +75,39 @@ |
76 | 76 | this.supports.overlays = false; |
77 | 77 | } |
78 | 78 | }, |
79 | | - |
| 79 | + |
80 | 80 | /** |
81 | 81 | * Return the embed code |
82 | 82 | */ |
83 | 83 | doEmbedHTML : function () { |
84 | 84 | var _this = this; |
85 | | - |
86 | | - // Reset some play state flags: |
| 85 | + |
| 86 | + // Reset some play state flags: |
87 | 87 | _this.bufferStartFlag = false; |
88 | 88 | _this.bufferEndFlag = false; |
89 | | - |
| 89 | + |
90 | 90 | mw.log( "native play url:" + this.getSrc() + ' startOffset: ' + this.start_ntp + ' end: ' + this.end_ntp ); |
91 | | - |
| 91 | + |
92 | 92 | // Check if using native controls and already the "pid" is already in the DOM |
93 | 93 | if( this.useNativePlayerControls() && $j( '#' + this.pid ).length && |
94 | 94 | typeof $j( '#' + this.pid ).get(0).play != 'undefined' ) { |
95 | 95 | _this.postEmbedJS(); |
96 | 96 | return ; |
97 | 97 | } |
98 | | - |
| 98 | + |
99 | 99 | $j( this ).html( |
100 | 100 | _this.getNativePlayerHtml() |
101 | 101 | ); |
102 | | - |
103 | | - // Directly run postEmbedJS ( if playerElement is not available it will retry ) |
| 102 | + |
| 103 | + // Directly run postEmbedJS ( if playerElement is not available it will retry ) |
104 | 104 | _this.postEmbedJS(); |
105 | 105 | }, |
106 | | - |
| 106 | + |
107 | 107 | /** |
108 | 108 | * Get the native player embed code. |
109 | | - * |
| 109 | + * |
110 | 110 | * @param {object} playerAttribtues Attributes to be override in function call |
111 | | - * @return {object} cssSet css to apply to the player |
| 111 | + * @return {object} cssSet css to apply to the player |
112 | 112 | */ |
113 | 113 | getNativePlayerHtml: function( playerAttribtues, cssSet ){ |
114 | 114 | if( !playerAttribtues) { |
— | — | @@ -116,46 +116,46 @@ |
117 | 117 | // Update required attributes |
118 | 118 | if( !playerAttribtues[ 'id'] ) playerAttribtues['id'] = this.pid; |
119 | 119 | if( !playerAttribtues['src'] ) playerAttribtues['src'] = this.getSrc(); |
120 | | - |
| 120 | + |
121 | 121 | // If autoplay pass along to attribute ( needed for iPad / iPod no js autoplay support |
122 | 122 | if( this.autoplay ) { |
123 | 123 | playerAttribtues['autoplay'] = 'true'; |
124 | 124 | } |
125 | | - |
126 | | - |
| 125 | + |
| 126 | + |
127 | 127 | if( !cssSet ){ |
128 | 128 | cssSet = {}; |
129 | 129 | } |
130 | 130 | // Set default width height to 100% of parent container |
131 | 131 | if( !cssSet['width'] ) cssSet['width'] = '100%'; |
132 | 132 | if( !cssSet['height'] ) cssSet['height'] = '100%'; |
133 | | - |
| 133 | + |
134 | 134 | // Also need to set the loop param directly for iPad / iPod |
135 | 135 | if( this.loop ) { |
136 | 136 | playerAttribtues['loop'] = 'true'; |
137 | 137 | } |
138 | | - |
| 138 | + |
139 | 139 | var tagName = ( this.isAudio() ) ? 'audio' : 'video'; |
140 | | - |
| 140 | + |
141 | 141 | return $j( '<' + tagName + ' />' ) |
142 | | - // Add the special nativeEmbedPlayer to avoid any rewrites of of this video tag. |
| 142 | + // Add the special nativeEmbedPlayer to avoid any rewrites of of this video tag. |
143 | 143 | .addClass( 'nativeEmbedPlayerPid' ) |
144 | 144 | .attr( playerAttribtues ) |
145 | 145 | .css( cssSet ); |
146 | 146 | }, |
147 | | - |
| 147 | + |
148 | 148 | /** |
149 | | - * Post element javascript, binds event listeners and starts monitor |
| 149 | + * Post element javascript, binds event listeners and starts monitor |
150 | 150 | */ |
151 | 151 | postEmbedJS: function() { |
152 | 152 | var _this = this; |
153 | 153 | mw.log( "f:native:postEmbedJS:" ); |
154 | 154 | |
155 | | - // Setup local pointer: |
| 155 | + // Setup local pointer: |
156 | 156 | var vid = this.getPlayerElement(); |
157 | 157 | // Apply media element bindings: |
158 | 158 | this.applyMediaElementBindings(); |
159 | | - |
| 159 | + |
160 | 160 | // Check for load flag |
161 | 161 | if ( this.onlyLoadFlag ) { |
162 | 162 | vid.pause(); |
— | — | @@ -164,14 +164,14 @@ |
165 | 165 | // Issue play request |
166 | 166 | vid.play(); |
167 | 167 | } |
168 | | - |
| 168 | + |
169 | 169 | setTimeout( function() { |
170 | 170 | _this.monitor(); |
171 | 171 | }, 100 ); |
172 | 172 | }, |
173 | | - |
| 173 | + |
174 | 174 | /** |
175 | | - * Apply media element bindings |
| 175 | + * Apply media element bindings |
176 | 176 | */ |
177 | 177 | applyMediaElementBindings: function(){ |
178 | 178 | var _this = this; |
— | — | @@ -181,36 +181,36 @@ |
182 | 182 | return ; |
183 | 183 | } |
184 | 184 | $j.each( _this.nativeEvents, function( inx, eventName ){ |
185 | | - $j( vid ).bind( eventName , function(){ |
| 185 | + $j( vid ).bind( eventName , function(){ |
186 | 186 | if( _this._propagateEvents ){ |
187 | | - var argArray = $j.makeArray( arguments ); |
188 | | - // Check if there is local handler: |
| 187 | + var argArray = $j.makeArray( arguments ); |
| 188 | + // Check if there is local handler: |
189 | 189 | if( _this['on' + eventName ] ){ |
190 | 190 | _this['on' + eventName ].apply( _this, argArray); |
191 | 191 | } else { |
192 | | - // No local handler directly propagate the event to the abstract object: |
| 192 | + // No local handler directly propagate the event to the abstract object: |
193 | 193 | $j( _this ).trigger( eventName, argArray ) |
194 | 194 | } |
195 | 195 | } |
196 | 196 | }) |
197 | 197 | }); |
198 | 198 | }, |
199 | | - |
| 199 | + |
200 | 200 | // basic monitor function to update buffer |
201 | 201 | monitor: function(){ |
202 | 202 | var _this = this; |
203 | 203 | var vid = _this.getPlayerElement(); |
204 | | - |
| 204 | + |
205 | 205 | // Update the bufferedPercent |
206 | 206 | if( vid && vid.buffered && vid.buffered.end && vid.duration ) { |
207 | 207 | this.bufferedPercent = ( vid.buffered.end(0) / vid.duration ); |
208 | 208 | } |
209 | 209 | _this.parent_monitor(); |
210 | 210 | }, |
211 | | - |
212 | | - |
| 211 | + |
| 212 | + |
213 | 213 | /** |
214 | | - * Issue a seeking request. |
| 214 | + * Issue a seeking request. |
215 | 215 | * |
216 | 216 | * @param {Float} percentage |
217 | 217 | */ |
— | — | @@ -219,10 +219,10 @@ |
220 | 220 | this.seeking = true; |
221 | 221 | // Run the seeking hook |
222 | 222 | $j( this.embedPlayer ).trigger( 'onSeek' ); |
223 | | - |
| 223 | + |
224 | 224 | // Run the onSeeking interface update |
225 | 225 | this.controlBuilder.onSeek(); |
226 | | - |
| 226 | + |
227 | 227 | // @@todo check if the clip is loaded here (if so we can do a local seek) |
228 | 228 | if ( this.supportsURLTimeEncoding() ) { |
229 | 229 | // Make sure we could not do a local seek instead: |
— | — | @@ -230,21 +230,21 @@ |
231 | 231 | mw.log( "do local seek " + percentage + ' is already buffered < ' + this.bufferedPercent ); |
232 | 232 | this.doNativeSeek( percentage ); |
233 | 233 | } else { |
234 | | - // We support URLTimeEncoding call parent seek: |
| 234 | + // We support URLTimeEncoding call parent seek: |
235 | 235 | this.parent_doSeek( percentage ); |
236 | 236 | } |
237 | 237 | } else if ( this.playerElement && this.playerElement.duration ) { |
238 | | - // (could also check bufferedPercent > percentage seek (and issue oggz_chop request or not) |
| 238 | + // (could also check bufferedPercent > percentage seek (and issue oggz_chop request or not) |
239 | 239 | this.doNativeSeek( percentage ); |
240 | 240 | } else { |
241 | | - // try to do a play then seek: |
| 241 | + // try to do a play then seek: |
242 | 242 | this.doPlayThenSeek( percentage ) |
243 | 243 | } |
244 | 244 | }, |
245 | | - |
| 245 | + |
246 | 246 | /** |
247 | 247 | * Do a native seek by updating the currentTime |
248 | | - * @param {float} percentage |
| 248 | + * @param {float} percentage |
249 | 249 | * Percent to seek to of full time |
250 | 250 | */ |
251 | 251 | doNativeSeek: function( percentage ) { |
— | — | @@ -257,11 +257,11 @@ |
258 | 258 | _this.monitor(); |
259 | 259 | }) |
260 | 260 | }, |
261 | | - |
| 261 | + |
262 | 262 | /** |
263 | 263 | * Seek in a existing stream |
264 | 264 | * |
265 | | - * @param {Float} percentage |
| 265 | + * @param {Float} percentage |
266 | 266 | * Percentage of the stream to seek to between 0 and 1 |
267 | 267 | */ |
268 | 268 | doPlayThenSeek: function( percentage ) { |
— | — | @@ -275,7 +275,7 @@ |
276 | 276 | if ( _this.playerElement && _this.playerElement.duration ) { |
277 | 277 | _this.doNativeSeek( percentage ); |
278 | 278 | } else { |
279 | | - // Try to get player for 40 seconds: |
| 279 | + // Try to get player for 40 seconds: |
280 | 280 | // (it would be nice if the onmetadata type callbacks where fired consistently) |
281 | 281 | if ( retryCount < 800 ) { |
282 | 282 | setTimeout( readyForSeek, 50 ); |
— | — | @@ -287,11 +287,11 @@ |
288 | 288 | } |
289 | 289 | readyForSeek(); |
290 | 290 | }, |
291 | | - |
| 291 | + |
292 | 292 | /** |
293 | 293 | * Set the current time with a callback |
294 | | - * |
295 | | - * @param {Float} position |
| 294 | + * |
| 295 | + * @param {Float} position |
296 | 296 | * Seconds to set the time to |
297 | 297 | * @param {Function} callback |
298 | 298 | * Function called once time has been set. |
— | — | @@ -304,7 +304,7 @@ |
305 | 305 | if( _this.playerElement.readyState >= 1 ){ |
306 | 306 | if( _this.playerElement.currentTime == time ){ |
307 | 307 | callback(); |
308 | | - return; |
| 308 | + return; |
309 | 309 | } |
310 | 310 | var once = function( event ) { |
311 | 311 | if( callback ){ |
— | — | @@ -324,7 +324,7 @@ |
325 | 325 | } else { |
326 | 326 | if( callbackCount >= 300 ){ |
327 | 327 | mw.log("Error with seek request, media never in ready state"); |
328 | | - return ; |
| 328 | + return ; |
329 | 329 | } |
330 | 330 | setTimeout( function(){ |
331 | 331 | _this.setCurrentTime( time, callback , callbackCount++); |
— | — | @@ -338,8 +338,8 @@ |
339 | 339 | getPlayerElementTime: function() { |
340 | 340 | var _this = this; |
341 | 341 | // Make sure we have .vid obj |
342 | | - this.getPlayerElement(); |
343 | | - |
| 342 | + this.getPlayerElement(); |
| 343 | + |
344 | 344 | if ( !this.playerElement ) { |
345 | 345 | mw.log( 'mwEmbedPlayer::getPlayerElementTime: ' + this.id + ' not in dom ( stop monitor)' ); |
346 | 346 | return false; |
— | — | @@ -347,7 +347,7 @@ |
348 | 348 | // Return the playerElement currentTime |
349 | 349 | return this.playerElement.currentTime; |
350 | 350 | }, |
351 | | - |
| 351 | + |
352 | 352 | /** |
353 | 353 | * Pause the video playback |
354 | 354 | * calls parent_pause to update the interface |
— | — | @@ -361,13 +361,13 @@ |
362 | 362 | } |
363 | 363 | } |
364 | 364 | }, |
365 | | - |
| 365 | + |
366 | 366 | /** |
367 | 367 | * Play back the video stream |
368 | 368 | * calls parent_play to update the interface |
369 | 369 | */ |
370 | 370 | play: function( ) { |
371 | | - |
| 371 | + |
372 | 372 | this.getPlayerElement(); |
373 | 373 | this.parent_play(); // update interface |
374 | 374 | if ( this.playerElement && this.playerElement.play ) { |
— | — | @@ -375,12 +375,12 @@ |
376 | 376 | if( this.playerElement.paused ){ |
377 | 377 | this.playerElement.play(); |
378 | 378 | } |
379 | | - // re-start the monitor: |
| 379 | + // re-start the monitor: |
380 | 380 | this.monitor(); |
381 | 381 | } |
382 | 382 | }, |
383 | 383 | /** |
384 | | - * Stop the player ( end all listeners ) |
| 384 | + * Stop the player ( end all listeners ) |
385 | 385 | */ |
386 | 386 | stop:function(){ |
387 | 387 | if( this.playerElement ){ |
— | — | @@ -388,7 +388,7 @@ |
389 | 389 | } |
390 | 390 | this.parent_stop(); |
391 | 391 | }, |
392 | | - |
| 392 | + |
393 | 393 | /** |
394 | 394 | * Toggle the Mute |
395 | 395 | * calls parent_toggleMute to update the interface |
— | — | @@ -399,7 +399,7 @@ |
400 | 400 | if ( this.playerElement ) |
401 | 401 | this.playerElement.muted = this.muted; |
402 | 402 | }, |
403 | | - |
| 403 | + |
404 | 404 | /** |
405 | 405 | * Update Volume |
406 | 406 | * |
— | — | @@ -414,27 +414,27 @@ |
415 | 415 | this.playerElement.volume = percentage; |
416 | 416 | } |
417 | 417 | }, |
418 | | - |
| 418 | + |
419 | 419 | /** |
420 | 420 | * get Volume |
421 | 421 | * |
422 | | - * @return {Float} |
| 422 | + * @return {Float} |
423 | 423 | * Audio volume between 0 and 1. |
424 | 424 | */ |
425 | | - getPlayerElementVolume: function() { |
| 425 | + getPlayerElementVolume: function() { |
426 | 426 | if ( this.getPlayerElement() ) { |
427 | 427 | return this.playerElement.volume; |
428 | 428 | } |
429 | 429 | }, |
430 | 430 | /** |
431 | 431 | * get the native muted state |
432 | | - */ |
| 432 | + */ |
433 | 433 | getPlayerElementMuted: function(){ |
434 | 434 | if ( this.getPlayerElement() ) { |
435 | 435 | return this.playerElement.muted; |
436 | 436 | } |
437 | 437 | }, |
438 | | - |
| 438 | + |
439 | 439 | /** |
440 | 440 | * Get the native media duration |
441 | 441 | */ |
— | — | @@ -443,7 +443,7 @@ |
444 | 444 | return this.playerElement.duration; |
445 | 445 | } |
446 | 446 | }, |
447 | | - |
| 447 | + |
448 | 448 | /** |
449 | 449 | * load the video stream with a callback fired once the video is "loaded" |
450 | 450 | * |
— | — | @@ -464,80 +464,80 @@ |
465 | 465 | callback(); |
466 | 466 | } |
467 | 467 | }, |
468 | | - |
| 468 | + |
469 | 469 | /** |
470 | | - * Get /update the playerElement value |
471 | | - */ |
| 470 | + * Get /update the playerElement value |
| 471 | + */ |
472 | 472 | getPlayerElement: function () { |
473 | 473 | this.playerElement = $j( '#' + this.pid ).get( 0 ); |
474 | 474 | return this.playerElement; |
475 | 475 | }, |
476 | | - |
| 476 | + |
477 | 477 | /** |
478 | | - * Bindings for the Video Element Events |
| 478 | + * Bindings for the Video Element Events |
479 | 479 | */ |
480 | | - |
| 480 | + |
481 | 481 | /** |
482 | 482 | * Local method for seeking event |
483 | | - * fired when "seeking" |
| 483 | + * fired when "seeking" |
484 | 484 | */ |
485 | 485 | onseeking: function() { |
486 | 486 | mw.log( "native:onSeeking"); |
487 | | - // Trigger the html5 seeking event |
| 487 | + // Trigger the html5 seeking event |
488 | 488 | //( if not already set from interface ) |
489 | 489 | if( !this.seeking ) { |
490 | 490 | this.seeking = true; |
491 | 491 | // Run the seeking hook (somewhat redundant ) |
492 | 492 | $j( this ).trigger( 'onSeek' ); |
493 | | - |
| 493 | + |
494 | 494 | // Run the onSeeking interface update |
495 | 495 | this.controlBuilder.onSeek(); |
496 | | - |
| 496 | + |
497 | 497 | // Trigger the html5 "seeking" trigger |
498 | 498 | mw.log("native:seeking:trigger:: " + this.seeking); |
499 | 499 | $j( this ).trigger( 'seeking' ); |
500 | 500 | } |
501 | 501 | }, |
502 | | - |
| 502 | + |
503 | 503 | /** |
504 | 504 | * Local method for seeked event |
505 | | - * fired when done seeking |
| 505 | + * fired when done seeking |
506 | 506 | */ |
507 | 507 | onseeked: function() { |
508 | 508 | mw.log("native:onSeeked"); |
509 | | - |
| 509 | + |
510 | 510 | mw.log("native:onSeeked:trigger"); |
511 | | - // Trigger the html5 action on the parent |
| 511 | + // Trigger the html5 action on the parent |
512 | 512 | if( this.seeking && this.useNativePlayerControls() ){ |
513 | 513 | this.seeking = false; |
514 | 514 | $j( this ).trigger( 'seeked' ); |
515 | 515 | } |
516 | 516 | this.seeking = false; |
517 | 517 | }, |
518 | | - |
| 518 | + |
519 | 519 | /** |
520 | 520 | * Handle the native paused event |
521 | | - */ |
| 521 | + */ |
522 | 522 | onpause: function(){ |
523 | 523 | mw.log( "EmbedPlayer:native: OnPaused" ); |
524 | 524 | this.parent_pause(); |
525 | 525 | }, |
526 | | - |
| 526 | + |
527 | 527 | /** |
528 | | - * Handle the native play event |
| 528 | + * Handle the native play event |
529 | 529 | */ |
530 | 530 | onplay: function(){ |
531 | 531 | mw.log("EmbedPlayer:native:: OnPlay"); |
532 | 532 | // Update the interface ( if paused ) |
533 | 533 | this.parent_play(); |
534 | 534 | }, |
535 | | - |
| 535 | + |
536 | 536 | /** |
537 | 537 | * Local method for metadata ready |
538 | 538 | * fired when metadata becomes available |
539 | 539 | * |
540 | | - * Used to update the media duration to |
541 | | - * accurately reflect the src duration |
| 540 | + * Used to update the media duration to |
| 541 | + * accurately reflect the src duration |
542 | 542 | */ |
543 | 543 | onloadedmetadata: function() { |
544 | 544 | this.getPlayerElement(); |
— | — | @@ -545,25 +545,25 @@ |
546 | 546 | mw.log( 'f:onloadedmetadata metadata ready Update duration:' + this.playerElement.duration + ' old dur: ' + this.getDuration() ); |
547 | 547 | this.duration = this.playerElement.duration; |
548 | 548 | } |
549 | | - |
| 549 | + |
550 | 550 | //Fire "onLoaded" flags if set |
551 | 551 | if( typeof this.onLoadedCallback == 'function' ) { |
552 | 552 | this.onLoadedCallback(); |
553 | 553 | } |
554 | | - |
| 554 | + |
555 | 555 | // Tigger "media loaded" |
556 | 556 | if( ! this.mediaLoadedFlag ){ |
557 | 557 | $j( this ).trigger( 'mediaLoaded' ); |
558 | 558 | this.mediaLoadedFlag = true; |
559 | 559 | } |
560 | 560 | }, |
561 | | - |
| 561 | + |
562 | 562 | /** |
563 | 563 | * Local method for progress event |
564 | 564 | * fired as the video is downloaded / buffered |
565 | 565 | * |
566 | | - * Used to update the bufferedPercent |
567 | | - * |
| 566 | + * Used to update the bufferedPercent |
| 567 | + * |
568 | 568 | * Note: this way of updating buffer was only supported in firefox 3.x and |
569 | 569 | * not supported in firefox 4.x |
570 | 570 | */ |
— | — | @@ -571,11 +571,11 @@ |
572 | 572 | var e = event.originalEvent; |
573 | 573 | //mw.log("onprogress: e:" + e + ' ' + e.loaded + ' && ' + e.total ); |
574 | 574 | if( e.loaded && e.total ) { |
575 | | - this.bufferedPercent = e.loaded / e.total; |
| 575 | + this.bufferedPercent = e.loaded / e.total; |
576 | 576 | this.progressEventData = e.loaded; |
577 | 577 | } |
578 | 578 | }, |
579 | | - |
| 579 | + |
580 | 580 | /** |
581 | 581 | * Local method for progress event |
582 | 582 | * fired as the video is downloaded / buffered |
— | — | @@ -585,7 +585,7 @@ |
586 | 586 | onended: function() { |
587 | 587 | var _this = this; |
588 | 588 | mw.log( 'EmbedPlayer:native: onended:' + this.playerElement.currentTime + ' real dur:' + this.getDuration() ); |
589 | | - |
| 589 | + |
590 | 590 | this.onClipDone(); |
591 | 591 | } |
592 | 592 | }; |