Android声音池SoundPool
来源:互联网 发布:男生喜欢的内衣知乎 编辑:程序博客网 时间:2024/05/22 19:01
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" > <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="射击" android:onClick="shoot" /></RelativeLayout>
public class MainActivity extends Activity { private SoundPool pool; private int soundID; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); int maxStreams = 10;// 池子中最多有多少声音 int streamType = AudioManager.STREAM_MUSIC; int srcQuality = 0; pool = new SoundPool(maxStreams, streamType, srcQuality); // 加载声音 soundID = pool.load(this, R.raw.shoot, 1); } public void shoot(View view) { float leftVolume = 1f;// 左声道 float rightVolume = 1f; int priority = 0; int loop = 0; float rate = 1f; pool.play(soundID, leftVolume, rightVolume, priority, loop, rate); }}
参考:Android音频、视频
阅读全文
0 0
- Android声音池SoundPool
- SoundPool--声音池
- 声音池 soundpool
- Android声音播放之SoundPool
- Android中SoundPool放声音
- android 的soundpool播放声音
- android----使用SoundPool播放声音
- Android播放声音SoundPool、MediaPlayer、AudioTrack
- Android soundPool 不能播放声音问题
- Android播放声音SoundPool、MediaPlayer、AudioTrack
- Android 中声音的处理二:SoundPool
- 【Android 声音处理】MediaPlayer和SoundPool
- Android播放声音SoundPool、MediaPlayer、AudioTrack
- 【Android 声音处理】MediaPlayer和SoundPool
- Ringtone,SoundPool,MediaPlayer之声音播放- Android
- Android播放声音SoundPool、MediaPlayer、AudioTrack
- Android播放声音SoundPool、MediaPlayer、AudioTrack
- Android学习笔记_24_多媒体MediaPlayer对象之音乐播放器与SoundPool声音池
- 汉诺塔如何记录每一步,每个塔上的盘子数
- LeetCode OJ 56 Merge Intervals [Medium]
- 插入排序和希尔排序
- udp sendto的数据会分包发送吗?
- HDU 3715 Go Deeper【2-SAT+二分】
- Android声音池SoundPool
- Fix npm ERR! addLocal Could not install on windows path
- java三目运算符
- git常用操作 (读廖雪峰git笔记)
- 学生时代结束_即将步入社会
- 利用python-pandas和sklearn进行天池移动推荐离线赛的全过程
- 阿里云ubuntu16 lnmp配置
- LibZXing二维码扫描/生成库,基于ZXing最新版3.3的封装
- address align