Last active
August 29, 2015 14:00
-
-
Save gicolek/11176340 to your computer and use it in GitHub Desktop.
MJ Handler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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