Added music and music player js files

This commit is contained in:
Ascendings 2015-10-06 12:36:47 -04:00
parent 6507e0e54c
commit 5c2606e5bd
2 changed files with 60 additions and 10 deletions

View File

@ -0,0 +1,53 @@
(function($){
$.fn.musicPlayer = function(opt) {
var settings, player, getVolume, setVolume, isPlaying, play, pause, getTime, setTime;
settings = $.extend({
'audio': '#music-player',
'volume': .5,
'startTime': 0
}, opt);
player = $(settings.player);
getVolume = function() {
return player.prop('volume');
}
setVolume = function(volume) {
player.prop('volume', volume);
};
isPlaying = function() {
return !player.prop('paused');
};
play = function() {
if (!isPlaying()) {
player.trigger('play');
}
};
pause = function() {
if (isPlaying()) {
player.trigger('pause');
}
};
getTime = function() {
return player.prop('currentTime');
};
setTime = function(time) {
player.prop('currentTime', time);
};
// Default actions
setVolume(settings.volume);
setTime(setTime.startTime);
};
})(jQuery);

View File

@ -1,10 +1,7 @@
// Generated by CoffeeScript 1.4.0
(function() {
$(document).ready(function() { $(document).ready(function() {
var player; $('#music-player').musicPlayer({
player = $('#music-player'); 'audio': '#music-player',
return player.volume = .5; 'volume': .5,
'startTime': 0
})
}); });
}).call(this);