react-native-audio-api
Advanced tools
Comparing version
@@ -17,4 +17,4 @@ "use strict"; | ||
} | ||
enqueueBuffer(buffer, isLastBuffer = false) { | ||
this.node.enqueueBuffer(buffer.buffer, isLastBuffer); | ||
enqueueBuffer(buffer, bufferId = 0, isLastBuffer = false) { | ||
this.node.enqueueBuffer(buffer.buffer, bufferId, isLastBuffer); | ||
} | ||
@@ -34,4 +34,15 @@ start(when = 0, offset = 0) { | ||
} | ||
// eslint-disable-next-line accessor-pairs | ||
set onPositionChanged(callback) { | ||
const subscription = this.audioEventEmitter.addAudioEventListener('positionChanged', callback); | ||
this.node.onPositionChanged = subscription.subscriptionId; | ||
} | ||
// eslint-disable-next-line accessor-pairs | ||
set onPositionChangedInterval(value) { | ||
this.node.onPositionChangedInterval = value; | ||
} | ||
} | ||
exports.default = AudioBufferQueueSourceNode; | ||
//# sourceMappingURL=AudioBufferQueueSourceNode.js.map |
@@ -12,4 +12,4 @@ "use strict"; | ||
} | ||
enqueueBuffer(buffer, isLastBuffer = false) { | ||
this.node.enqueueBuffer(buffer.buffer, isLastBuffer); | ||
enqueueBuffer(buffer, bufferId = 0, isLastBuffer = false) { | ||
this.node.enqueueBuffer(buffer.buffer, bufferId, isLastBuffer); | ||
} | ||
@@ -29,3 +29,14 @@ start(when = 0, offset = 0) { | ||
} | ||
// eslint-disable-next-line accessor-pairs | ||
set onPositionChanged(callback) { | ||
const subscription = this.audioEventEmitter.addAudioEventListener('positionChanged', callback); | ||
this.node.onPositionChanged = subscription.subscriptionId; | ||
} | ||
// eslint-disable-next-line accessor-pairs | ||
set onPositionChangedInterval(value) { | ||
this.node.onPositionChangedInterval = value; | ||
} | ||
} | ||
//# sourceMappingURL=AudioBufferQueueSourceNode.js.map |
@@ -6,2 +6,3 @@ import { IAudioBufferQueueSourceNode } from '../interfaces'; | ||
import AudioParam from './AudioParam'; | ||
import { OnPositionChangedEventType } from '../events/types'; | ||
export default class AudioBufferQueueSourceNode extends AudioScheduledSourceNode { | ||
@@ -11,5 +12,7 @@ readonly playbackRate: AudioParam; | ||
constructor(context: BaseAudioContext, node: IAudioBufferQueueSourceNode); | ||
enqueueBuffer(buffer: AudioBuffer, isLastBuffer?: boolean): void; | ||
enqueueBuffer(buffer: AudioBuffer, bufferId?: number, isLastBuffer?: boolean): void; | ||
start(when?: number, offset?: number): void; | ||
set onPositionChanged(callback: (event: OnPositionChangedEventType) => void); | ||
set onPositionChangedInterval(value: number); | ||
} | ||
//# sourceMappingURL=AudioBufferQueueSourceNode.d.ts.map |
import AudioNode from './AudioNode'; | ||
import { EventTypeWithValueAndState } from '../events/types'; | ||
import { OnEndedEventType } from '../events/types'; | ||
import { AudioEventEmitter } from '../events'; | ||
export default class AudioScheduledSourceNode extends AudioNode { | ||
protected hasBeenStarted: boolean; | ||
private readonly audioEventEmitter; | ||
protected readonly audioEventEmitter: AudioEventEmitter; | ||
start(when?: number): void; | ||
stop(when?: number): void; | ||
set onended(callback: (event: EventTypeWithValueAndState) => void); | ||
set onended(callback: (event: OnEndedEventType) => void); | ||
} | ||
//# sourceMappingURL=AudioScheduledSourceNode.d.ts.map |
@@ -7,6 +7,11 @@ import AudioBuffer from '../core/AudioBuffer'; | ||
} | ||
export interface EventTypeWithValueAndState { | ||
export interface OnEndedEventType { | ||
value: number; | ||
state: 'stopped' | 'ended'; | ||
bufferId: number | undefined; | ||
} | ||
export interface OnPositionChangedEventType { | ||
value: number; | ||
bufferId: number; | ||
} | ||
interface OnInterruptionEventType { | ||
@@ -42,4 +47,5 @@ type: 'ended' | 'began'; | ||
interface AudioAPIEvents { | ||
ended: EventTypeWithValueAndState; | ||
ended: OnEndedEventType; | ||
audioReady: OnAudioReadyEventType; | ||
positionChanged: OnPositionChangedEventType; | ||
audioError: EventEmptyType; | ||
@@ -46,0 +52,0 @@ systemStateChanged: EventEmptyType; |
@@ -79,4 +79,6 @@ import { WindowType, ContextState, OscillatorType, BiquadFilterType, ChannelCountMode, ChannelInterpretation } from './types'; | ||
playbackRate: IAudioParam; | ||
enqueueBuffer: (audioBuffer: IAudioBuffer, isLastBuffer: boolean) => void; | ||
enqueueBuffer: (audioBuffer: IAudioBuffer, bufferId: number, isLastBuffer: boolean) => void; | ||
start: (when?: number, offset?: number) => void; | ||
onPositionChanged: string; | ||
onPositionChangedInterval: number; | ||
} | ||
@@ -83,0 +85,0 @@ export interface IAudioBuffer { |
{ | ||
"name": "react-native-audio-api", | ||
"version": "0.6.1-rc.2", | ||
"version": "0.6.1-rc.3", | ||
"description": "react-native-audio-api provides system for controlling audio in React Native environment compatible with Web Audio API specification", | ||
@@ -5,0 +5,0 @@ "bin": { |
@@ -7,2 +7,3 @@ import { IAudioBufferQueueSourceNode } from '../interfaces'; | ||
import { InvalidStateError, RangeError } from '../errors'; | ||
import { OnPositionChangedEventType } from '../events/types'; | ||
@@ -22,2 +23,3 @@ export default class AudioBufferQueueSourceNode extends AudioScheduledSourceNode { | ||
buffer: AudioBuffer, | ||
bufferId: number = 0, | ||
isLastBuffer: boolean = false | ||
@@ -27,2 +29,3 @@ ): void { | ||
buffer.buffer, | ||
bufferId, | ||
isLastBuffer | ||
@@ -52,2 +55,21 @@ ); | ||
} | ||
// eslint-disable-next-line accessor-pairs | ||
public set onPositionChanged( | ||
callback: (event: OnPositionChangedEventType) => void | ||
) { | ||
const subscription = this.audioEventEmitter.addAudioEventListener( | ||
'positionChanged', | ||
callback | ||
); | ||
(this.node as IAudioBufferQueueSourceNode).onPositionChanged = | ||
subscription.subscriptionId; | ||
} | ||
// eslint-disable-next-line accessor-pairs | ||
public set onPositionChangedInterval(value: number) { | ||
(this.node as IAudioBufferQueueSourceNode).onPositionChangedInterval = | ||
value; | ||
} | ||
} |
import { IAudioScheduledSourceNode } from '../interfaces'; | ||
import AudioNode from './AudioNode'; | ||
import { InvalidStateError, RangeError } from '../errors'; | ||
import { EventTypeWithValueAndState } from '../events/types'; | ||
import { OnEndedEventType } from '../events/types'; | ||
import { AudioEventEmitter } from '../events'; | ||
@@ -9,3 +9,3 @@ | ||
protected hasBeenStarted: boolean = false; | ||
private readonly audioEventEmitter = new AudioEventEmitter( | ||
protected readonly audioEventEmitter = new AudioEventEmitter( | ||
global.AudioEventEmitter | ||
@@ -46,3 +46,3 @@ ); | ||
// eslint-disable-next-line accessor-pairs | ||
public set onended(callback: (event: EventTypeWithValueAndState) => void) { | ||
public set onended(callback: (event: OnEndedEventType) => void) { | ||
const subscription = this.audioEventEmitter.addAudioEventListener( | ||
@@ -49,0 +49,0 @@ 'ended', |
@@ -9,7 +9,13 @@ import AudioBuffer from '../core/AudioBuffer'; | ||
export interface EventTypeWithValueAndState { | ||
export interface OnEndedEventType { | ||
value: number; | ||
state: 'stopped' | 'ended'; | ||
bufferId: number | undefined; | ||
} | ||
export interface OnPositionChangedEventType { | ||
value: number; | ||
bufferId: number; | ||
} | ||
interface OnInterruptionEventType { | ||
@@ -49,4 +55,5 @@ type: 'ended' | 'began'; | ||
interface AudioAPIEvents { | ||
ended: EventTypeWithValueAndState; | ||
ended: OnEndedEventType; | ||
audioReady: OnAudioReadyEventType; | ||
positionChanged: OnPositionChangedEventType; | ||
audioError: EventEmptyType; // to change | ||
@@ -53,0 +60,0 @@ systemStateChanged: EventEmptyType; // to change |
@@ -117,4 +117,13 @@ import { | ||
enqueueBuffer: (audioBuffer: IAudioBuffer, isLastBuffer: boolean) => void; | ||
enqueueBuffer: ( | ||
audioBuffer: IAudioBuffer, | ||
bufferId: number, | ||
isLastBuffer: boolean | ||
) => void; | ||
start: (when?: number, offset?: number) => void; | ||
// passing subscriptionId(uint_64 in cpp, string in js) to the cpp | ||
onPositionChanged: string; | ||
// set how often the onPositionChanged event is called | ||
onPositionChangedInterval: number; | ||
} | ||
@@ -121,0 +130,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
5391632
0.12%10716
0.59%