r69859 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69858‎ | r69859 | r69860 >
Date:04:01, 25 July 2010
Author:dale
Status:deferred
Tags:
Comment:
firefogg gui updates ( fix maxsize override of width height )
Modified paths:
  • /trunk/extensions/AddMediaWizard/AddMedia/AddMedia.i18n.php (modified) (history)
  • /trunk/extensions/AddMediaWizard/AddMedia/loader.js (modified) (history)
  • /trunk/extensions/AddMediaWizard/AddMedia/mw.Firefogg.js (modified) (history)
  • /trunk/extensions/AddMediaWizard/AddMedia/mw.FirefoggGUI.js (modified) (history)

Diff [purge]

Index: trunk/extensions/AddMediaWizard/AddMedia/loader.js
@@ -65,7 +65,7 @@
6666 ]
6767 ] );
6868
69 - //Set a variable for the base upload interface for easy inclution
 69+ //Set a variable for the base upload interface for easy inclusion
7070 var baseUploadlibs = [
7171 [
7272 'mw.UploadHandler',
Index: trunk/extensions/AddMediaWizard/AddMedia/mw.Firefogg.js
@@ -24,7 +24,8 @@
2525 "fogg-badtoken" : "Token is not valid",
2626 "fogg-preview" : "Preview video",
2727 "fogg-hidepreview" : "Hide preview",
28 - "fogg-warning-firebug" : "<b>Firebug</b> can cause conflicts with <i>Firefogg</i>. Please disable <b>Firebug</b> for this page."
 28+ "fogg-warning-firebug" : "<b>Firebug</b> can cause conflicts with <i>Firefogg</i>. Please disable <b>Firebug</b> for this page.",
 29+ "fogg-missing-webm-support" : "Please use a [$1 webm compatible] browsers to preview results of webm videos"
2930 });
3031
3132 var firefogg_install_links = {
@@ -100,7 +101,7 @@
101102 * NOTE: we should have the firefogg binding work the same way as
102103 * the upload form binding.
103104 */
104 -( function( $ ) {
 105+( function( $ ) {
105106 $.fn.firefogg = function( options ) {
106107 if ( !options ){
107108 options = { };
@@ -123,14 +124,14 @@
124125 } )( jQuery );
125126
126127
127 -mw.Firefogg = function( options ) {
 128+mw.Firefogg = function( options ) {
128129 return this.init( options );
129130 };
130131 mw.Firefogg.prototype = { // extends mw.BaseUploadHandler
131 - // Minnium version of firefogg allowed
132 - min_firefogg_version: '1.1.0',
 132+ // Minimum version of firefogg allowed
 133+ min_firefogg_version: '1.2.06',
133134
134 - // The default encoder seetings
 135+ // The default encoder settings
135136 // NOTE: should be mw.getConfig based
136137 default_encoder_settings: {
137138 'maxSize' : '400',
@@ -139,13 +140,13 @@
140141 'noUpscaling' : true
141142 },
142143
143 - // Lazy initialised, use getFirefogg()
 144+ // Lazy initialized, use getFirefogg()
144145 have_firefogg: null,
145146
146 - // Lazy initialised, use getEncoderSettings()
 147+ // Lazy initialized, use getEncoderSettings()
147148 current_encoder_settings: null,
148149
149 - // Lazy initialised, use getSourceFileInfo()
 150+ // Lazy initialized, use getSourceFileInfo()
150151 sourceFileInfo: null,
151152
152153 // Valid ogg extensions
@@ -350,9 +351,9 @@
351352 gM( 'fogg-for_improved_uploads' ) + ' ' : gM( 'fogg-not-installed') + ' ';
352353
353354 // Show the "use latest Firefox" message if necessary
354 - mw.log( 'bv: ' + mw.versionIsAtLeast( '1.9.1', $j.browser.version ) );
 355+ mw.log( 'mw.Firefogg:: browser: ' + mw.versionIsAtLeast( '1.9.1', $j.browser.version ) );
355356 if ( !( $j.browser.mozilla && mw.versionIsAtLeast( '1.9.1', $j.browser.version ) ) ) {
356 - mw.log( 'show use latest::' + _this.target_use_latest_firefox );
 357+ mw.log( 'mw.Firefogg::show use latest::' + _this.target_use_latest_firefox );
357358
358359 // Add the use_latest if not present:
359360 if ( !this.target_use_latest_firefox ) {
@@ -384,7 +385,8 @@
385386 $j( _this.target_use_latest_firefox ).show();
386387 return ;
387388 }
388 - mw.log( 'should show install link');
 389+ mw.log( 'mw.Firefogg::should show install link');
 390+
389391 // Otherwise show the "install Firefogg" message
390392 var firefoggUrl = _this.getFirefoggInstallUrl();
391393 if( firefoggUrl ) {
@@ -822,42 +824,60 @@
823825 * This is called when a local encode operation has completed. It updates the UI.
824826 */
825827 onLocalEncodeDone: function() {
826 - var _this = this;
 828+ var _this = this;
 829+ var videoEmbedCode = '<video controls="true" style="margin:auto" id="fogg_final_vid" '+
 830+ 'src="' +_this.fogg.previewUrl + '"></video>';
 831+
 832+ if( this.current_encoder_settings['videoCodec'] == 'vp8' ) {
 833+ var dummyvid = document.createElement( "video" );
 834+ if( !dummyvid.canPlayType('video/webm; codecs="vp8, vorbis"') ) {
 835+ videoEmbedCode = gM('fogg-missing-webm-support',
 836+ $j('<a />')
 837+ .attr({
 838+ 'href' : 'http://www.webmproject.org/users/',
 839+ 'target' : '_new'
 840+ })
 841+ )
 842+ }
 843+ }
827844 _this.ui.setPrompt( gM( 'fogg-encoding-done' ),
828 - gM( 'fogg-encoding-done' ) + '<br>' +
829 - // Show the video at full resolution upto 720px wide
830 - '<video controls="true" style="margin:auto" id="fogg_final_vid" '+
831 - 'src="' +_this.fogg.previewUrl + '"></video>'
 845+ $j( '<div />' ).append(
 846+ gM( 'fogg-encoding-done' ),
 847+ $j('<br>' ),
 848+ videoEmbedCode
 849+ )
832850 );
833851 //Load the video and set a callback:
834852 var v = $j( '#fogg_final_vid' ).get( 0 );
835 - function resizeVid() {
836 - var v = $j( '#fogg_final_vid' ).get(0);
837 - if ( v.videoWidth > 720 ) {
838 - var vW = 720;
839 - var vH = 720 * v.videoHeight / v.videoWidth;
840 - } else {
841 - var vW = v.videoWidth;
842 - var vH = v.videoHeight;
 853+ if( v ) {
 854+ function resizeVid() {
 855+ var v = $j( '#fogg_final_vid' ).get(0);
 856+ if ( v.videoWidth > 720 ) {
 857+ var vW = 720;
 858+ var vH = 720 * v.videoHeight / v.videoWidth;
 859+ } else {
 860+ var vW = v.videoWidth;
 861+ var vH = v.videoHeight;
 862+ }
 863+ //reize the video:
 864+ $j( v ).css({
 865+ 'width': vW,
 866+ 'height': vH
 867+ });
 868+ //if large video resize the dialog box:
 869+ if( vW + 5 > 400 ) {
 870+ //also resize the dialog box
 871+ $j( '#upProgressDialog' ).dialog( 'option', 'width', vW + 20 );
 872+ $j( '#upProgressDialog' ).dialog( 'option', 'height', vH + 120 );
 873+
 874+ //also position the dialog container
 875+ $j( '#upProgressDialog') .dialog( 'option', 'position', 'center' );
 876+ }
843877 }
844 - //reize the video:
845 - $j( v ).css({
846 - 'width': vW,
847 - 'height': vH
848 - });
849 - //if large video resize the dialog box:
850 - if( vW + 5 > 400 ) {
851 - //also resize the dialog box
852 - $j( '#upProgressDialog' ).dialog( 'option', 'width', vW + 20 );
853 - $j( '#upProgressDialog' ).dialog( 'option', 'height', vH + 120 );
854 -
855 - //also position the dialog container
856 - $j( '#upProgressDialog') .dialog( 'option', 'position', 'center' );
857 - }
 878+ v.removeEventListener( "loadedmetadata", resizeVid, true );
 879+ v.addEventListener( "loadedmetadata", resizeVid, true );
 880+ v.load();
858881 }
859 - v.removeEventListener( "loadedmetadata", resizeVid, true );
860 - v.addEventListener( "loadedmetadata", resizeVid, true );
861 - v.load();
862882 },
863883
864884 /**
@@ -865,6 +885,7 @@
866886 * into which a video has already been selected.
867887 */
868888 getEncoderSettings: function() {
 889+ // set the current_encoder_settings form the default_encoder_settings if not yet set
869890 if ( this.current_encoder_settings == null ) {
870891
871892 // Clone the default settings
@@ -896,8 +917,15 @@
897918 ' passthrough:' + settings['passthrough'] );
898919
899920 this.current_encoder_settings = settings;
900 - }
901 - //Update the format based on codec selection
 921+ }
 922+
 923+ // Remove maxSize if width or height is set:
 924+ if( ( this.current_encoder_settings['width'] || this.current_encoder_settings['height'] )
 925+ && this.current_encoder_settings['maxSize'] ){
 926+ delete this.current_encoder_settings['maxSize'];
 927+ }
 928+
 929+ // Update the format based on codec selection
902930 if( this.current_encoder_settings['videoCodec'] == 'vp8' ){
903931 this.fogg.setFormat('webm');
904932 } else {
Index: trunk/extensions/AddMediaWizard/AddMedia/mw.FirefoggGUI.js
@@ -68,7 +68,8 @@
6969 "fogg-license-title" : "License",
7070 "fogg-license-help" : "The license of the clip (preferably a Creative Commons URL).",
7171 "fogg-contact-title" : "Contact",
72 - "fogg-contact-help" : "Contact link"
 72+ "fogg-contact-help" : "Contact link",
 73+ "fogg-gui-title" : "Make web video"
7374 });
7475
7576 /**
@@ -769,8 +770,11 @@
770771 presetDesc = this.local_settings.presets[presetKey].desc;
771772 } else {
772773 presetDesc = gM( 'fogg-preset-' + presetKey );
773 - }
774 -
 774+ }
 775+ if( presetKey != 'custom' ){
 776+ // Copy the preset into custom settings
 777+ this.local_settings.presets['custom']['conf'] = $j.extend( {}, this.local_settings.presets[presetKey]['conf'] );
 778+ }
775779 // Update the preset title
776780 $j( this.selector + ' .gd_preset' )
777781 .html( gM( 'fogg-cg-preset', presetDesc ) );
@@ -814,7 +818,7 @@
815819 * return it.
816820 */
817821 updateLocalValue: function( confKey, value ) {
818 - if ( typeof this.default_encoder_config[confKey] == 'undefined' ) {
 822+ if ( typeof this.default_encoder_config[ confKey ] == 'undefined' ) {
819823 mw.log( "Error: could not update conf key: " + confKey )
820824 return value;
821825 }
Index: trunk/extensions/AddMediaWizard/AddMedia/AddMedia.i18n.php
@@ -97,11 +97,8 @@
9898 'fogg-license-help' => 'The license of the clip (preferably a Creative Commons URL).',
9999 'fogg-contact-title' => 'Contact',
100100 'fogg-contact-help' => 'Contact link',
101 - 'mwe-stream_title' => '$1 $2 to $3',
102 - 'rsd-media-filter-title' => 'Media',
103 - 'rsd-media-filter-videos' => 'Videos',
104 - 'rsd-media-filter-images' => 'Images',
105 - 'rsd-provider-filter-title' => 'Providers',
 101+ 'fogg-missing-webm-support' => 'Please use a [$1 webm compatible] browsers to preview results of webm videos',
 102+ 'fogg-gui-title' => 'Make web video',
106103 'mwe-imported_from' => '$1 imported from [$2 $3]. See the original [$4 resource page] for more information.',
107104 'mwe-import-description' => '$1, imported from $2',
108105 'mwe-select_file' => 'Select file',

Follow-up revisions

RevisionCommit summaryAuthorDate
r69897Follow-up r69859: webm -> WebM (see http://en.wikipedia.org/wiki/WebM )...raymond19:37, 25 July 2010

Status & tagging log