Skip to content

Instantly share code, notes, and snippets.

@burchbobby
Created December 7, 2016 21:50
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 burchbobby/4e92e8890f2ee31f9e06530af61fc5c9 to your computer and use it in GitHub Desktop.
Save burchbobby/4e92e8890f2ee31f9e06530af61fc5c9 to your computer and use it in GitHub Desktop.
Tools to further enhance your Giant Bomb experience!
var GBHelper = window.GBHelper = window.GBHelper || {};
//////////////////////
// GBHelper.Podcast //
//////////////////////
GBHelper.Podcast = (function ($) {
var defaults, options;
var player = null;
defaults = {
id: 'playingPodcast',
el: '#js-pod-player',
step: {
fine: 15000, // 15 seconds
coarse: 30000 // 30 seconds
},
};
var init = function (opt) {
options = $.extend({}, defaults, opt);
player = soundManager.getSoundById(options.id);
_allowFocus();
_allowSeeking();
};
function _allowFocus () {
$(options.el).attr('tabfocus', 0);
}
function _allowSeeking () {
// @TODO: Add shift + arrow for coarse jump (30 seconds).
var LEFT_ARROW = 37;
var RIGHT_ARROW = 39;
$(options.el).on('keyup', function (e) {
// Get current position.
var current = player.position;
switch (e.keyCode) {
case LEFT_ARROW:
// Step back 15 seconds.
player.setPosition(current - options.step.fine);
break;
case RIGHT_ARROW:
// Step forward 15 seconds.
player.setPosition(current + options.step.fine);
break;
default:
break;
}
});
}
return {
init: init
};
})(window.jQuery);
$(function () {
GBHelper.Podcast.init();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment