mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 03:23:29 +01:00
Merge pull request #226 from petoem/indev
Add ability to pause and resume audio thats being played
This commit is contained in:
@@ -6,23 +6,23 @@ exports.__esModule = true;
|
|||||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||||
|
|
||||||
var TokenCacher = (function () {
|
var TokenCacher = (function () {
|
||||||
function TokenCacher() {
|
function TokenCacher() {
|
||||||
_classCallCheck(this, TokenCacher);
|
_classCallCheck(this, TokenCacher);
|
||||||
}
|
}
|
||||||
|
|
||||||
TokenCacher.prototype.setToken = function setToken() {};
|
TokenCacher.prototype.setToken = function setToken() {};
|
||||||
|
|
||||||
TokenCacher.prototype.save = function save() {};
|
TokenCacher.prototype.save = function save() {};
|
||||||
|
|
||||||
TokenCacher.prototype.getToken = function getToken() {
|
TokenCacher.prototype.getToken = function getToken() {
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
TokenCacher.prototype.init = function init(ind) {
|
TokenCacher.prototype.init = function init(ind) {
|
||||||
this.done = true;
|
this.done = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
return TokenCacher;
|
return TokenCacher;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
exports["default"] = TokenCacher;
|
exports["default"] = TokenCacher;
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ var VoiceConnection = (function (_EventEmitter) {
|
|||||||
this.secret = null;
|
this.secret = null;
|
||||||
|
|
||||||
this.volume = new _VolumeTransformer2["default"]();
|
this.volume = new _VolumeTransformer2["default"]();
|
||||||
|
this.paused = false;
|
||||||
this.init();
|
this.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,6 +144,11 @@ var VoiceConnection = (function (_EventEmitter) {
|
|||||||
this.playingIntent = retStream;
|
this.playingIntent = retStream;
|
||||||
|
|
||||||
function send() {
|
function send() {
|
||||||
|
if (self.paused) {
|
||||||
|
startTime += Date.now() - (startTime + count * length);
|
||||||
|
setTimeout(send, length);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!self.playingIntent || !self.playing) {
|
if (!self.playingIntent || !self.playing) {
|
||||||
self.setSpeaking(false);
|
self.setSpeaking(false);
|
||||||
retStream.emit("end");
|
retStream.emit("end");
|
||||||
@@ -466,6 +472,18 @@ var VoiceConnection = (function (_EventEmitter) {
|
|||||||
this.lastVolume = undefined;
|
this.lastVolume = undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
VoiceConnection.prototype.pause = function pause() {
|
||||||
|
this.paused = true;
|
||||||
|
this.setSpeaking(false);
|
||||||
|
this.playingIntent.emit("pause");
|
||||||
|
};
|
||||||
|
|
||||||
|
VoiceConnection.prototype.resume = function resume() {
|
||||||
|
this.paused = false;
|
||||||
|
this.setSpeaking(true);
|
||||||
|
this.playingIntent.emit("resume");
|
||||||
|
};
|
||||||
|
|
||||||
return VoiceConnection;
|
return VoiceConnection;
|
||||||
})(_events2["default"]);
|
})(_events2["default"]);
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ export default class VoiceConnection extends EventEmitter {
|
|||||||
this.secret = null;
|
this.secret = null;
|
||||||
|
|
||||||
this.volume = new VolumeTransformer();
|
this.volume = new VolumeTransformer();
|
||||||
|
this.paused = false;
|
||||||
this.init();
|
this.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,6 +106,11 @@ export default class VoiceConnection extends EventEmitter {
|
|||||||
this.playingIntent = retStream;
|
this.playingIntent = retStream;
|
||||||
|
|
||||||
function send() {
|
function send() {
|
||||||
|
if(self.paused) {
|
||||||
|
startTime += Date.now() - (startTime + count * length);
|
||||||
|
setTimeout(send, length);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!self.playingIntent || !self.playing) {
|
if (!self.playingIntent || !self.playing) {
|
||||||
self.setSpeaking(false);
|
self.setSpeaking(false);
|
||||||
retStream.emit("end");
|
retStream.emit("end");
|
||||||
@@ -421,4 +427,16 @@ export default class VoiceConnection extends EventEmitter {
|
|||||||
this.setVolume(this.lastVolume);
|
this.setVolume(this.lastVolume);
|
||||||
this.lastVolume = undefined;
|
this.lastVolume = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pause() {
|
||||||
|
this.paused = true;
|
||||||
|
this.setSpeaking(false);
|
||||||
|
this.playingIntent.emit("pause");
|
||||||
|
}
|
||||||
|
|
||||||
|
resume() {
|
||||||
|
this.paused = false;
|
||||||
|
this.setSpeaking(true);
|
||||||
|
this.playingIntent.emit("resume");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user