当前位置:网站首页>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
边栏推荐
- Xamarin effect Chapter 21 expandable floating operation button in GIS
- Use of MySQL command line client and common commands
- Distributed system services
- Ningde's position in the times is not guaranteed?
- HLS / chisel uses CORDIC hyperbolic system to realize square root calculation
- Laravel's own paging query
- 2022年度Top9的任务管理系统
- [new version release] componentone added Net 6 and blazor platform control support
- Thoughts on the 2022 national network security competition of the national secondary vocational group (only one idea for myself) - network security competition questions (7)
- Middle and rear binary tree
猜你喜欢

Laravel's own paging query

由于3²+4²=5²,所以称‘3,4,5‘为勾股数,求n(包括n)以内所有勾股数数组。

AOT和单文件发布对程序性能的影响
![[new version release] componentone added Net 6 and blazor platform control support](/img/08/71e7328f685a5cdd584f1bfdce5f2a.png)
[new version release] componentone added Net 6 and blazor platform control support

Impact of AOT and single file release on program performance

MySQL port is occupied when building xampp

Blazor University (11)组件 — 替换子组件的属性

Detailed explanation of distributed things

Realize QQ login with PHP

全网讲的最细,软件测试度量,怎样优化软件测试成本提高效率---火爆
随机推荐
ASP. Net 6 middleware series - execution sequence
利用正反遍历来解决“字符的最短距离”问题
建立与遍历二叉树
HLS / chisel uses CORDIC hyperbolic system to realize square root calculation
Thoughts on the 2022 national network security competition of the national secondary vocational group (only one idea for myself) - network security competition questions (9)
Impact of AOT and single file release on program performance
Thoughts on the 2022 national network security competition of the national secondary vocational group (only one idea for myself) - network security competition questions (7)
Laravel's own paging query
Load view Caton
树莓派开发笔记(十二):入手研华ADVANTECH工控树莓派UNO-220套件(一):介绍和运行系统
c#语法糖模式匹配【switch 表达式】
If the deep replication of objects is realized through C #?
2022A特种设备相关管理(电梯)上岗证题库及模拟考试
基于.NetCore开发博客项目 StarBlog - (1) 为什么需要自己写一个博客?
LNMP MySQL allows remote access
ASP.NET 6 中间件系列 - 自定义中间件类
全网最全,接口自动化测试怎么做的?精通接口自动化测试详解
Use of slice grammar sugar in C #
.Net Core 限流控制-AspNetCoreRateLimit
Middle and rear binary tree