soundpool

Android AudioHardware pcm playback is going to standby

柔情痞子 提交于 2019-12-11 08:43:42
问题 Occasionally when I have a lot going on in my app, and I am playing a number of sounds using SoundPool, my app just completely freezes. Looking at the logs, I see this: I/AudioHardwareMSM72XX( 56): AudioHardware pcm playback is going to standby. My app must then be force closed and restarted. Does anyone know what may be causing this, or a possible workaround? I cannot reproduce this in the emulator - only on my HTC Hero, so I am wondering if this may be a device specific bug. 回答1: There are

Playing Audio files from SD card

只愿长相守 提交于 2019-12-11 07:25:17
问题 I wanted to load files from the SD card into a SoundPool as well as ringtones. I am able to successfully get the path of the files, and I am able to play them with MediaPlayer. However, I need the functionality of the SoundPool. I have tried SoundPool.load(String, int) but it appears to not load the file. Is it possible to load files from the SD card into a SoundPool, or is there a better way to do this? 回答1: You can use android.os.Environment.getExternalStorageDirectory() to get the

how to know when soundpool finished playing audiofile?

喜夏-厌秋 提交于 2019-12-11 03:40:21
问题 I am using soundpool to play my recorded file. I just want to know that is there any way to know when soundpool finish playing. here is my working code below. public void soundPool() { final float playbackSpeed = 1.5f; final SoundPool soundPool = new SoundPool(4, AudioManager.STREAM_MUSIC, 100); final int soundId = soundPool.load(audiofile.getAbsolutePath(), 1); AudioManager mgr = (AudioManager) getSystemService(Context.AUDIO_SERVICE); final float volume = mgr.getStreamMaxVolume(AudioManager

How to disable the wired headset programmatically in Java

穿精又带淫゛_ 提交于 2019-12-10 17:35:02
问题 Please refer my question here. This question is an extension to that: How to check and redirect audio between wired headset and speaker phone? I was able to partially solve my problem by including the permissions <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> in my Android Manifest for that same piece of code. Now, I am able to enable and disable the phone speakers, but I am not able to turn off my wired headset connection programmatically, when the wired headset

and again about memory issues with SoundPool

妖精的绣舞 提交于 2019-12-10 14:18:40
问题 I am aware that SoundPool was intended to handle small fx like sounds and I made sure my 4 sound clips which I want to play one by one in some sequence are small enough. I used ogg quality 0 and clips are 35kb, 14kb, 21kb and 23kb totaling 92kb of compressed audio. I have no idea how to estimate what the uncompressed size would be, but it should not be a lot, right? So when I play 4 sounds in sequence, it works well for first 9 times (9 sequences x 4 sounds) but starts to cause memory issues

Android: Recording SoundPool output

房东的猫 提交于 2019-12-08 17:13:49
问题 I'm allowing the user to push buttons to play sounds via a SoundPool. Is it possible to record whatever the SoundPool is playing so that the user can record a sequence of sounds? 回答1: Actually there is no possibility to catch played sound. I had the same wish to do this, but for now, it is just possible with record the output of the speaker. For this, You have to use MediaRecorder and record just "live". But I don´t think it is a good solution, there will be much background sounds. 来源: https:

MediaPlayer vs SoundPool for only 1 simultaneous stream

扶醉桌前 提交于 2019-12-08 03:47:35
问题 I'm working on a game in which one single sound is played each time the phone is shaked. Does it make sense to use a SoundPool and load sounds in the onCreate of my activity, or is it ok to create a mediaplayer each time, as shown below: private void onShake() { MediaPlayer mp= MediaPlayer.create(this, whipSound[currentWhip][force]); mp.start(); } My guess is that SoundPool is better because the sounds are loaded only once. Am I right? Thanks Julien 回答1: As expected, SoundPool is much faster.

android mediaplayer alternative?

痞子三分冷 提交于 2019-12-08 00:55:42
问题 Is there a java audio library that is capable of setting the playback rate of the audio(controlling the speed of the audio) as well as being able to return me the current position of the playback and the total duration of the audio stream? I noticed that the android mediaplayer would be able to return me the current position of the playback and the total duration of the audio stream but it doesn't let me set the playback rate. And unfortunately the android soundpool lets me set the playback

Android soundpool rate range?

为君一笑 提交于 2019-12-07 17:00:53
问题 Android's soundpool.play [documentation][1] says " The playback rate allows the application to vary the playback rate (pitch) of the sound. A value of 1.0 means play back at the original frequency. A value of 2.0 means play back twice as fast, and a value of 0.5 means playback at half speed. ". However, when I set the rate to 1.49f, I hear silence. 1.485f renders correctly (it's ogg file). Is this specific to my handset, is the documentation wrong, or am I being foolish in some other way? [1]

Android 2.2 - SoundPool sample 0 is not READY

女生的网名这么多〃 提交于 2019-12-07 05:21:45
问题 I have searched StackOverflow and cannot find a situtation like mine. I am using four buttons with each button playing a sound file. I am using SoundPool: SoundPool sound = new SoundPool(4, AudioManager.STREAM_MUSIC, 0); I am also using the OnLoadCompleteListener() which uses Log to create an I notification in LogCat. When I launch the program in the emulator I see all four samples complete loading. During the program three of the sounds will play, however, one will always say: WARN/SoundPool