mirror of
https://github.com/ivuorinen/rss-audio-player.git
synced 2026-02-05 00:46:57 +00:00
RSSAudioPlayer 1.0
Quick system to play your (currently my) favourite podcast feeds and stuff.
This commit is contained in:
51
assets/scripts.js
Normal file
51
assets/scripts.js
Normal file
@@ -0,0 +1,51 @@
|
||||
$(document).foundation();
|
||||
|
||||
$(function() {
|
||||
// Setup the player to autoplay the next track
|
||||
var a = audiojs.createAll({
|
||||
trackEnded: function() {
|
||||
var next = $('ol li.playing').next();
|
||||
if (!next.length) next = $('ol li').first();
|
||||
next.addClass('playing').siblings().removeClass('playing');
|
||||
audio.load($('a', next).attr('data-src'));
|
||||
audio.play();
|
||||
}
|
||||
});
|
||||
|
||||
// Load in the first track
|
||||
var audio = a[0];
|
||||
first = $('ol a').attr('data-src');
|
||||
$('ol li').first().addClass('playing');
|
||||
audio.load(first);
|
||||
|
||||
// Load in a track on click
|
||||
$('ol li').click(function(e) {
|
||||
e.preventDefault();
|
||||
$(this).addClass('playing').siblings().removeClass('playing');
|
||||
audio.load($('a', this).attr('data-src'));
|
||||
audio.play();
|
||||
});
|
||||
|
||||
// Keyboard shortcuts
|
||||
$(document).keydown(function(e) {
|
||||
var unicode = e.charCode ? e.charCode : e.keyCode;
|
||||
|
||||
// right arrow
|
||||
if (unicode == 39) {
|
||||
var next = $('li.playing').next();
|
||||
if (!next.length) next = $('ol li').first();
|
||||
next.click();
|
||||
|
||||
// back arrow
|
||||
} else if (unicode == 37) {
|
||||
|
||||
var prev = $('li.playing').prev();
|
||||
|
||||
if (!prev.length) prev = $('ol li').last();
|
||||
prev.click();
|
||||
// spacebar
|
||||
} else if (unicode == 32) {
|
||||
audio.playPause();
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user