react-native-audio-api
Version:
react-native-audio-api provides system for controlling audio in React Native environment compatible with Web Audio API specification
32 lines (30 loc) • 956 B
JavaScript
;
import AudioNode from "./AudioNode.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);
}
// eslint-disable-next-line accessor-pairs
set onended(callback) {
this.node.onended = callback;
}
}
//# sourceMappingURL=AudioScheduledSourceNode.js.map