From a5f917bbc55e295896b8084f6657eb8b6abaf8a8 Mon Sep 17 00:00:00 2001 From: André Fabian Silva Delgado Date: Fri, 15 Jul 2016 15:33:36 -0300 Subject: Add TimedMediaHandler extension that allows display audio and video files in wiki pages, using the same syntax as for image files --- .../resources/PopUpThumbVideo.css | 29 ++ .../resources/download_sprite.png | Bin 0 -> 806 bytes .../resources/embedPlayerIframe.css | 7 + .../resources/ext.tmh.OgvJsSupport.js | 67 ++++ .../resources/ext.tmh.TimedTextSelector.js | 8 + .../resources/ext.tmh.transcodetable.js | 90 +++++ .../resources/mw.MediaWikiPlayer.loader.js | 8 + .../resources/mw.MediaWikiPlayerSupport.js | 380 +++++++++++++++++++++ .../resources/mw.PopUpThumbVideo.js | 44 +++ .../resources/mw.TMHGalleryHook.js | 46 +++ .../resources/player_big_play_button.png | Bin 0 -> 987 bytes .../resources/player_big_play_button_hover.png | Bin 0 -> 1022 bytes .../TimedMediaHandler/resources/transcodeTable.css | 14 + 13 files changed, 693 insertions(+) create mode 100644 extensions/TimedMediaHandler/resources/PopUpThumbVideo.css create mode 100644 extensions/TimedMediaHandler/resources/download_sprite.png create mode 100644 extensions/TimedMediaHandler/resources/embedPlayerIframe.css create mode 100644 extensions/TimedMediaHandler/resources/ext.tmh.OgvJsSupport.js create mode 100644 extensions/TimedMediaHandler/resources/ext.tmh.TimedTextSelector.js create mode 100644 extensions/TimedMediaHandler/resources/ext.tmh.transcodetable.js create mode 100644 extensions/TimedMediaHandler/resources/mw.MediaWikiPlayer.loader.js create mode 100644 extensions/TimedMediaHandler/resources/mw.MediaWikiPlayerSupport.js create mode 100644 extensions/TimedMediaHandler/resources/mw.PopUpThumbVideo.js create mode 100644 extensions/TimedMediaHandler/resources/mw.TMHGalleryHook.js create mode 100644 extensions/TimedMediaHandler/resources/player_big_play_button.png create mode 100644 extensions/TimedMediaHandler/resources/player_big_play_button_hover.png create mode 100644 extensions/TimedMediaHandler/resources/transcodeTable.css (limited to 'extensions/TimedMediaHandler/resources') diff --git a/extensions/TimedMediaHandler/resources/PopUpThumbVideo.css b/extensions/TimedMediaHandler/resources/PopUpThumbVideo.css new file mode 100644 index 00000000..3ba0572a --- /dev/null +++ b/extensions/TimedMediaHandler/resources/PopUpThumbVideo.css @@ -0,0 +1,29 @@ +.PopUpMediaTransform a .play-btn-large{ + position : absolute; + top: 50%; + left : 50%; + width: 70px; + height: 53px; + margin-left: -35px; + margin-top: -25px; + /* @embed */ + background-image:url('player_big_play_button.png'); +} +.PopUpMediaTransform a .play-btn-large :hover{ + /* @embed */ + background-image:url('player_big_play_button_hover.png'); +} +.PopUpMediaTransform { + position : relative; + display: inline-block; +} +/* Should hopefully be only visible to screen readers */ +.mw-tmh-playtext { + display: block; + height: 0; + overflow: hidden; +} + +li.gallerybox div.thumb div.PopUpMediaTransform { + margin: 0 auto; +} diff --git a/extensions/TimedMediaHandler/resources/download_sprite.png b/extensions/TimedMediaHandler/resources/download_sprite.png new file mode 100644 index 00000000..541d4a99 Binary files /dev/null and b/extensions/TimedMediaHandler/resources/download_sprite.png differ diff --git a/extensions/TimedMediaHandler/resources/embedPlayerIframe.css b/extensions/TimedMediaHandler/resources/embedPlayerIframe.css new file mode 100644 index 00000000..eb6e9003 --- /dev/null +++ b/extensions/TimedMediaHandler/resources/embedPlayerIframe.css @@ -0,0 +1,7 @@ +body { + margin-left: 0px; + margin-top: 0px; + margin-right: 0px; + margin-bottom: 0px; + overflow: hidden; +} diff --git a/extensions/TimedMediaHandler/resources/ext.tmh.OgvJsSupport.js b/extensions/TimedMediaHandler/resources/ext.tmh.OgvJsSupport.js new file mode 100644 index 00000000..af3fd9f5 --- /dev/null +++ b/extensions/TimedMediaHandler/resources/ext.tmh.OgvJsSupport.js @@ -0,0 +1,67 @@ +( function( $, mw ) { + + var support = mw.OgvJsSupport = { + /** + * Ensure that the OGVPlayer class is loaded before continuing. + * + * @return jQuery.Deferred + */ + loadOgvJs: function() { + return $.Deferred( function( deferred ) { + if ( typeof OGVPlayer === 'undefined' ) { + mw.loader.using( 'ext.tmh.OgvJs', function() { + OGVLoader.base = support.basePath(); + deferred.resolve(); + } ); + } else { + deferred.resolve(); + } + }); + }, + + /** + * Get the base path of ogv.js and friends. + * + * @return string + */ + basePath: function() { + var ext = mw.config.get( 'wgExtensionAssetsPath' ), + binPlayers = ext + '/TimedMediaHandler/MwEmbedModules/EmbedPlayer/binPlayers'; + return binPlayers + '/ogv.js'; + }, + + /** + * Return a stub audio context + * + * This is used for iOS Safari to enable Web Audio by triggering an empty + * audio output channel during a user input event handler. Without that, + * audio is left disabled and won't work when we start things up after an + * asynchronous code load. + * + * @return AudioContext + */ + initAudioContext: function() { + var AudioContext = window.AudioContext || window.webkitAudioContext; + if ( AudioContext ) { + var context = new AudioContext(), + node; + if ( context.createScriptProcessor ) { + node = context.createScriptProcessor( 1024, 0, 2 ); + } else if ( context.createJavaScriptNode ) { + node = context.createJavaScriptNode( 1024, 0, 2 ); + } else { + throw new Error( 'Bad version of web audio API?' ); + } + + // Don't actually run any audio, just start & stop the node + node.connect( context.destination ); + node.disconnect(); + + return context; + } else { + return null; + } + } + }; + +} )( jQuery, mediaWiki ); diff --git a/extensions/TimedMediaHandler/resources/ext.tmh.TimedTextSelector.js b/extensions/TimedMediaHandler/resources/ext.tmh.TimedTextSelector.js new file mode 100644 index 00000000..b53bb6f8 --- /dev/null +++ b/extensions/TimedMediaHandler/resources/ext.tmh.TimedTextSelector.js @@ -0,0 +1,8 @@ +( function ( $, mw ) { + $( function () { + $( '#timedmedia-tt-go' ).click( function () { + window.location = mw.config.get( 'wgScript' ) + '?title=' + mw.util.wikiUrlencode( mw.config.get( 'wgPageName' ) ) + '.' + $( '#timedmedia-tt-input' ).val() + '.srt&action=edit'; + } ); + } ); + +} )( jQuery, mediaWiki ); diff --git a/extensions/TimedMediaHandler/resources/ext.tmh.transcodetable.js b/extensions/TimedMediaHandler/resources/ext.tmh.transcodetable.js new file mode 100644 index 00000000..a8c8f98d --- /dev/null +++ b/extensions/TimedMediaHandler/resources/ext.tmh.transcodetable.js @@ -0,0 +1,90 @@ +/** +* Javascript to support transcode table on image page +*/ +( function ( mw, $ ) { + $( document ).ready( function () { + var errorPopup, $errorLink; + + errorPopup = function () { + // pop up dialog + mw.addDialog( { + 'width': '640', + 'height': '480', + 'title': $(this).attr( 'title' ), + 'content': $('