Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct the recording docs example and add the sample to playing #80

Merged
merged 2 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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