-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Recording options and Bug Fixes (#108)
* Add support for AudioRecording Options * delete raw file on android after recording stopped and throw exception on ios * ensure recordings and other audio can be played on iOS after a recording session. EnableRate on iOS to ensure speed value can be changed. * fixes #32 : load audio from files on android * fix navigation issue in setter * Try fix CI * Revert "Try fix CI" This reverts commit 10cda9b. * Update Plugin.Maui.Audio.Sample.csproj Co-authored-by: Gerald Versluis <gerald@verslu.is> * Update AudioRecorderPageViewModel.cs Co-authored-by: Gerald Versluis <gerald@verslu.is> * Update AudioPlayer.macios.cs Co-authored-by: Gerald Versluis <gerald@verslu.is> * Update AudioPlayer.macios.cs Co-authored-by: Gerald Versluis <gerald@verslu.is> * Update AudioRecordingOptions.cs Co-authored-by: Gerald Versluis <gerald@verslu.is> * Update AudioRecordingOptions.cs Co-authored-by: Gerald Versluis <gerald@verslu.is> * Update AudioRecordingOptions.cs Co-authored-by: Gerald Versluis <gerald@verslu.is> * Update AudioRecordingOptions.cs Co-authored-by: Gerald Versluis <gerald@verslu.is> * Update AudioRecordingOptions.cs Co-authored-by: Gerald Versluis <gerald@verslu.is> * support for windows recording options * trace error message * bug fixes on windows & support of Alac & Flac * reset csproj * replace observable collections with lists * fix error on ios and final merges * remove redundant code * Apply suggestions from code review --------- Co-authored-by: Gerald Versluis <gerald.versluis@microsoft.com> Co-authored-by: Gerald Versluis <gerald@verslu.is>
- Loading branch information
1 parent
b343328
commit d88f00d
Showing
23 changed files
with
744 additions
and
334 deletions.
There are no files selected for viewing
90 changes: 52 additions & 38 deletions
90
samples/Plugin.Maui.Audio.Sample/Pages/AudioRecorderPage.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,55 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:viewmodels="clr-namespace:Plugin.Maui.Audio.Sample.ViewModels" | ||
xmlns:converters="clr-namespace:Plugin.Maui.Audio.Sample.Converters" | ||
x:Class="Plugin.Maui.Audio.Sample.Pages.AudioRecorderPage" | ||
Title="Audio Recorder" | ||
x:DataType="viewmodels:AudioRecorderPageViewModel"> | ||
|
||
<ContentPage.Resources> | ||
<converters:SecondsToStringConverter x:Key="SecondsToStringConverter" /> | ||
</ContentPage.Resources> | ||
|
||
<Grid> | ||
<VerticalStackLayout | ||
HorizontalOptions="Center" | ||
VerticalOptions="Center"> | ||
|
||
<Button | ||
Text="Start" | ||
Command="{Binding StartCommand}" /> | ||
|
||
<Button | ||
Text="Stop" | ||
Command="{Binding StopCommand}" /> | ||
|
||
<Button | ||
Text="Play" | ||
Command="{Binding PlayCommand}" /> | ||
|
||
<Button | ||
Text="StopPlay" | ||
Command="{Binding StopPlayCommand}" /> | ||
|
||
<Label | ||
Text="{Binding RecordingTime, Converter={StaticResource SecondsToStringConverter}}" /> | ||
</VerticalStackLayout> | ||
|
||
</Grid> | ||
|
||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:viewmodels="clr-namespace:Plugin.Maui.Audio.Sample.ViewModels" | ||
xmlns:converters="clr-namespace:Plugin.Maui.Audio.Sample.Converters" | ||
x:Class="Plugin.Maui.Audio.Sample.Pages.AudioRecorderPage" | ||
Title="Audio Recorder" | ||
x:DataType="viewmodels:AudioRecorderPageViewModel"> | ||
|
||
<ContentPage.Resources> | ||
<converters:SecondsToStringConverter x:Key="SecondsToStringConverter" /> | ||
</ContentPage.Resources> | ||
|
||
<ScrollView> | ||
<VerticalStackLayout HorizontalOptions="Center" | ||
Spacing="10" | ||
VerticalOptions="Center"> | ||
|
||
<Picker Title="Select Sample Rate" | ||
ItemsSource="{Binding SampleRates}" | ||
SelectedItem="{Binding SelectedSampleRate, Mode=TwoWay}" /> | ||
|
||
<Picker Title="Select Channels" | ||
ItemsSource="{Binding ChannelTypes}" | ||
SelectedItem="{Binding SelectedChannelType, Mode=TwoWay}" | ||
ItemDisplayBinding="{Binding Name}" /> | ||
|
||
<Picker Title="Select Bit Depth" | ||
ItemsSource="{Binding BitDepths}" | ||
SelectedItem="{Binding SelectedBitDepth, Mode=TwoWay}" | ||
ItemDisplayBinding="{Binding Name}" /> | ||
|
||
<Picker Title="Select Encoding" | ||
ItemsSource="{Binding EncodingOptions}" | ||
SelectedItem="{Binding SelectedEconding, Mode=TwoWay}" | ||
ItemDisplayBinding="{Binding Name}" /> | ||
|
||
<Button Text="Start" | ||
Command="{Binding StartCommand}" /> | ||
|
||
<Button Text="Stop" | ||
Command="{Binding StopCommand}" /> | ||
|
||
<Button Text="Play" | ||
Command="{Binding PlayCommand}" /> | ||
|
||
<Button Text="StopPlay" | ||
Command="{Binding StopPlayCommand}" /> | ||
|
||
<Label Text="{Binding RecordingTime, Converter={StaticResource SecondsToStringConverter}}" /> | ||
</VerticalStackLayout> | ||
|
||
</ScrollView> | ||
|
||
</ContentPage> |
105 changes: 57 additions & 48 deletions
105
samples/Plugin.Maui.Audio.Sample/Pages/MyLibraryPage.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,66 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:viewmodels="clr-namespace:Plugin.Maui.Audio.Sample.ViewModels" | ||
x:Class="Plugin.Maui.Audio.Sample.Pages.MyLibraryPage" | ||
Title="My Library" | ||
x:DataType="viewmodels:MyLibraryPageViewModel"> | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:viewmodels="clr-namespace:Plugin.Maui.Audio.Sample.ViewModels" | ||
x:Class="Plugin.Maui.Audio.Sample.Pages.MyLibraryPage" | ||
Title="My Library" | ||
x:Name="Page" | ||
x:DataType="viewmodels:MyLibraryPageViewModel"> | ||
|
||
<ContentPage.Resources> | ||
<Style x:Key="border_gallery_card" TargetType="Border"> | ||
<Setter Property="Stroke" Value="{AppThemeBinding Light={StaticResource Gray200}, Dark={StaticResource Gray950}}" /> | ||
<Setter Property="BackgroundColor" Value="{AppThemeBinding Light={StaticResource White}, Dark={StaticResource Gray950}}" /> | ||
<Setter Property="Padding" Value="16" /> | ||
<Setter Property="StrokeThickness" Value="1" /> | ||
<Setter Property="StrokeShape" Value="RoundRectangle 8" /> | ||
</Style> | ||
</ContentPage.Resources> | ||
<ContentPage.Resources> | ||
<Style x:Key="border_gallery_card" | ||
TargetType="Border"> | ||
<Setter Property="Stroke" | ||
Value="{AppThemeBinding Light={StaticResource Gray200}, Dark={StaticResource Gray950}}" /> | ||
<Setter Property="BackgroundColor" | ||
Value="{AppThemeBinding Light={StaticResource White}, Dark={StaticResource Gray950}}" /> | ||
<Setter Property="Padding" | ||
Value="16" /> | ||
<Setter Property="StrokeThickness" | ||
Value="1" /> | ||
<Setter Property="StrokeShape" | ||
Value="RoundRectangle 8" /> | ||
</Style> | ||
</ContentPage.Resources> | ||
|
||
<Grid | ||
RowDefinitions="60,*"> | ||
<Grid RowDefinitions="60,*"> | ||
|
||
<Button | ||
Text="Create Recording" | ||
HorizontalOptions="End" | ||
Margin="10" | ||
Command="{Binding AddRecordingCommand}" /> | ||
<Button Text="Create Recording" | ||
HorizontalOptions="End" | ||
Margin="10" | ||
Command="{Binding AddRecordingCommand}" /> | ||
|
||
<CollectionView ItemsSource="{Binding Music}" | ||
Grid.Row="1" | ||
SelectionMode="Single" | ||
SelectedItem="{Binding SelectedMusicItem}"> | ||
<CollectionView.ItemTemplate> | ||
<DataTemplate x:DataType="viewmodels:MusicItemViewModel"> | ||
<Border Style="{StaticResource border_gallery_card}"> | ||
<Grid ColumnDefinitions="75,*" | ||
RowDefinitions="3*,2*" | ||
ColumnSpacing="8"> | ||
<!-- Placeholder for imagery --> | ||
<Image BackgroundColor="{AppThemeBinding Light={StaticResource Gray200}, Dark={StaticResource Gray950}}" | ||
Grid.RowSpan="2" /> | ||
<CollectionView ItemsSource="{Binding Music}" | ||
Grid.Row="1" | ||
SelectionMode="Single"> | ||
<CollectionView.ItemTemplate> | ||
<DataTemplate x:DataType="viewmodels:MusicItemViewModel"> | ||
<Border Style="{StaticResource border_gallery_card}"> | ||
<Border.GestureRecognizers> | ||
<TapGestureRecognizer Command="{Binding Path=BindingContext.OpenMusicCommand, Source={x:Reference Page}}" | ||
CommandParameter="{Binding .}" /> | ||
</Border.GestureRecognizers> | ||
<Grid ColumnDefinitions="75,*" | ||
InputTransparent="True" | ||
RowDefinitions="3*,2*" | ||
ColumnSpacing="8"> | ||
<!-- Placeholder for imagery --> | ||
<Image BackgroundColor="{AppThemeBinding Light={StaticResource Gray200}, Dark={StaticResource Gray950}}" | ||
Grid.RowSpan="2" /> | ||
|
||
<Label Text="{Binding Title}" | ||
FontSize="32" | ||
FontAttributes="Bold" | ||
Grid.Column="1" /> | ||
<Label Text="{Binding Title}" | ||
FontSize="32" | ||
FontAttributes="Bold" | ||
Grid.Column="1" /> | ||
|
||
<Label Text="{Binding Artist}" | ||
FontSize="20" | ||
Grid.Column="1" | ||
Grid.Row="1" /> | ||
</Grid> | ||
</Border> | ||
</DataTemplate> | ||
</CollectionView.ItemTemplate> | ||
</CollectionView> | ||
</Grid> | ||
<Label Text="{Binding Artist}" | ||
FontSize="20" | ||
Grid.Column="1" | ||
Grid.Row="1" /> | ||
</Grid> | ||
</Border> | ||
</DataTemplate> | ||
</CollectionView.ItemTemplate> | ||
</CollectionView> | ||
</Grid> | ||
</ContentPage> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
samples/Plugin.Maui.Audio.Sample/ViewModels/BitDepthViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Plugin.Maui.Audio.Sample.ViewModels; | ||
|
||
public class BitDepthViewModel | ||
{ | ||
public string Name { get; set; } | ||
public BitDepth BitDepth { get; set; } | ||
}; |
13 changes: 13 additions & 0 deletions
13
samples/Plugin.Maui.Audio.Sample/ViewModels/ChannelTypesViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Plugin.Maui.Audio.Sample.ViewModels; | ||
|
||
public class ChannelTypesViewModel | ||
{ | ||
public string Name { get; set; } | ||
public ChannelType ChannelType { get; set; } | ||
}; |
7 changes: 7 additions & 0 deletions
7
samples/Plugin.Maui.Audio.Sample/ViewModels/EncodingViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Plugin.Maui.Audio.Sample.ViewModels; | ||
|
||
public class EncodingViewModel | ||
{ | ||
public string Name { get; set; } | ||
public Encoding Encoding { get; set; } | ||
} |
4 changes: 1 addition & 3 deletions
4
samples/Plugin.Maui.Audio.Sample/ViewModels/MusicItemViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.