Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@gicolek
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gicolek/11176340 to your computer and use it in GitHub Desktop.
Save gicolek/11176340 to your computer and use it in GitHub Desktop.
MJ Handler
/* global mejs, _wpmejsSettings */
(function($) {
// add mime-type aliases to MediaElement plugin support
mejs.plugins.silverlight[0].types.push('video/x-ms-wmv');
mejs.plugins.silverlight[0].types.push('audio/x-ms-wma');
$(function() {
var currentID,
settings = {
success: function(media, node, player) {
media.addEventListener('play', function(e) {
// do something here
});
media.addEventListener('pause', function(e) {
// do something here
});
// add event listener fired for a video being played
media.addEventListener('playing', function(e) {
// get the currently playing post id
currentID = $(node).parents('.post').data('id');
// fire a global trigger view function injected by includes/views.php
trigger_view(currentID);
});
},
iPadUseNativeControls: true,
// force iPhone's native controls
iPhoneUseNativeControls: true,
// force Android's native controls
AndroidUseNativeControls: true
};
if (typeof _wpmejsSettings !== 'undefined')
// not sure if we need that
settings.pluginPath = _wpmejsSettings.pluginPath;
$('.wp-audio-shortcode, .wp-video-shortcode').mediaelementplayer(settings);
});
}(jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment