Skip to content

Commit 931337e

Browse files
authored
Improve READMEs (#174)
1 parent f28f968 commit 931337e

File tree

4 files changed

+64
-38
lines changed

4 files changed

+64
-38
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ builder.AddAudio();
2323
```
2424

2525
> [!NOTE]
26-
> You can also customize the shared settings for both audio [playback](./docs/audio-player.md#configure-the-playback-options) and [recording](./docs/audio-recorder.md#configure-the-recording-options).
26+
> You can also customize the shared settings for audio [playback](./docs/audio-player.md#configure-the-playback-options), [recording](./docs/audio-recorder.md#configure-the-recording-options) and [streaming](./docs/audio-streamer.md#configure-streaming-options).
2727
2828
You can then enable your classes to depend on `IAudioManager` as per the following example.
2929

@@ -37,7 +37,7 @@ public class AudioPlayerViewModel
3737
this.audioManager = audioManager;
3838
}
3939

40-
public async void PlayAudio()
40+
public async Task PlayAudioAsync()
4141
{
4242
var audioPlayer = audioManager.CreatePlayer(await FileSystem.OpenAppPackageFileAsync("ukelele.mp3"));
4343

@@ -53,7 +53,7 @@ Alternatively if you want to skip using the dependency injection approach you ca
5353
```csharp
5454
public class AudioPlayerViewModel
5555
{
56-
public async void PlayAudio()
56+
public async Task PlayAudioAsync()
5757
{
5858
var audioPlayer = AudioManager.Current.CreatePlayer(await FileSystem.OpenAppPackageFileAsync("ukelele.mp3"));
5959

docs/audio-recorder.md

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,6 @@
22

33
The `AudioRecorder` class provides you with the ability to record audio from a microphone in your .NET MAUI application to a file on disk. In order to create an `AudioRecorder` instance you can make use of the `CreateRecorder` method on the [`AudioManager`](../readme.md#audiomanager) class.
44

5-
> [!NOTE]
6-
> If you want to record in the background on iOS, you will need to add a key to the `Info.plist` file like show below.
7-
> `<key>UIBackgroundModes</key>`
8-
> `<array>`
9-
> ` <string>audio</string>`
10-
> `</array>`
11-
125
```csharp
136
public class AudioRecorderViewModel
147
{
@@ -21,14 +14,14 @@ public class AudioRecorderViewModel
2114
this.audioRecorder = audioManager.CreateRecorder();
2215
}
2316

24-
public async Task StartRecording()
17+
public async Task StartRecordingAsync()
2518
{
26-
await this.audioRecorder.StartAsync();
19+
await audioRecorder.StartAsync();
2720
}
2821

29-
public async Task StopRecording()
22+
public async Task StopRecordingAsync()
3023
{
31-
IAudioSource audioSource = await this.audioRecorder.StopAsync();
24+
IAudioSource audioSource = await audioRecorder.StopAsync();
3225

3326
// You can use the audioSource to play the file or save it somewhere in your application.
3427
}
@@ -102,46 +95,62 @@ The *AndroidManifest.xml* file will need to be modified to include the following
10295
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
10396
```
10497

105-
For a full example of this change check out our [*AndroidManifest.xml*](https://github.com/jfversluis/Plugin.Maui.Audio/blob/main/samples/Plugin.Maui.Audio.Sample/Platforms/Android/AndroidManifest.xml) file.
98+
For a full example of this change check out our [**AndroidManifest.xml**](../samples/Plugin.Maui.Audio.Sample/Platforms/Android/AndroidManifest.xml) file.
10699

107100
### iOS
108101

109-
The *Info.plist* file will need to be modified to include the following 2 entries inside the `dict` tag.
102+
The **Info.plist** file will need to be modified to include the following 2 entries inside the `dict` tag.
110103

111104
```xml
112105
<key>NSMicrophoneUsageDescription</key>
113106
<string>The [app name] wants to use your microphone to record audio.</string>
114107
```
115108

109+
> [!NOTE]
110+
> If you want to record in the background on iOS, you will need to add a key to the **Info.plist** file like show below. \
111+
> \
112+
> `<key>UIBackgroundModes</key>` \
113+
> `<array>` \
114+
> ` <string>audio</string>` \
115+
> `</array>`
116+
116117
**Replacing [app name] with your application name.**
117118

118-
For a full example of this change check out our [*Info.plist*](https://github.com/jfversluis/Plugin.Maui.Audio/blob/main/samples/Plugin.Maui.Audio.Sample/Platforms/iOS/Info.plist) file.
119+
For a full example of this change check out our [**Info.plist**](../samples/Plugin.Maui.Audio.Sample/Platforms/iOS/Info.plist) file.
119120

120121
### MacCatalyst
121122

122123
This change is identical to the iOS section but for explicitness:
123124

124-
The *Info.plist* file will need to be modified to include the following 2 entries inside the `dict` tag.
125+
The **Info.plist** file will need to be modified to include the following 2 entries inside the `dict` tag.
125126

126127
```xml
127128
<key>NSMicrophoneUsageDescription</key>
128129
<string>The [app name] wants to use your microphone to record audio.</string>
129130
```
130131

132+
> [!NOTE]
133+
> If you distribute your app to others, you will need to declare an [entitlement](https://learn.microsoft.com/dotnet/maui/ios/entitlements) in order to be able to access the microphone. Add a key to the `Entitlements.plist` file like show below. \
134+
> \
135+
> `<key>com.apple.security.device.audio-input</key>` \
136+
> `<true/>` \
137+
> \
138+
> For a full example of this change check out our [**Entitlements.plist**](../samples/Plugin.Maui.Audio.Sample/Platforms/MacCatalyst/Entitlements.plist) file.
139+
131140
**Replacing [app name] with your application name.**
132141

133-
For a full example of this change check out our [*Info.plist*](https://github.com/jfversluis/Plugin.Maui.Audio/blob/main/samples/Plugin.Maui.Audio.Sample/Platforms/MacCatalyst/Info.plist) file.
142+
For a full example of this change check out our [**Info.plist**](../samples/Plugin.Maui.Audio.Sample/Platforms/MacCatalyst/Info.plist) file.
134143

135144
### Windows
136145

137-
The *Package.appxmanifest* file will need to be modified to include the following entry inside the `Capabilities` tag.
146+
The **Package.appxmanifest** file will need to be modified to include the following entry inside the `Capabilities` tag.
138147

139148
```xml
140149
<DeviceCapability Name="microphone"/>
141150
```
142151

143-
For a full example of this change check out our [*Package.appxmanifest*](https://github.com/jfversluis/Plugin.Maui.Audio/blob/main/samples/Plugin.Maui.Audio.Sample/Platforms/Windows/Package.appxmanifest) file.
152+
For a full example of this change check out our [**Package.appxmanifest**](../samples/Plugin.Maui.Audio.Sample/Platforms/Windows/Package.appxmanifest) file.
144153

145154
## Sample
146155

147-
For a concrete example of recording audio in a .NET MAUI application check out our sample application and specifically the [`AudioRecorderPageViewModel`](https://github.com/jfversluis/Plugin.Maui.Audio/blob/main/samples/Plugin.Maui.Audio.Sample/ViewModels/AudioRecorderPageViewModel.cs) class.
156+
For a concrete example of recording audio in a .NET MAUI application check out our sample application and specifically the [`AudioRecorderPageViewModel`](../samples/Plugin.Maui.Audio.Sample/ViewModels/AudioRecorderPageViewModel.cs) class.

docs/audio-streamer.md

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,6 @@
22

33
The `AudioStreamer` class gives you the ability to stream audio from a microphone in your .NET MAUI application through an event handler. The `AudioStreamer` works pretty much the same as the recorder `AudioRecorder`, except that it provides raw audio data instead of a file. In order to create an `AudioStreamer` instance you can make use of the `CreateStreamer` method on the [`AudioManager`](../readme.md#audiomanager) class.
44

5-
> [!NOTE]
6-
> If you want to stream in the background on iOS, you will need to add a key to the `Info.plist` file like shown below.
7-
> `<key>UIBackgroundModes</key>`
8-
> `<array>`
9-
> ` <string>audio</string>`
10-
> `</array>`
11-
125
```csharp
136
public class AudioStreamerViewModel
147
{
@@ -22,12 +15,12 @@ public class AudioStreamerViewModel
2215
this.audioStreamer.OnAudioCaptured += OnAudioStreamerCapturedData;
2316
}
2417

25-
public async Task StartStreaming()
18+
public async Task StartStreamingAsync()
2619
{
2720
await audioStreamer.StartAsync();
2821
}
2922

30-
public async Task StopStreaming()
23+
public async Task StopStreamingAsync()
3124
{
3225
await audioStreamer.StopAsync();
3326
}
@@ -124,45 +117,61 @@ The *AndroidManifest.xml* file will need to be modified to include the following
124117
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
125118
```
126119

127-
For a full example of this change check out our [*AndroidManifest.xml*](https://github.com/jfversluis/Plugin.Maui.Audio/blob/main/samples/Plugin.Maui.Audio.Sample/Platforms/Android/AndroidManifest.xml) file.
120+
For a full example of this change check out our [**AndroidManifest.xml**](../samples/Plugin.Maui.Audio.Sample/Platforms/Android/AndroidManifest.xml) file.
128121

129122
### iOS
130123

131-
The *Info.plist* file will need to be modified to include the following 2 entries inside the `dict` tag.
124+
The **Info.plist** file will need to be modified to include the following 2 entries inside the `dict` tag.
132125

133126
```xml
134127
<key>NSMicrophoneUsageDescription</key>
135128
<string>The [app name] wants to use your microphone to record audio.</string>
136129
```
137130

131+
> [!NOTE]
132+
> If you want to stream in the background on iOS, you will need to add a key to the **Info.plist** file like shown below. \
133+
> \
134+
> `<key>UIBackgroundModes</key>` \
135+
> `<array>` \
136+
> ` <string>audio</string>` \
137+
> `</array>`
138+
138139
**Replacing [app name] with your application name.**
139140

140-
For a full example of this change check out our [*Info.plist*](https://github.com/jfversluis/Plugin.Maui.Audio/blob/main/samples/Plugin.Maui.Audio.Sample/Platforms/iOS/Info.plist) file.
141+
For a full example of this change check out our [**Info.plist**](../samples/Plugin.Maui.Audio.Sample/Platforms/iOS/Info.plist) file.
141142

142143
### MacCatalyst
143144

144145
This change is identical to the iOS section but for explicitness:
145146

146-
The *Info.plist* file will need to be modified to include the following 2 entries inside the `dict` tag.
147+
The **Info.plist** file will need to be modified to include the following 2 entries inside the `dict` tag.
147148

148149
```xml
149150
<key>NSMicrophoneUsageDescription</key>
150151
<string>The [app name] wants to use your microphone to record audio.</string>
151152
```
152153

154+
> [!NOTE]
155+
> If you distribute your app to others, you will need to declare an [entitlement](https://learn.microsoft.com/dotnet/maui/ios/entitlements) in order to be able to access the microphone. Add a key to the `Entitlements.plist` file like show below. \
156+
> \
157+
> `<key>com.apple.security.device.audio-input</key>` \
158+
> `<true/>` \
159+
> \
160+
> For a full example of this change check out our [**Entitlements.plist**](../samples/Plugin.Maui.Audio.Sample/Platforms/MacCatalyst/Entitlements.plist) file.
161+
153162
**Replacing [app name] with your application name.**
154163

155-
For a full example of this change check out our [*Info.plist*](https://github.com/jfversluis/Plugin.Maui.Audio/blob/main/samples/Plugin.Maui.Audio.Sample/Platforms/MacCatalyst/Info.plist) file.
164+
For a full example of this change check out our [**Info.plist**](https://github.com/jfversluis/Plugin.Maui.Audio/blob/main/samples/Plugin.Maui.Audio.Sample/Platforms/MacCatalyst/Info.plist) file.
156165

157166
### Windows
158167

159-
The *Package.appxmanifest* file will need to be modified to include the following entry inside the `Capabilities` tag.
168+
The **Package.appxmanifest** file will need to be modified to include the following entry inside the `Capabilities` tag.
160169

161170
```xml
162171
<DeviceCapability Name="microphone"/>
163172
```
164173

165-
For a full example of this change check out our [*Package.appxmanifest*](https://github.com/jfversluis/Plugin.Maui.Audio/blob/main/samples/Plugin.Maui.Audio.Sample/Platforms/Windows/Package.appxmanifest) file.
174+
For a full example of this change check out our [**Package.appxmanifest**](https://github.com/jfversluis/Plugin.Maui.Audio/blob/main/samples/Plugin.Maui.Audio.Sample/Platforms/Windows/Package.appxmanifest) file.
166175

167176
## Listening and Manipulating audio
168177

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>com.apple.security.device.audio-input</key>
6+
<true/>
7+
</dict>
8+
</plist>

0 commit comments

Comments
 (0)