[英]sound effects in android Xamarin c#
I wanted to add sound effect to my android app.我想为我的 android 应用程序添加音效。 I am using
xamarin
4.2 c# and searched examples to do sound effects but could not find one in c#
or the one I found had issues.我正在使用
xamarin
4.2 c# 并搜索示例来制作声音效果,但在c#
找不到一个或我发现的那个有问题。
could some one please show me how to do sound effects in c# in xamarin
4.2;有人可以告诉我如何在
xamarin
4.2 中的 c# 中xamarin
声音效果xamarin
? something like playing .mp3
sound for one second without media player pop up.就像在没有媒体播放器弹出的情况下播放
.mp3
声音一秒钟。
According tothe Xamarin docs it seems to be pretty straightforward:根据Xamarin 文档,它似乎非常简单:
Create a new Xamarin.Android application named PlayAudio.
创建一个名为 PlayAudio 的新 Xamarin.Android 应用程序。
Add a sub folder named raw under Resources.
在 Resources 下添加一个名为 raw 的子文件夹。
Add a file named test.mp3 under raw.
在 raw 下添加一个名为 test.mp3 的文件。
In the Activity, create a class variable for the MediaPlayer.
在 Activity 中,为 MediaPlayer 创建一个类变量。
MediaPlayer _player;
In the OnCreate method, call MediaPlayer.Create, passing the context and the resource identifier for the mp3.
在 OnCreate 方法中,调用 MediaPlayer.Create,传递 mp3 的上下文和资源标识符。
_player = MediaPlayer.Create(this, Resource.Raw.test);
Call the Start method of the MediaPlayer.
调用 MediaPlayer 的 Start 方法。
_player.Start();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.