android - 为什么我无法使用 SoundPool 播放声音?
问题描述
我正在使用以下代码:
button.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
AudioAttributes at = new AudioAttributes.Builder().setContentType(AudioAttributes.CONTENT_TYPE_MUSIC).setUsage(AudioAttributes.USAGE_NOTIFICATION).build();
SoundPool sp = new SoundPool.Builder().setMaxStreams(2).setAudioAttributes(at).build();
int sonido = sp.load(reserva.this,R.raw.sound_gracias,1);
sp.play(sonido,1,1,1,0,1);
}
});
问题:
当我单击按钮时,我听不到任何声音(我有 100% 的多媒体声音)。
这是我正在使用的声音:
https://freesound.org/people/HoseNoseSounds/sounds/510735/
我能做些什么来解决这个问题?
非常感谢您的阅读!
解决方案
推荐阅读
- python - Python Selenium seleniumrequests GET 代理执行两次?
- asp.net - OwinMiddleware 中 HttpRequest.PhysicalPath 的等价物是什么?
- angular - 在Angular 12中更改选定收音机的标签背景
- python - 如何下载实际上没有下载链接的文件?
- android - 将数据加载到表单更新sqlite android时出现换行问题
- ag-grid-react - 文本转换在 ag-grid react 中不起作用
- c# - 如何在我的 c# 项目中使用“apache org”依赖项
- sql-server - 计算十分位数的频率
- java - JPA在没有预定义实体类的情况下获取映射结果
- containers - 容器没有ip地址,我们如何从本地客户端连接到mysql服务器容器