Skip to content

Commit

Permalink
Correct the recording docs example and add the sample to playing (#80)
Browse files Browse the repository at this point in the history
Co-authored-by: Shaun Lawrence <[email protected]>
Co-authored-by: Gerald Versluis <[email protected]>
  • Loading branch information
3 people authored Nov 28, 2023
1 parent 354ea28 commit 4801a27
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
19 changes: 19 additions & 0 deletions docs/audio-player.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@

The `AudioPlayer` class provides you with the ability to play audio files/streams in your .NET MAUI application. In order to create an `AudioPlayer` instance you can make use of the `CreatePlayer` method on the [`AudioManager`](../readme.md#audiomanager) class.

```csharp
public class AudioPlayerViewModel
{
readonly IAudioManager audioManager;

public AudioPlayerViewModel(IAudioManager audioManager)
{
this.audioManager = audioManager;
}

public async void PlayAudio()
{
var audioPlayer = audioManager.CreatePlayer(await FileSystem.OpenAppPackageFileAsync("ukelele.mp3"));

audioPlayer.Play();
}
}
```

## AudioPlayer API

Once you have created an `AudioPlayer` you can interact with it in the following ways:
Expand Down
8 changes: 4 additions & 4 deletions docs/audio-recorder.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ public class AudioRecorderViewModel
public AudioPlayerViewModel(IAudioManager audioManager)
{
this.audioManager = audioManager;
this.audioRecorder.CreateRecorder();
this.audioRecorder = audioManager.CreateRecorder();
}

public async void StartRecording()
public async Task StartRecording()
{
this.audioRecorder.StartAsync();
await this.audioRecorder.StartAsync();
}

public async void StopRecording()
public async Task StopRecording()
{
IAudioSource audioSource = await this.audioRecorder.StopAsync();

Expand Down

0 comments on commit 4801a27

Please sign in to comment.