PlaybackDevice class final
A class for managing audio playback devices.
The PlaybackDevice
class provides methods for controlling audio playback,
such as starting and stopping playback, resetting the internal buffer,
and pushing audio buffers to the device. It integrates with the native
audio system to ensure efficient playback.
Example Usage:
final context = AudioContext();
final devices = context.playbackDeviceInfos;
final device = devices.first; // Select the first playback device.
final config = PlaybackConfig.withAudioFormat(
AudioFormat(
sampleFormat: PcmFormat.s16,
channels: 2,
sampleRate: 44100,
),
);
final playbackDevice = PlaybackDevice(
context: context,
deviceInfo: device,
config: config,
);
playbackDevice.start();
playbackDevice.pushBuffer(
buffer: Float32List.fromList([0.0, 0.5, -0.5, 1.0]),
framesCount: 2,
);
playbackDevice.stop();
playbackDevice.dispose();
Constructors
- PlaybackDevice.new({required AudioContext context, required DeviceId? id, required PlaybackConfig config})
-
Creates a new playback device instance.
factory
Properties
- config → PlaybackConfig
-
The playback configuration for this device.
final
- context → AudioContext
-
The AudioContext that manages this device.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- id → DeviceId?
-
Information about the playback device.
final
- isFinalized → bool
-
Indicates whether the resource has been disposed.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- state → DeviceState
-
Gets the current state of the playback device.
no setter
Methods
-
dispose(
) → void -
Releases the resource manually.
inherited
-
ensureIsNotFinalized(
) → Pointer< Void> -
Ensures that the resource is valid and not finalized.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pushBuffer<
T extends TypedData> ({required TypedData buffer, required int framesCount}) → void - Pushes an audio buffer to the playback device.
-
releaseResource(
) → void - Defines how the native resource should be released.
-
resetBuffer(
) → void - Resets the internal buffer of the playback device.
-
start(
) → void - Starts audio playback.
-
stop(
) → void - Stops audio playback.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited