onProgress
onProgress property
The stream side of the onProgress Controller
This is a stream on which FlutterSound will post the player progression. You may listen to this Stream to have feedback on the current playback.
If you want to receive events on this stream, do not forget to call also setSubscriptionDuration(). If you do not call this verb, you will not receive anything because the default value is 0ms which means not events!
PlaybackDisposition has two fields :
- Duration duration (the total playback duration)
- Duration position (the current playback position)
Example
_playerSubscription = myPlayer.onProgress.listen((e)
{
Duration maxDuration = e.duration;
Duration position = e.position;
...
}
await _mPlayer.setSubscriptionDuration(
Duration(milliseconds: 100, // an event each 100 ms
);
See also
- setSubscriptionDuration()
- You may look to this small guide if you need precisions about this.
Implementation
Stream<PlaybackDisposition>? get onProgress =>
_playerController != null ? _playerController!.stream : null;