Permalink
Browse files

audiojs fallback for firefox, msie and opera

audiojs submodule is used instead of mediaelementjs player if viewed in
firefox, msie or opera. workaround till mediaelementjs player is
working again in those browsers. chapter list is still displayed, but
not interacting with the player.
  • Loading branch information...
1 parent e1d74ff commit 7104fa268a7b0af8b7c319b8ccb3ffcffe2fd7ff @socialhack socialhack committed May 12, 2012
Showing with 26 additions and 0 deletions.
  1. +3 −0 .gitmodules
  2. +1 −0 podlove-web-player/audiojs
  3. +22 −0 podlove-web-player/podlove-web-player.php
View
3 .gitmodules
@@ -0,0 +1,3 @@
+[submodule "podlove-web-player/audiojs"]
+ path = podlove-web-player/audiojs
+ url = https://github.com/kolber/audiojs.git
1 podlove-web-player/audiojs
@@ -0,0 +1 @@
+Subproject commit 7f384f47dcd2d584676310ca03c300f091252d55
View
22 podlove-web-player/podlove-web-player.php
@@ -21,6 +21,7 @@
$podlovePlayerIndex = 1;
define('MEDIAELEMENTJS_DIR', plugin_dir_url(__FILE__) . 'mediaelement/');
+define('AUDIOJS_DIR', plugin_dir_url(__FILE__).'audiojs/audiojs/');
/* Runs when plugin is activated */
register_activation_hook(__FILE__, 'mejs_install');
@@ -202,6 +203,7 @@ function mejs_add_scripts() {
if (!is_admin()) {
// the scripts
wp_enqueue_script('podlove-scripts', MEDIAELEMENTJS_DIR . 'mediaelement-and-player.min.js', array('jquery'), '2.7.1', false);
+ wp_enqueue_script("audiojs-scripts", AUDIOJS_DIR ."audio.min.js");
wp_enqueue_script('podlove-chapters', plugin_dir_url(__FILE__) . 'podlove-chapters.js', array('jquery'), '2.7.1', false);
}
}
@@ -429,13 +431,33 @@ function podlove_media_shortcode($tagName, $atts) {
$options_string = !empty($options) ? '{' . implode(',', $options) . '}' : '';
$mediahtml = <<<_end_
+ <div class="mediaelementjs_player_container">
<{$tagName} id="wp_mep_{$podlovePlayerIndex}" controls="controls" {$attributes_string} class="mejs-player {$skin_class}" data-mejsoptions='{$options_string}'>
{$sources_string}
<object width="{$width}" height="{$height}" type="application/x-shockwave-flash" data="{$dir}flashmediaelement.swf">
<param name="movie" value="{$dir}flashmediaelement.swf" />
<param name="flashvars" value="controls=true&amp;file={$flash_src}" />
</object>
</{$tagName}>
+ </div>
+ <div class="audiojs_player_container" style="display: none">
+ <audio src="{$flash_src}" preload="none"/>
+ </div>
+ <script type="text/javascript">
+ $(document).ready(function () {
+ // firefox, msie and opera get the fallback player
+ var user_agent = navigator.userAgent.toLowerCase()
+ if ((/mozilla/.test(user_agent) && (!/(compatible|webkit)/.test(user_agent))) ||
+ (/msie/.test(user_agent) && !/opera/.test(user_agent)) ||
+ (/opera/.test(user_agent))) {
+ $('.mediaelementjs_player_container').hide();
+ $('.audiojs_player_container').show();
+ audiojs.events.ready(function() {
+ var as = audiojs.createAll();
+ });
+ }
+ });
+ </script>
_end_;
// Chapters Table and Behaviour

0 comments on commit 7104fa2

Please sign in to comment.