soundpool

Knowing if the loading of a sound with SoundPool has been successful on Android 1.6/2.0/2.1

夙愿已清 提交于 2019-11-29 10:57:43
On Android 2.2+ there is something called SoundPool.OnLoadCompleteListener allowing to know whether a sound has been loaded successfully or not. I am targeting lower API version (ideally 1.6 but could go for 2.1) and I need to know whether a sound has been loaded correctly (as it is selected by the user). What's the proper way to do it? I hope not load the sound once with MediaPlayer and if correct with SoundPool?! I implemented a kind-of-compatible OnLoadCompleteListener class that works at least for Android 2.1. The constructor takes a SoundPool object, and sounds for which the SoundPool

Playing Multiple sounds at the same time in Android

丶灬走出姿态 提交于 2019-11-29 07:57:53
I am unable to use the following to code to play multiple sounds/beeps simultaneously. In my onclicklistener I have added: public void onClick(View v) { mSoundManager.playSound(1); mSoundManager.playSound(2); } But this plays only one sound at a time, sound with index 1 followed by sound with index 2. How can I play at least 2 sounds simultaneously using this code whenever there is an onClick() event? public class SoundManager { private SoundPool mSoundPool; private HashMap<Integer, Integer> mSoundPoolMap; private AudioManager mAudioManager; private Context mContext; public SoundManager() { }

stream volume in SoundPool vs volume in AudioManager

会有一股神秘感。 提交于 2019-11-29 06:15:03
问题 I am so confused... SoundPool.play(int soundID, float leftVolume, float rightVolume , int priority, int loop, float rate) volume here is from 0.0 to 1.0 Tutorials I've seen recommend to calculate stream volume as: AudioManager mgr = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE); int streamVolume = mgr.getStreamVolume(AudioManager.STREAM_MUSIC); streamVolume = streamVolume / AudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); mSoundPool.play(mSoundPoolMap.get

SoundPool: Error creating AudioTrack

微笑、不失礼 提交于 2019-11-28 21:20:13
问题 I am having a problem With SoundPool as it refuses to work with my .ogg files. I am getting this error: AudioFlinger could not create track, status: -12 Error creating AudioTrack I've found a thread concerning this and the (possible) answer is: Make sure you use .ogg media files with constant bitrate! Is this the case? (someone please confirm or cancel) If yes - which application to use (Audacity doesn't support .ogg custom export settings). If not - what else could be wrong? As a side note -

Play sound with SoundPool

你说的曾经没有我的故事 提交于 2019-11-28 08:32:06
I need to play a short sound in my application. I wrote the following code but I have no sound and strange vibration appeared on my Samsung phone. But in the same time this code works well on my android simulator. My code is: package com.samplers; import android.app.Activity; import android.media.SoundPool; import android.media.AudioManager; import android.os.Bundle; import android.view.View; import android.widget.Button; public class FixVibroActivity extends Activity { /** Called when the activity is first created. */ private Button white; private SoundPool spool; private int soundID;

Waiting for SoundPool to load before moving on with application

做~自己de王妃 提交于 2019-11-28 08:07:13
问题 I was following a tutorial to integrate SoundPool into my app, and this is the code which was given in the tutorial: package com.example.soundpoolexample; import android.app.Activity; import android.media.AudioManager; import android.media.SoundPool; import android.media.SoundPool.OnLoadCompleteListener; import android.os.Bundle; import android.util.Log; import android.view.MotionEvent; import android.view.View; import android.view.View.OnTouchListener; public class SoundPoolExample extends

AudioFlinger could not create track. status: -12

淺唱寂寞╮ 提交于 2019-11-28 06:12:57
I am programming for android 2.2 and am trying to using the SoundPool class to play several sounds simultaneously but at what feel like random times sound will stop coming out of the speakers. for each sound that would have been played this is printed in the logcat: AudioFlinger could not create track. status: -12 Error creating AudioTrack Audio track delete No exception is thrown and the program continues to execute without any changes except for the lack of volume. I've had a really hard time tracking down what conditions cause the error or recreating it after it happens. I can't find the

How bad is Android SoundPool? What alternative to use?

核能气质少年 提交于 2019-11-28 03:31:57
I was looking at Android's SoundPool as a mechanism to implement sound effects in my generic game development library. It seemed ideal. But a little bit of research indicates that there all kinds of bugs in SoundPool . Are the bugs in SoundPool still relevant? Because I'm developing a library, any bugs in SoundPool become bugs in my library, and I want to insulate my users from that. So my question is basically: what API should I use for audio? Using AudioTrack and writing my own mixer is not out of the question. But obviously it would be preferable to avoid doing that. And is there any API to

SoundPool “AudioFlinger could not create track, status: -12”

半腔热情 提交于 2019-11-28 03:11:35
问题 I have an Android app with single button. When the button is clicked, the app starts playing (looping) sound loaded with SoundPool. When the button is clicked again, the sound is stopped, and then started again. But the problem is that the sound is played only every other time. Click 1st time -> sound starts to play Click 2nd time -> sound stops but doesn't start again Click 3rd time -> sound starts to play Click 4th time -> sound stops but doesn't start to play and so on... When the sound

Playing audio file from Sdcard

断了今生、忘了曾经 提交于 2019-11-28 01:22:12
I would like to play an audio file from the sdcard. How can I read the audio file and play it? Below is my code to play audio file: int sound1; sound1 = mSoundPool.load(this, R.raw.om, 1); mSoundPool.play(sound1, 1, 1, 1, time - 1, 1); Here in the above code i am using soundpool to play the audio file from raw folder but i need to play the audio file from sdcard using soundpool. Right now interested to play audio from sdcard. How to acheive this? please help i need to fix this as soon as possible Use the code below it worked for me. MediaPlayer mp = new MediaPlayer(); mp.setDataSource("/mnt