当前位置:网站首页>Xamarin effect Chapter 22 recording effect
Xamarin effect Chapter 22 recording effect
2022-04-23 03:08:00 【Dotnet cross platform】
In the previous article, I simply played GIS Of Basic operation 、Mark relevant 、AR、 ranging 、 Load 3d white mold and Scalable floating operation ; Let's share the recording effect today ; Don't say anything, it's all in the effect :
1、 First attempt at open source Plugin.AudioRecorder It turned out to be ineffective , Or maybe my posture is wrong :
https://github.com/NateRickard/Plugin.AudioRecorder
2、 Please consult the boss, Dawei , Sent a sentence :“ Reverse dependency ", Then I posted some code ; I don't understand what reverse dependency is , Only in the end do we know that it is to use DependencyService
This class ;
To put it bluntly, shared code can call the native of each independent platform API
3、 Shared code defines the interface to be implemented :
4、 Then each platform implements the interface , Under the loser machine :
5、 The registration platform realizes , such Xamarin.Forms To find them at runtime
6、 Android recording on the next use MediaRecorder
// Set up the microphone
mMediaRecorder.SetAudioSource(AudioSource.Mic);
mMediaRecorder.SetOutputFormat(OutputFormat.Default);
mMediaRecorder.SetAudioEncoder(AudioEncoder.Default);
mMediaRecorder.SetOutputFile(filePath);
mMediaRecorder.Prepare();
mMediaRecorder.Start();
7、 Play the recording effect
public void Play(RecordModel model)
{
if(model != null)
{
var player = new MediaPlayer();
player.Prepared += (s, e) =>
{
player.Start();
model.IsPlaying = true;
};
player.SetDataSource(model.Path);
player.Prepare();
// When the playback is finished
player.Completion += (ss, ee) =>
{
model.IsPlaying = false;
};
}
}
8、 All the recording files at the front desk are still CollectionView( Love alone ), His ItemTemplate:
<Grid HorizontalOptions="Center" VerticalOptions="Center" HeightRequest="50">
<StackLayout Orientation="Horizontal" Margin="10,4,0,0" Padding="0">
<!-- Small microphone -->
<Label Text="" FontSize="22" BackgroundColor="Transparent" FontFamily="iconfont.ttf#" VerticalOptions="Center" TextColor="{Binding IsPlaying,Converter={StaticResource IsPlayingToTextColorConverter}}" />
<!-- The name of the recording -->
<Label Text="{Binding Name}" VerticalOptions="Center" FontSize="18" TextColor="{Binding IsPlaying,Converter={StaticResource IsPlayingToTextColorConverter}}" />
<!-- Duration , The main thing here is StringFormat usage -->
<Label Text="{Binding Duration,StringFormat='{0} second '}" Margin="10,0,0,0" VerticalOptions="Center" FontSize="18" TextColor="{Binding IsPlaying,Converter={StaticResource IsPlayingToTextColorConverter}}" />
<!-- Play -->
<Label Text="" FontSize="25" VerticalOptions="Center" FontFamily="iconfont.ttf#" TextColor="#98A6B1">
<Label.GestureRecognizers>
<TapGestureRecognizer Command="{Binding Source={RelativeSource AncestorType={x:Type vm:MainViewModel}},Path=PlayRecordCommand}" CommandParameter="{Binding}" /> </Label.GestureRecognizers>
</Label>
</StackLayout>
</Grid>
The final simple effect is this ; If you have time later , You can explore more complex effects
; Programming never stops 、Bug More than 、 nothing Bug、 No life
; Change bug Calm down 、 The passion of coding 、 Joy after completion 、 The excitement of digging a hole 、 The excitement of filling the hole ; Maybe that's the fun of lousy programmers ; Come here today ; I hope I have the motivation to persist step by step ; Life is endless , Code is more than ; You can take time to see the effect of today's sharing , Have good opinions and ideas , You can leave a message on the message board ; I will reply you as soon as I see it , Thank you for your attention and support ! If it feels good , Then reach out your little hand, praise and pay attention to , Thank you for your support !
版权声明
本文为[Dotnet cross platform]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230301333334.html
边栏推荐
- Using positive and negative traversal to solve the problem of "the shortest distance of characters"
- [format] simple output (2)
- Distributed system services
- Two methods are used to solve the "maximum palindrome product" problem
- C#中元组对象Tuple的使用
- Thoughts on the 2022 national network security competition of the national secondary vocational group (only one idea for myself) - network security competition questions (10)
- Tips in MATLAB
- C language to achieve address book - (static version)
- Middle and rear binary tree
- 腾讯视频涨价:一年多赚74亿!关注我领取腾讯VIP会员,周卡低至7元
猜你喜欢
Some problems encountered in setting Django pure interface, channel and MySQL on the pagoda panel
C# 读写二进制文件
准备一个月去参加ACM,是一种什么体验?
[format] simple output (2)
再战leetcode (290.单词规律)
Recursion - outputs continuously increasing numbers
微软是如何解决 PC 端程序多开问题的——内部实现
Thoughts on the 2022 national network security competition of the national secondary vocational group (only one idea for myself) - network security competition questions (8)
最通俗易懂的依赖注入之服务容器与作用域
Drawing polygons with < polygon / > circular array in SVG tag
随机推荐
Using positive and negative traversal to solve the problem of "the shortest distance of characters"
ASP.NET和ASP.NETCore多环境配置对比
最通俗易懂的依赖注入之服务容器与作用域
中后二叉建树
使用栈来解决”迷你语法分析器“的问题
Find the number of leaf nodes of binary tree
First in the binary tree
TP5 inherits base and uses the variables in base
How does Microsoft solve the problem of multiple PC programs
搭建XAMPP时mysql端口被占用
宁德时代地位不保?
Xamarin效果第二十一篇之GIS中可扩展浮动操作按钮
C#中元组对象Tuple的使用
TP5 where query one field is not equal to multiple values
ASP.NET 6 中间件系列 - 执行顺序
C# 读写二进制文件
C#语法糖空合并运算符【??】和空合并赋值运算符【 ??=】
Blazor University (12)组件 — 组件生命周期
Vs code setting line feed
svg标签中利用<polygon/>循环数组绘制多边形