Created
December 7, 2016 21:50
-
-
Save burchbobby/4e92e8890f2ee31f9e06530af61fc5c9 to your computer and use it in GitHub Desktop.
Tools to further enhance your Giant Bomb experience!
This file contains 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
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