react-native-audio-api
Version:
react-native-audio-api provides system for controlling audio in React Native environment compatible with Web Audio API specification
34 lines (33 loc) • 1.01 kB
JavaScript
;
import AudioNode from "./AudioNode.web.js";
import { RangeError, InvalidStateError } from "../errors/index.js";
export default class AudioScheduledSourceNode extends AudioNode {
hasBeenStarted = false;
start(when = 0) {
if (when < 0) {
throw new RangeError(`when must be a finite non-negative number: ${when}`);
}
if (this.hasBeenStarted) {
throw new InvalidStateError('Cannot call start more than once');
}
this.hasBeenStarted = true;
this.node.start(when);
}
stop(when = 0) {
if (when < 0) {
throw new RangeError(`when must be a finite non-negative number: ${when}`);
}
if (!this.hasBeenStarted) {
throw new InvalidStateError('Cannot call stop without calling start first');
}
this.node.stop(when);
}
get onEnded() {
return this.onEndedCallback;
}
set onEnded(callback) {
this.node.onended = callback;
this.onEndedCallback = callback;
}
}
//# sourceMappingURL=AudioScheduledSourceNode.web.js.map