r73259 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r73258‎ | r73259 | r73260 >
Date:23:36, 17 September 2010
Author:dale
Status:deferred (Comments)
Tags:
Comment:
fixes for usage of library on file:// protocal
Modified paths:
  • /branches/MwEmbedStandAlone/ResourceLoader.php (modified) (history)
  • /branches/MwEmbedStandAlone/includes/noMediaWikiConfig.php (modified) (history)
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/loader.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayerKplayer.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayerNative.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/skins/kskin/mw.PlayerSkinKskin.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/skins/mvpcf/mw.style.PlayerSkinMvpcf.css (modified) (history)
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/skins/mw.PlayerControlBuilder.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/tests/Player_Sources.html (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Playlist/mw.Playlist.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Playlist/tests/Player_MediaRss.html (modified) (history)
  • /branches/MwEmbedStandAlone/modules/TimedText/mw.TimedText.js (modified) (history)
  • /branches/MwEmbedStandAlone/mwEmbed.js (modified) (history)

Diff [purge]

Index: branches/MwEmbedStandAlone/mwEmbed.js
@@ -1,6 +1,6 @@
2 -// Add support for html5 / mwEmbed elements to IE ( comment must come before js code )
3 -// For discussion and comments, see: http://remysharp.com/2009/01/07/html5-enabling-script/
4 -/*@cc_on@if(@_jscript_version<9){'video audio source track'.replace(/\w+/g,function(n){document.createElement(n)})}@end@*/
 2+// Add support for html5 / mwEmbed elements to browsers that do not support the elements natively
 3+// For discussion and comments, see: http://ejohn.org/blog/html5-shiv/
 4+'video audio source track'.replace(/\w+/g, function(n){ document.createElement(n) });
55
66 /**
77 * @license
@@ -1144,22 +1144,31 @@
11451145 }
11461146
11471147 /**
1148 - * Mobile Safari has special properties for html5 video::
 1148+ * Mobile HTML5 has special properties for html5 video::
11491149 *
1150 - * NOTE: should be phased out in favor of browser feature detection script
 1150+ * NOTE: should be phased out in favor of browser feature detection where possible
11511151 */
1152 - mw.isMobileSafari = function() {
 1152+ mw.isMobileHTML5 = function() {
11531153 // check mobile safari foce ( for debug )
1154 - if( mw.getConfig( 'forceMobileSafari' ) || document.URL.indexOf('forceMobileSafari') != -1 ){
 1154+ if( mw.getConfig( 'forceMobileHTML5' ) || document.URL.indexOf('forceMobileHTML5') != -1 ){
11551155 return true;
11561156 }
1157 - if ((navigator.userAgent.indexOf('iPhone') != -1) ||
1158 - (navigator.userAgent.indexOf('iPod') != -1) ||
1159 - (navigator.userAgent.indexOf('iPad') != -1)) {
 1157+ if (( navigator.userAgent.indexOf('iPhone') != -1) ||
 1158+ ( navigator.userAgent.indexOf('iPod') != -1) ||
 1159+ ( navigator.userAgent.indexOf('iPad') != -1) ||
 1160+ ( mw.isAndroid2() )
 1161+ ) {
11601162 return true;
11611163 }
11621164 return false;
1163 - }
 1165+ };
 1166+ // Android 2 has some restrictions vs other mobile platforms
 1167+ mw.isAndroid2 = function(){
 1168+ if ( navigator.userAgent.indexOf('Android 2.') != -1) {
 1169+ return true;
 1170+ }
 1171+ return false;
 1172+ };
11641173
11651174 /**
11661175 * Similar to php isset function checks if the variable exists. Does a safe
@@ -1185,7 +1194,7 @@
11861195 }
11871196 }
11881197 return true;
1189 - }
 1198+ };
11901199
11911200 /**
11921201 * Wait for a object to be defined and the call the callback
@@ -1268,10 +1277,11 @@
12691278
12701279 if ( window.console ) {
12711280 window.console.log( string );
1272 - } else {
 1281+ } else {
12731282 /**
12741283 * Old IE and non-Firebug debug: ( commented out for now )
1275 - */
 1284+ */
 1285+
12761286 /*var log_elm = document.getElementById('mv_js_log');
12771287 if(!log_elm) {
12781288 document.getElementsByTagName("body")[0].innerHTML += '<div ' +
@@ -1282,7 +1292,9 @@
12831293 var log_elm = document.getElementById('mv_js_log');
12841294 if(log_elm) {
12851295 log_elm.value+=string+"\n";
1286 - }*/
 1296+ // scroll to bottom:
 1297+ log_elm.scrollTop = log_elm.scrollHeight;
 1298+ }*/
12871299 }
12881300 }
12891301
@@ -1390,6 +1402,7 @@
13911403 if( mw.isset( 'window.jQuery' )
13921404 && mw.getConfig( 'debug' ) === false
13931405 && typeof $j != 'undefined'
 1406+ && mw.parseUri( url ).protocal != 'file'
13941407 && !isCssFile )
13951408 {
13961409 $j.getScript( url, myCallback);
@@ -1507,18 +1520,13 @@
15081521 }
15091522 };
15101523
1511 -
1512 - // Local mwEmbedPath variable ( for cache of mw.getMwEmbedPath )
1513 - var mwEmbedPath = null;
1514 -
 1524+ mw.getRelativeMwEmbedPath = function(){
 1525+ return mw.getMwEmbedPath(true);
 1526+ };
15151527 /**
15161528 * Get the path to the mwEmbed folder
15171529 */
1518 - mw.getMwEmbedPath = function() {
1519 - if ( mwEmbedPath ) {
1520 - return mwEmbedPath;
1521 - }
1522 -
 1530+ mw.getMwEmbedPath = function( relativePath ) {
15231531 // Get mwEmbed src:
15241532 var src = mw.getMwEmbedSrc();
15251533 var mwpath = null;
@@ -1539,7 +1547,7 @@
15401548 if( src.indexOf( 'ResourceLoader.php' ) !== -1 ) {
15411549 mwpath = src.substr( 0, src.indexOf( 'ResourceLoader.php' ) );
15421550 }
1543 -
 1551+
15441552 // For static packages mwEmbed packages start with: "mwEmbed-"
15451553 if( src.indexOf( 'mwEmbed-' ) !== -1 && src.indexOf( '-static' ) !== -1 ) {
15461554 mwpath = src.substr( 0, src.indexOf( 'mwEmbed-' ) );
@@ -1552,8 +1560,10 @@
15531561 }
15541562
15551563 // Update the cached var with the absolute path:
1556 - mwEmbedPath = mw.absoluteUrl( mwpath ) ;
1557 - return mwEmbedPath;
 1564+ if( !relativePath ){
 1565+ mwpath = mw.absoluteUrl( mwpath ) ;
 1566+ }
 1567+ return mwpath;
15581568 }
15591569
15601570 /**
@@ -1823,28 +1833,36 @@
18241834 * from a relative path
18251835 * @return {String} absolute url
18261836 */
1827 - mw.absoluteUrl = function( src, contextUrl ) {
 1837+mw.absoluteUrl = function( src, contextUrl ) {
18281838
18291839 var parsedSrc = mw.parseUri( src );
 1840+
18301841 // Source is already absolute return:
18311842 if( parsedSrc.protocol != '') {
18321843 return src;
18331844 }
18341845
18351846 // Get parent Url location the context URL
1836 - if( contextUrl ) {
1837 - var parsedUrl = mw.parseUri( contextUrl );
1838 - } else {
1839 - var parsedUrl = mw.parseUri( document.URL );
 1847+ if( !contextUrl ) {
 1848+ contextUrl = document.URL;
 1849+ }
 1850+ var parsedUrl = mw.parseUri( contextUrl );
 1851+
 1852+ // Check for IE local file that does not flip the slashes
 1853+ if( parsedUrl.directory == '' && parsedUrl.protocol == 'file' ){
 1854+ // pop off the file
 1855+ var fileUrl = contextUrl.split( '\\');
 1856+ fileUrl.pop();
 1857+ return fileUrl.join('\\') + '\\' + src;
18401858 }
1841 -
 1859+
18421860 // Check for leading slash:
18431861 if( src.indexOf( '/' ) === 0 ) {
18441862 return parsedUrl.protocol + '://' + parsedUrl.authority + src;
1845 - }else{
 1863+ }else{
18461864 return parsedUrl.protocol + '://' + parsedUrl.authority + parsedUrl.directory + src;
18471865 }
1848 - };
 1866+ };
18491867 /**
18501868 * Check if a given source string is likely a url
18511869 *
@@ -2164,11 +2182,18 @@
21652183 } );
21662184 }
21672185 function addLocalSettings(){
2168 - mw.log("Load loacal settings")
2169 - mw.load( 'localSettings.js', function(){
 2186+ var continueCallback = function(){
21702187 // Set the mwModuleLoaderCheckFlag flag to true
21712188 mwModuleLoaderCheckFlag = true;
21722189 callback();
 2190+ }
 2191+ if( mw.getConfig( 'LoadLocalSettings') != true ){
 2192+ continueCallback();
 2193+ return;
 2194+ }
 2195+ mw.log("Load loacal settings")
 2196+ mw.load( 'localSettings.js', function(){
 2197+ continueCallback();
21732198 })
21742199 }
21752200
Index: branches/MwEmbedStandAlone/ResourceLoader.php
@@ -160,14 +160,12 @@
161161 wfRestoreWarnings();
162162 }
163163
164 - // Add the required core mwEmbed style sheets removed for now
165 - // because when creating stand alone packages js package with css
 164+ // Add the required core mwEmbed style sheets
 165+ // removed for now because when creating stand alone packages js package with css
166166 // the paths get messed up.
167 - /*
168 - if( !isset( $this->namedFileList[ 'mw.style.mwCommon' ] ) ) {
 167+ /*if( !isset( $this->namedFileList[ 'mw.style.mwCommon' ] ) ) {
169168 $this->output .= $this->getResourceText( 'mw.style.mwCommon' );
170 - }
171 - */
 169+ }*/
172170
173171 // Output "special" IE comment tag to support "special" mwEmbed tags.
174172 $this->notMinifiedTopOutput .='/*@cc_on@if(@_jscript_version<9){\'video audio source itext playlist\'.replace(/\w+/g,function(n){document.createElement(n)})}@end@*/'."\n";
Index: branches/MwEmbedStandAlone/includes/noMediaWikiConfig.php
@@ -151,6 +151,9 @@
152152 if( $wgLoadedMsgKeysFlag ) {
153153 return true;
154154 }
 155+ if( !$wgMessageCache ){
 156+ $wgMessageCache = array();
 157+ }
155158 foreach( $wgExtensionMessagesFiles as $msgFile ){
156159 if( !is_file( $msgFile ) ) {
157160 throw new MWException( "Missing msgFile: " . htmlspecialchars( $msgFile ) . "\n" );
Index: branches/MwEmbedStandAlone/modules/Playlist/tests/Player_MediaRss.html
@@ -14,8 +14,8 @@
1515
1616 <script type="text/javascript">
1717 // For testing safari in chrome /
18 - if( document.URL.indexOf('forceMobileSafari') != -1 ){
19 - mw.setConfig( 'forceMobileSafari' , true );
 18+ if( document.URL.indexOf('forceMobileHTML5') != -1 ){
 19+ mw.setConfig( 'forceMobileHTML5' , true );
2020 }
2121
2222 mw.ready( function(){
Index: branches/MwEmbedStandAlone/modules/Playlist/mw.Playlist.js
@@ -257,7 +257,7 @@
258258 $videoList.show()
259259 // show the video list and apply the swipe binding
260260 $j( _this.target ).find('.media-rss-video-list-wrapper').fadeIn();
261 - if( mw.isMobileSafari() ){
 261+ if( mw.isMobileHTML5() ){
262262 // iScroll is buggy with current version of iPad / iPhone use scroll buttons instead
263263 /*
264264 document.addEventListener('touchmove', function(e){ e.preventDefault(); });
@@ -434,7 +434,7 @@
435435 // ( mobile safari can't javascript start the video )
436436 // see: http://developer.apple.com/iphone/search/search.php?simp=1&num=10&Search=html5+autoplay
437437 var addVideoPlayerToDom = true;
438 - if( mw.isMobileSafari() ){
 438+ if( mw.isMobileHTML5() ){
439439 // Check for a current video:
440440 var $inDomVideo = $j( _this.target + ' .media-rss-video-player video' );
441441 if( $inDomVideo.length == 0 ){
Index: branches/MwEmbedStandAlone/modules/TimedText/mw.TimedText.js
@@ -11,36 +11,7 @@
1212 *
1313 */
1414
15 -mw.addMessages( {
16 - "mwe-timedtext-back-btn" : "Back",
17 - "mwe-timedtext-choose-text" : "Chose text",
18 - "mwe-timedtext-add-timed-text" : "Add timed text",
19 - "mwe-timedtext-loading-text-edit" : "Loading timed text editor",
20 -
21 - "mwe-timedtext-search" : "Search clip",
22 -
23 - "mwe-timedtext-layout" : "Layout",
24 - "mwe-timedtext-layout-ontop" : "Ontop of video",
25 - "mwe-timedtext-layout-below": "Below video",
26 - "mwe-timedtext-layout-off" : "Hide subtitles",
27 -
28 - "mwe-timedtext-loading-text" : "Loading text ...",
29 -
30 - "mwe-timedtext-key-language": "$1, $2",
31 -
32 - "mwe-timedtext-textcat-cc" : "Captions",
33 - "mwe-timedtext-textcat-sub" : "Subtitles",
34 - "mwe-timedtext-textcat-tad" : "Audio description",
35 - "mwe-timedtext-textcat-ktv" : "Karaoke",
36 - "mwe-timedtext-textcat-tik" : "Ticker text",
37 - "mwe-timedtext-textcat-ar" : "Active regions",
38 - "mwe-timedtext-textcat-nb" : "Annotation",
39 - "mwe-timedtext-textcat-meta" : "Timed metadata",
40 - "mwe-timedtext-textcat-trx" : "Transcript",
41 - "mwe-timedtext-textcat-lrc" : "Lyrics",
42 - "mwe-timedtext-textcat-lin" : "Linguistic markup",
43 - "mwe-timedtext-textcat-cue" : "Cue points"
44 -} );
 15+mw.includeAllModuleMessages();
4516
4617 // Bind to mw ( for uncluttered global namespace )
4718 ( function( $ ) {
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/loader.js
@@ -166,15 +166,17 @@
167167
168168 // Set up the embed video player class request: (include the skin js as well)
169169 var dependencyRequest = [
 170+ [
 171+ 'mw.EmbedPlayer'
 172+ ],
170173 [
171 - '$j.ui',
172 - 'mw.EmbedPlayer',
173 - 'mw.PlayerControlBuilder',
 174+ 'mw.PlayerControlBuilder',
174175 '$j.fn.hoverIntent',
175176 'mw.style.EmbedPlayer',
176177 '$j.cookie',
177178 // Add JSON lib if browsers does not define "JSON" natively
178179 'JSON',
 180+ '$j.ui',
179181 '$j.widget'
180182 ],
181183 [
@@ -189,7 +191,7 @@
190192 // Pass every tag being rewritten through the update request function
191193 $j( mw.getConfig( 'EmbedPlayer.RewriteTags' ) ).each( function() {
192194 var playerElement = this;
193 - mw.embedPlayerUpdateLibraryRequest( playerElement, dependencyRequest[ 0 ] )
 195+ mw.embedPlayerUpdateLibraryRequest( playerElement, dependencyRequest[ 1 ] )
194196 } );
195197
196198 // Add PNG fix code needed:
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/tests/Player_Sources.html
@@ -17,4 +17,4 @@
1818
1919
2020 </body>
21 -</html>
\ No newline at end of file
 21+</html>
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js
@@ -11,68 +11,7 @@
1212 * Add the messages text:
1313 */
1414
15 -mw.addMessages( {
16 - "mwe-embedplayer-loading_plugin" : "Loading plugin ...",
17 - "mwe-embedplayer-select_playback" : "Set playback preference",
18 - "mwe-embedplayer-link_back" : "Link back",
19 - "mwe-embedplayer-error_swap_vid" : "Error: mwEmbed was unable to swap the video tag for the mwEmbed interface",
20 - "mwe-embedplayer-add_to_end_of_sequence" : "Add to end of sequence",
21 - "mwe-embedplayer-missing_video_stream" : "The video file for this stream is missing",
22 - "mwe-embedplayer-play_clip" : "Play clip",
23 - "mwe-embedplayer-pause_clip" : "Pause clip",
24 - "mwe-embedplayer-volume_control" : "Volume control",
25 - "mwe-embedplayer-player_options" : "Player options",
26 - "mwe-embedplayer-timed_text" : "Timed text",
27 - "mwe-embedplayer-player_fullscreen" : "Fullscreen",
28 - "mwe-embedplayer-next_clip_msg" : "Play next clip",
29 - "mwe-embedplayer-prev_clip_msg" : "Play previous clip",
30 - "mwe-embedplayer-current_clip_msg" : "Continue playing this clip",
31 - "mwe-embedplayer-seek_to" : "Seek $1",
32 - "mwe-embedplayer-paused" : "paused",
33 - "mwe-embedplayer-download_segment" : "Download selection:",
34 - "mwe-embedplayer-download_full" : "Download full video file:",
35 - "mwe-embedplayer-download_right_click" : "To download, right click and select <i>Save link as...<\/i>",
36 - "mwe-embedplayer-download_clip" : "Download video",
37 - "mwe-embedplayer-download_text" : "Download timed text",
38 - "mwe-embedplayer-download" : "Download",
39 - "mwe-embedplayer-share" : "Share",
40 - "mwe-embedplayer-about-library" : "About kaltura player",
41 - "mwe-embedplayer-about-library-desc" : "Kaltura's HTML5 Media Library enables you to take advantage of the html5 &lt;video&gt; and &lt;audio&gt; tags today with a consistent player interface across all major browsers. <br> <br> [$1 More about the kaltura player library]",
42 - "mwe-embedplayer-credits" : "Credits",
43 - "mwe-embedplayer-clip_linkback" : "Clip source page",
44 - "mwe-embedplayer-choose_player" : "Choose video player",
45 - "mwe-embedplayer-no-player" : "No player available for $1",
46 - "mwe-embedplayer-share_this_video" : "Share this video",
47 - "mwe-embedplayer-video_credits" : "Video credits",
48 - "mwe-embedplayer-kaltura-platform-title" : "Kaltura open source video platform",
49 - "mwe-embedplayer-menu_btn" : "Menu",
50 - "mwe-embedplayer-close_btn" : "Close",
51 - "mwe-embedplayer-ogg-player-vlc-player" : "VLC player",
52 - "mwe-embedplayer-ogg-player-oggNative" : "HTML5 Ogg player",
53 - "mwe-embedplayer-ogg-player-h264Native" : "HTML5 H.264 player",
54 - "mwe-embedplayer-ogg-player-oggPlugin" : "Generic Ogg plugin",
55 - "mwe-embedplayer-ogg-player-quicktime-mozilla" : "QuickTime plugin",
56 - "mwe-embedplayer-ogg-player-quicktime-activex" : "QuickTime ActiveX",
57 - "mwe-embedplayer-ogg-player-cortado" : "Java Cortado",
58 - "mwe-embedplayer-ogg-player-flowplayer" : "Flowplayer",
59 - "mwe-embedplayer-ogg-player-kplayer" : "Kaltura player",
60 - "mwe-embedplayer-ogg-player-selected" : "(selected)",
61 - "mwe-embedplayer-generic_missing_plugin" : "You browser does not appear to support the following playback type: <b>$1<\/b><br \/>Visit the <a href=\"http:\/\/commons.wikimedia.org\/wiki\/Commons:Media_help\">Playback methods<\/a> page to download a player.<br \/>",
62 - "mwe-embedplayer-missing-source" : "No source video was found",
63 - "mwe-embedplayer-for_best_experience" : "For a better video playback experience we recommend the <b><a href=\"http:\/\/www.mozilla.com\/en-US\/firefox\/upgrade.html?from=mwEmbed\">latest Firefox<\/a>.<\/b>",
64 - "mwe-embedplayer-do_not_warn_again" : "Dismiss for now.",
65 - "mwe-embedplayer-playerSelect" : "Players",
66 - "mwe-embedplayer-read_before_embed" : "<a href=\"http:\/\/mediawiki.org\/wiki\/Security_Notes_on_Remote_Embedding\" target=\"_new\">Read this<\/a> before embedding.",
67 - "mwe-embedplayer-embed_site_or_blog" : "Embed on a page",
68 - "mwe-embedplayer-related_videos" : "Related videos",
69 - "mwe-embedplayer-seeking" : "seeking",
70 - "mwe-embedplayer-buffering" : "buffering",
71 - "mwe-embedplayer-copy-code" : "Copy code",
72 - "mwe-embedplayer-video-h264" : "H.264 video",
73 - "mwe-embedplayer-video-flv" : "Flash video",
74 - "mwe-embedplayer-video-ogg" : "Ogg video",
75 - "mwe-embedplayer-video-audio" : "Ogg audio"
76 -} );
 15+mw.includeAllModuleMessages();
7716
7817 /*
7918 * The default video attributes supported by embedPlayer
@@ -335,7 +274,8 @@
336275 }
337276 var addedToPlayerManager = false;
338277 // Make sure we have user preference setup ( for setting preferences on video selection )
339 - mw.setupUserConfig( function() {
 278+ mw.setupUserConfig( function() {
 279+ mw.log("EmbedPlayer:: found: " + $j( playerSelect ).length + ' players ');
340280 // Add each selected element to the player manager:
341281 $j( playerSelect ).each( function( index, playerElement) {
342282 // Make sure the video tag was not generated by our library:
@@ -1153,7 +1093,7 @@
11541094 /**
11551095 * Selects the default source via cookie preference, default marked, or by id order
11561096 */
1157 - autoSelectSource: function() {
 1097+ autoSelectSource: function() {
11581098 mw.log( 'EmbedPlayer::mediaElement::autoSelectSource:' + this.id);
11591099 // Select the default source
11601100 var playableSources = this.getPlayableSources();
@@ -1163,7 +1103,7 @@
11641104 for ( var source = 0; source < playableSources.length; source++ ) {
11651105 var mimeType = playableSources[source].mimeType;
11661106 if ( mw.EmbedTypes.players.preference[ 'format_preference' ] == mimeType ) {
1167 - mw.log( 'set via preference: ' + playableSources[source].mimeType );
 1107+ mw.log( 'Set via preference: ' + playableSources[source].mimeType );
11681108 this.selectedSource = playableSources[source];
11691109 return true;
11701110 }
@@ -1172,17 +1112,18 @@
11731113 // Set via marked default:
11741114 for ( var source = 0; source < playableSources.length; source++ ) {
11751115 if ( playableSources[ source ].markedDefault ) {
1176 - mw.log( 'set via marked default: ' + playableSources[source].markedDefault );
 1116+ mw.log( 'Set via marked default: ' + playableSources[source].markedDefault );
11771117 this.selectedSource = playableSources[source];
11781118 return true;
11791119 }
11801120 }
11811121
1182 - // Set native client for flash
 1122+ // Prefer native playback
11831123 for ( var source = 0; source < playableSources.length; source++ ) {
11841124 var mimeType = playableSources[source].mimeType;
11851125 var player = mw.EmbedTypes.players.defaultPlayer( mimeType );
1186 - if ( this.isOgg( mimeType ) && player && player.library == 'Native' ) {
 1126+ if ( player && player.library == 'Native' ) {
 1127+ mw.log('Set native playback');
11871128 this.selectedSource = playableSources[ source ];
11881129 return true;
11891130 }
@@ -1199,7 +1140,8 @@
12001141 ||
12011142 player.library == 'Kplayer'
12021143 )
1203 - ) {
 1144+ ) {
 1145+ mw.log('Set h264 via native or flash fallback');
12041146 this.selectedSource = playableSources[ source ];
12051147 return true;
12061148 }
@@ -2396,7 +2338,7 @@
23972339 * @returns boolean true if the mwEmbed player interface should be used
23982340 * false if the mwEmbed player interface should not be used
23992341 */
2400 - shouldUseNativeControls: function() {
 2342+ shouldUseNativeControls: function() {
24012343 if( this.usenativecontrols === true ){
24022344 return true;
24032345 }
@@ -2405,7 +2347,7 @@
24062348 return true;
24072349 }
24082350 if( mw.getConfig('EmbedPlayer.NativeControlsMobileSafari' ) &&
2409 - mw.isMobileSafari()
 2351+ mw.isMobileHTML5()
24102352 ){
24112353 return true;
24122354 }
@@ -2430,9 +2372,9 @@
24312373
24322374
24332375 // Check if we need to refresh mobile safari
2434 - var mobileSafairNeedsRefresh = false;
 2376+ var mobileSafariNeedsRefresh = false;
24352377
2436 - // Unhide the original video element
 2378+ // Unhide the original video element if not part of a playerThemer embed
24372379 if( !$j( '#' + this.pid ).hasClass('PlayerThemer') ){
24382380 $j( '#' + this.pid )
24392381 .css( {
@@ -2441,12 +2383,12 @@
24422384 .show()
24432385 .attr('controls', 'true');
24442386
2445 - mobileSafairNeedsRefresh = true;
 2387+ mobileSafariNeedsRefresh = true;
24462388 }
24472389
24482390 // iPad does not handle video tag update for attributes like "controls"
24492391 // so we have to do a full replace ( if controls are not included initially )
2450 - if( mw.isMobileSafari() && mobileSafairNeedsRefresh ) {
 2392+ if( mw.isMobileHTML5() && mobileSafariNeedsRefresh ) {
24512393 var source = this.mediaElement.getSources( 'video/h264' )[0];
24522394 if( source && ! source.src ){
24532395 mw.log( 'Error: should have caught no playable sources for mobile safari earlier' );
@@ -2465,20 +2407,43 @@
24662408 var cssStyle = {
24672409 'width' : _this.width,
24682410 'height' : _this.height
2469 - };
 2411+ };
24702412 $j( '#' + this.pid ).replaceWith(
24712413 _this.getNativePlayerHtml( videoAttribues, cssStyle )
24722414 )
24732415 // Bind native events:
24742416 this.applyMediaElementBindings();
24752417 }
 2418+ // Android only can play with a special play button ( no native controls in the dom , and no auto-play )
 2419+ // and only with 'native display'
 2420+ if( mw.isAndroid2() ){
 2421+ $j( '#' + _this.pid ).siblings('.play-btn-large').remove();
 2422+ $j( '#' + _this.pid ).after(
 2423+ $j('<div />')
 2424+ .css({
 2425+ 'position' : 'relative',
 2426+ 'top' : -1 * ( .5 * _this.getPlayerHeight() ) - 52,
 2427+ 'left' : ( .5 * _this.getPlayerWidth() ) - 75
 2428+ })
 2429+ .attr( {
 2430+ 'title' : gM( 'mwe-embedplayer-play_clip' ),
 2431+ 'class' : "ui-state-default play-btn-large"
 2432+ } )
 2433+ .click( function() {
 2434+ _this.play();
 2435+ // no need to hide the play button since android plays fullscreen
 2436+ } )
 2437+ )
 2438+ }
24762439 return ;
24772440 },
24782441 /**
24792442 * Should be set via native embed support
24802443 */
24812444 getNativePlayerHtml: function(){
2482 - return $j('<div />' ).html( 'Error: Trying to get native html5 player without native support for codec' );
 2445+ return $j('<div />' )
 2446+ .css( 'width', this.getWidth() )
 2447+ .html( 'Error: Trying to get native html5 player without native support for codec' );
24832448 },
24842449 /**
24852450 * Should be set via native embed support
@@ -3467,7 +3432,7 @@
34683433 * @param {String} mimeType Mime type for the associated player stream
34693434 */
34703435 setPlayerPreference : function( playerId, mimeType ) {
3471 - var selectedPlayer = null;
 3436+ var selectedPlayer = null;
34723437 for ( var i = 0; i < this.players.length; i++ ) {
34733438 if ( this.players[i].id == playerId ) {
34743439 selectedPlayer = this.players[i];
@@ -3597,12 +3562,16 @@
35983563 }
35993564
36003565 // Test for h264:
3601 - if ( dummyvid.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"' ) ) {
 3566+ if ( dummyvid.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"' ) ) {
36023567 this.players.addPlayer( h264NativePlayer );
36033568 }
 3569+ // For now if Android assume we support h264Native (FIXME test on real devices )
 3570+ if ( mw.isAndroid2() ){
 3571+ this.players.addPlayer( h264NativePlayer );
 3572+ }
36043573
36053574 // Test for ogg
3606 - if ( dummyvid.canPlayType( "video/ogg;codecs=\"theora,vorbis\"" ) ) {
 3575+ if ( dummyvid.canPlayType( 'video/ogg; codecs="theora,vorbis"' ) ) {
36073576 this.players.addPlayer( oggNativePlayer );
36083577 // older versions of safari do not support canPlayType,
36093578 // but xiph qt registers mimetype via quicktime plugin
@@ -3613,7 +3582,7 @@
36143583 } catch ( e ) {
36153584 mw.log( 'could not run canPlayType ' + e );
36163585 }
3617 - }
 3586+ }
36183587
36193588 // "navigator" plugins
36203589 if ( navigator.mimeTypes && navigator.mimeTypes.length > 0 ) {
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/skins/kskin/mw.PlayerSkinKskin.js
@@ -2,10 +2,6 @@
33 * Skin js allows you to override contrlBuilder html/class output
44 */
55
6 -mw.addMessages( {
7 - "mwe-embedplayer-credit-title" : "Title: $1"
8 -} );
9 -
106 mw.PlayerSkinKskin = {
117
128 // The parent class for all kskin css:
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/skins/mw.PlayerControlBuilder.js
@@ -984,10 +984,10 @@
985985 *
986986 * @param {String} overlayContent content to be displayed
987987 */
988 - displayOverlay: function( overlayContent ) {
 988+ displayMenuOverlay: function( overlayContent ) {
989989 var _this = this;
990990 var embedPlayer = this.embedPlayer;
991 - mw.log( 'displayOverlay::' );
 991+ mw.log( 'displayMenuOverlay::' );
992992 // set the overlay display flag to true:
993993 this.displayOptionsMenuFlag = true;
994994 mw.log(" set displayOptionsMenuFlag:: " + this.displayOptionsMenuFlag);
@@ -1069,11 +1069,9 @@
10701070 $overlayShadow
10711071 )
10721072 .find( '.overlay-win' )
1073 - .fadeIn( "slow" );
 1073+ .fadeIn( "slow" );
10741074
1075 -
1076 - // trigger menu overlay display
1077 - alert('triger displayMenuOverlay');
 1075+ // trigger menu overlay display
10781076 $j(embedPlayer).trigger( 'displayMenuOverlay' );
10791077
10801078 return false; // onclick action return false
@@ -1223,8 +1221,8 @@
12241222 .click( function() {
12251223 var iparts = $j( this ).attr( 'id' ).replace(/sc_/ , '' ).split( '_' );
12261224 var sourceId = iparts[0];
1227 - var default_player_id = iparts[1];
1228 - mw.log( 'source id: ' + sourceId + ' player id: ' + default_player_id );
 1225+ var player_id = iparts[1];
 1226+ mw.log( 'source id: ' + sourceId + ' player id: ' + player_id );
12291227
12301228 embedPlayer.controlBuilder.closeMenuOverlay();
12311229
@@ -1234,10 +1232,11 @@
12351233 }
12361234
12371235 embedPlayer.mediaElement.selectSource( sourceId );
1238 -
 1236+ var playableSources = embedPlayer.mediaElement.getPlayableSources();
 1237+
12391238 mw.EmbedTypes.players.setPlayerPreference(
1240 - default_player_id,
1241 - embedPlayer.mediaElement.sources[ sourceId ].getMIMEType()
 1239+ player_id,
 1240+ playableSources[ sourceId ].getMIMEType()
12421241 );
12431242
12441243 // Issue a stop
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/skins/mvpcf/mw.style.PlayerSkinMvpcf.css
@@ -49,11 +49,6 @@
5050 position:relative;
5151 }
5252
53 -.controls a{
54 - display: block;
55 - height: 100%;
56 - width: 100%;
57 -}
5853 .mv-player .volume_icon {
5954 float: right;
6055 display: inline;
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayerNative.js
@@ -46,7 +46,7 @@
4747 updateFeatureSupport: function(){
4848 // iWhatever devices appear to have a broken
4949 // dom overlay implementation of video atm. (hopefully iphone OS 4 fixes this )
50 - if( mw.isMobileSafari() ) {
 50+ if( mw.isMobileHTML5() ) {
5151 this.supports.overlays = false;
5252 }
5353 },
@@ -173,12 +173,12 @@
174174 // Bind events to local js methods:
175175 vid.addEventListener( 'canplaythrogh', function() { $j( _this ).trigger('canplaythrough'); }, true);
176176 vid.addEventListener( 'loadedmetadata', function() { _this.onloadedmetadata() }, true);
177 - vid.addEventListener( 'progress', function( e ) { _this.onprogress( e ); }, true);
 177+ vid.addEventListener( 'progress', function( e ) { if( _this.onprogress ) { _this.onprogress( e ); } }, true);
178178 vid.addEventListener( 'ended', function() { _this.onended() }, true);
179179 vid.addEventListener( 'seeking', function() { _this.onSeeking() }, true);
180180 vid.addEventListener( 'seeked', function() { _this.onSeeked() }, true);
181181
182 - vid.addEventListener( 'pause', function() { _this.onPaused() }, true );
 182+ vid.addEventListener( 'pause', function() { if( _this.onPaused ) { _this.onPaused() } }, true );
183183 vid.addEventListener( 'play', function(){ _this.onPlay() }, true );
184184 vid.addEventListener( 'volumechange', function(){ _this.onVolumeChange() } , true );
185185 },
@@ -364,6 +364,15 @@
365365 this.monitor();
366366 }
367367 },
 368+ /**
 369+ * Stop the player ( end all listeners )
 370+ */
 371+ stop:function(){
 372+ if( this.playerElement ){
 373+ $j( this.playerElement ).unbind();
 374+ }
 375+ this.parent_stop();
 376+ },
368377
369378 /**
370379 * Toggle the Mute
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayerKplayer.js
@@ -31,13 +31,20 @@
3232 * Write the Embed html to the target
3333 */
3434 doEmbedHTML : function () {
35 - var _this = this;
36 - var playerPath = mw.getMwEmbedPath() + 'modules/EmbedPlayer/binPlayers/kaltura-player';
 35+ var _this = this;
3736
3837 mw.log("kPlayer:: embed src::" + _this.getSrc() );
3938 var flashvars = {};
4039 flashvars.autoPlay = "true";
 40+ var playerPath = mw.getMwEmbedPath() + 'modules/EmbedPlayer/binPlayers/kaltura-player';
4141 flashvars.entryId = mw.absoluteUrl( _this.getSrc() );
 42+
 43+ // Use a relative url if the protocal is file://
 44+ if( mw.parseUri( document.URL).protocol == 'file' ) {
 45+ playerPath = mw.getRelativeMwEmbedPath() + 'modules/EmbedPlayer/binPlayers/kaltura-player';
 46+ flashvars.entryId = _this.getSrc();
 47+ }
 48+
4249 flashvars.debugMode = "true";
4350 flashvars.fileSystemMode = "true";
4451 flashvars.widgetId = "_7463";
@@ -208,6 +215,7 @@
209216 doSeek: function( percentage ) {
210217 var _this = this;
211218 if ( this.supportsURLTimeEncoding() ){
 219+
212220 // Make sure we could not do a local seek instead:
213221 if ( !( percentage < this.bufferedPercent && this.playerElement.duration && !this.didSeekJump )) {
214222 // We support URLTimeEncoding call parent seek:
@@ -216,10 +224,8 @@
217225 }
218226 }
219227
220 -
221228 if( this.playerElement ) {
222 - var seekTime = percentage * this.getDuration();
223 -
 229+ var seekTime = percentage * this.getDuration();
224230 // Issue the seek to the flash player:
225231 this.playerElement.sendNotification('doSeek', seekTime);
226232

Comments

#Comment by Nikerabbit (talk | contribs)   06:45, 18 September 2010

Does lots of other things too in addition to what is mentioned in commit message.

#Comment by Mdale (talk | contribs)   17:00, 18 September 2010

true. This synced up with kaltura updates. http://www.kaltura.org/repos-web/open/log/?base=&target=/html5video/trunk/mwEmbed

Adds android support, Adds some minor fixes to player switching callbacks Refactors the displayMenuOverlay call

Status & tagging log