# Monitoring

## Overview

If you are building your own widget you might want to display a progress bar that displays the current recording or playback position.

The easiest way to do this is via the `SoundPlayerUI/SoundRecordingUI` widgets but if you want to write your own then you will want to use the `dispositionStream` with a StreamBuilder.

To use a `dispositionStream` you need to create an `SoundPlayer or SoundRecorder` instance.

```dart
class MyWidgetState
{
	/// use .noUI() as you are going to build your own UI.
	var player = SoundPlayer().noUI();

	void initState()
	{
		super.initState();

	}

	void dispose()
	{
		player.release();
		super.dispose();
	}

	 Widget build() {
    	 return Row(children:
		 	[Button('Play' onTap: onPlay)
		 		, StreamBuilder<PlaybackDisposition>(
					stream: player.dispositionStream,
					initialData: PlaybackDisposition.zero(),
					builder: (context, snapshot) {
					var disposition = snapshot.data;
					return Slider(
						max: disposition.duration.inMilliseconds.toDouble(),
						value: disposition.position.inMilliseconds.toDouble(),
						onChanged: (value) =>
							player._seek(Duration(milliseconds: value.toInt())),
					);
            		}
				))
			]);
      },
    ));

  /// you would wire this to a button
  void onPlay()
  {
	  player.play(Track.fromFile('sample.aac'));
  }

   /// you would wire this to a pause button
  void onPause()
  {
	  player.pause();
  }

   /// you would wire this to a button
  void onResume()
  {
	  player.resume();
  }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://bsutton.gitbook.io/sounds/api/monitoring.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
