FakePlaybackSession class

A PlaybackSession that never opens an audio device.

The playhead moves when a test calls advance, and not when a device consumes frames. This makes the timing exact instead of merely likely. FakeCaptureSession makes the same bargain for the frame stream.

This fake answers the same way as the real session at each point where a host can see the difference. position never goes past duration. It never moves backward, except on a seek. It answers after dispose and does not throw.

Implemented types

Constructors

FakePlaybackSession({required WaveformDocument document, int sampleRate = 44100})

Properties

document WaveformDocument
This field is mutable, like the rest of this fake. setDocument assigns it, and a test can also set it directly to stage an initial state.
getter/setter pairoverride-getter
documents List<WaveformDocument>
Every document that setDocument received, in order.
final
duration Duration
The length of the whole document, at the sample rate of the source.
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
isFinished bool
Whether the playhead reached the end of the document.
no setteroverride
isPlaying bool
no setteroverride
nextPlayError Object?
If a test sets this field, play throws it.
getter/setter pair
pauseCount int
getter/setter pair
playCount int
getter/setter pair
position Duration
The position of the playhead.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sampleRate int
The rate that duration and position use.
final
seeks List<Duration>
Every seek requested, in order.
final
underrunCount int
What underruns reports.
getter/setter pair
underruns int
Frames of silence that the session gave the device because the feeder was too slow.
no setteroverride

Methods

advance(Duration by) → void
Moves the playhead, as a device that consumes frames does. The playhead stops at the end.
dispose() Future<void>
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pause() Future<void>
override
play() Future<void>
override
seek(Duration position) Future<void>
Moves the playhead.
override
setDocument(WaveformDocument document) Future<void>
Swaps the document under an active session.
override
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited