PlayerController class

Inheritance

Constructors

PlayerController.new()

Properties

hashCode int
The hash code for this object.
no setteroverride
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
maxDuration int
Provides max duration of currently provided audio file.
no setter
onCompletion Stream<void>
A stream to get events when audio is finished playing.
no setter
onCurrentDurationChanged Stream<int>
A stream to get current duration. This stream will emit every 200 milliseconds. Emitted duration is in milliseconds.
no setter
onCurrentExtractedWaveformData Stream<List<double>>
A stream to get current extracted waveform data. This stream will emit list of doubles which are waveform data point.
no setter
onExtractionProgress Stream<double>
A stream to get current progress of waveform extraction.
no setter
onPlayerStateChanged Stream<PlayerState>
A stream to get current state of the player. This stream will emit event whenever there is change in the playerState.
no setter
overrideAudioSession bool
IOS only.
getter/setter pair
playerKey String
An unique key string associated with this player only
final
playerState PlayerState
Provides current state of the player
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
shouldClearLabels bool
no setter
shouldRefresh bool
no setter
updateFrequency UpdateFrequency
Rate of updating the reported current duration. Making it high will cause reporting duration at faster rate which also causes UI to look smoother.
getter/setter pair
waveformData List<double>
no setter

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
dispose() → void
Release any resources taken by this controller. Disposing this will stop the player and release resources from native.
override
extractWaveformData({required String path, int noOfSamples = 100}) Future<List<double>>
Extracts waveform data from provided audio file path. noOfSamples indicates number of extracted data points. This will determine number of bars in the waveform.
getDuration([DurationType? durationType]) Future<int>
Returns maximum duration for DurationType.max and current duration for DurationType.current for playing media. The duration is in milliseconds, if no duration is available -1 is returned.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
override
pauseAllPlayers() Future<bool>
Pauses all the players. Works similar to stopAllPlayer.
pausePlayer() Future<void>
Pauses currently playing audio.
preparePlayer({required String path, double? volume, bool shouldExtractWaveform = true, int noOfSamples = 100}) Future<void>
Calls platform to prepare player.
release() Future<void>
Releases the resources associated with this player.
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
seekTo(int progress) Future<void>
Moves the media to specified time(milliseconds) position.
setFinishMode({FinishMode finishMode = FinishMode.stop}) Future<void>
This method will be used to change behaviour of player when audio is finished playing.
setRate(double rate) Future<bool>
Sets playback rate for this player. Doesn't throw Exception. Returns false if it couldn't set the rate.
setRefresh(bool refresh) → void
Sets _shouldRefresh flag with provided boolean parameter.
setVolume(double volume) Future<bool>
Sets volume for this player. Doesn't throw Exception. Returns false if it couldn't set the volume.
startPlayer({bool forceRefresh = true}) Future<void>
A function to start the player to play/resume the audio.
stopAllPlayers() Future<bool>
Frees resources used by all players simultaneously.
stopPlayer() Future<void>
A function to stop player.
toString() String
A string representation of this object.
inherited

Operators

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