Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 7 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
Commits on May 12, 2012
@socialhack 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.
7104fa2
Commits on May 17, 2012
@socialhack alpha version of deep linking support
url rewriting for continuous play and chapters already works. what's
missing is the right hook to wait until later playback positions are
loaded.
d09b44e
@socialhack cleanup ff30f25
@socialhack dirty running code
first version that actually skips correctly to the deep-linked time.
code needs cleanup & packaging, but it works! :)
2a34f92
Commits on May 18, 2012
@socialhack beta deep linking
everything besides start-stop deep links is working and organized in
fine encapsulated manner.
5ccaa28
@socialhack bugfix 2356117
@socialhack finish
cleanup & final version without stop times
1311544
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
96 podlove-web-player/podlove-chapters.js
@@ -1,14 +1,30 @@
var PODLOVE = PODLOVE || {};
+PODLOVE.playercount = 0;
PODLOVE.chapters = function (playerId) {
+ // parse deeplinks
+ if (!PODLOVE.playercount) {
+ PODLOVE.ref_deep_links = window.location.href.match(/((\d\d:)?\d\d:\d\d(\.\d\d\d)?)/) || [];
+ PODLOVE.ref_deep_links.splice(1,1);
+ $(PODLOVE.ref_deep_links).each(function (i, e) {
+ PODLOVE.ref_deep_links[i] = PODLOVE.chapters.parseTimecode(e);
+ });
+
+ if (PODLOVE.ref_deep_links.length) {
+ $('#' + playerId).attr('preload', 'auto');
+ }
+ }
+
MediaElement(playerId, {
success: function (player) {
- PODLOVE.chapters.addBehaviour(playerId, player);
+ PODLOVE.playercount++;
+ PODLOVE.chapters.addBehaviour_chapter(playerId, player);
+ PODLOVE.chapters.addBehaviour_deep_linking(playerId, player);
}
});
};
-PODLOVE.chapters.addBehaviour = function (playerId, player) {
+PODLOVE.chapters.addBehaviour_chapter = function (playerId, player) {
var list = jQuery('table[rel=' + playerId + ']')
.show()
.on('click', 'a', function () {
@@ -16,9 +32,11 @@ PODLOVE.chapters.addBehaviour = function (playerId, player) {
player.setCurrentTime(time);
player.play();
return false;
- });
+ })
+
player.addEventListener('timeupdate', function (e) {
+ // update the chapter list when the data is loaded
list.find('span').each(function (i) {
var span = jQuery(this),
row = span.closest('tr'),
@@ -26,8 +44,9 @@ PODLOVE.chapters.addBehaviour = function (playerId, player) {
endTime = span.data('end'),
isEnabled = span.data('enabled') === '1',
isBuffered = player.buffered.end(0) > startTime,
- isActive = player.currentTime > startTime - 0.3 &&
- player.currentTime <= endTime;
+ isActive = player.currentTime > startTime - 0.3 &&
+ player.currentTime <= endTime,
+ tmpTimecode;
if (isActive && !row.hasClass('active')) {
span.closest('table')
@@ -40,4 +59,69 @@ PODLOVE.chapters.addBehaviour = function (playerId, player) {
}
});
}, false);
-};
+};
+
+
+/**
+ * deeplinking: skipt to referenced time position & write current times into adress
+ * @param playerId string
+ * @param player object
+ */
+PODLOVE.chapters.addBehaviour_deep_linking = function (playerId, player) {
+ var skip_to_linked_time = function (e) {
+ if (PODLOVE.playercount === 1 && PODLOVE.ref_deep_links.length) {
+ player.setCurrentTime(PODLOVE.ref_deep_links[0]);
+ PODLOVE.ref_deep_links = [];
+ }
+ }
+ , address_current_time = function (e) {
+ if (PODLOVE.playercount === 1 && !PODLOVE.ref_deep_links.length) {
+ history.pushState(null, null, '#' + PODLOVE.chapters.generateTimecode(player.currentTime));
+ }
+ }
+
+ if (PODLOVE.playercount === 1) {
+ if (PODLOVE.ref_deep_links.length) {
+ player.addEventListener('play', skip_to_linked_time , false);
+ player.addEventListener('timeupdate', skip_to_linked_time , false);
+ }
+ player.addEventListener('pause', address_current_time, false);
+ player.addEventListener('seeked', address_current_time, false);
+
+ jQuery('table[rel=' + playerId + ']').on('click', 'a', function () {
+ history.pushState(null, null, '#' + PODLOVE.chapters.generateTimecode(jQuery(this).find('span').data('start')));
+ });
+ }
+};
+
+/**
+ * returns seconds in deep-linking time format
+ * @param sec number
+ * @return string
+ **/
+PODLOVE.chapters.generateTimecode = function (sec) {
+ var prim = function (v, mil) {
+ v = (v || 0) + '';
+ return (mil && v.length <3 ? '0' : '') + (v.length < 2 ? '0' : '') + v;
+ }
+ , tcode;
+ tcode = prim(Math.floor(sec/60/60)) + ':' + prim(Math.floor(sec/60)%60) + ':' + prim(Math.floor(sec%60)%60) + '.' + prim(((sec-Math.floor(sec)) + '').substring(2,5) || '000', true);
+ return tcode;
+};
+
+/**
+ * parses time code into seconds
+ * @param string timecode
+ * @return number
+ **/
+PODLOVE.chapters.parseTimecode = function (tcode) {
+ var parts;
+ if ((parts = (tcode || '').match(/((\d\d:)?(\d\d):(\d\d)(\.\d\d\d)?)/)) && parts.length === 6) {
+ parts = (parts[2] ? parseInt (parts[2].substring(0,2)) * 60 * 60 : 0) +
+ parseInt (parts[3]) * 60 +
+ parseInt (parts[4]) +
+ (parts[5] ? parseFloat('0' + parts[5]) : 0);
+ return parts;
+ }
+};
+
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,6 +431,7 @@ 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">
@@ -436,6 +439,25 @@ function podlove_media_shortcode($tagName, $atts) {
<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

No commit comments for this range

Something went wrong with that request. Please try again.