mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
38 lines
No EOL
690 B
JavaScript
38 lines
No EOL
690 B
JavaScript
define([
|
|
],
|
|
|
|
function () {
|
|
|
|
"use strict";
|
|
|
|
function AudioPlayer(path) {
|
|
this.audio = new Audio(path);
|
|
this.audio.loop = true;
|
|
this.audio.volume = 0.1;
|
|
|
|
this.audio.addEventListener('timeupdate', function(){
|
|
var buffer = 1
|
|
if(this.currentTime > this.duration - buffer) {
|
|
this.currentTime = 1
|
|
this.play()
|
|
}
|
|
}, false);
|
|
}
|
|
|
|
AudioPlayer.prototype.play = function() {
|
|
//this.audio.play();
|
|
//this.doPlay = true;
|
|
}
|
|
|
|
AudioPlayer.prototype.stop = function() {
|
|
this.audio.stop();
|
|
this.doPlay = false;
|
|
};
|
|
|
|
AudioPlayer.prototype.destroy = function() {
|
|
this.stop();
|
|
};
|
|
|
|
return AudioPlayer;
|
|
|
|
}); |