soundpool

Loading MP3s into the Sound Pool in Android

这一生的挚爱 提交于 2019-12-02 05:17:07
I want to load a couple of MP3s into the sound pool, but I will only be using these MP3s on Activity 3, is it possible to load the MP3s in Activity 1? Or is this limited to the Activity that loads it uses it? I can't find the answer in the docs. You can load them anytime and use them everywhere. The best thing to re-use the SoundPool object would be to extend the Application class and declare a private variable in there that is your SoundPool . Something like: class MyApp extends Application { private static MyApp singleton; private static SoundPool mSoundPool; public onCreate() { super

How to check and redirect audio between wired headset and speaker phone?

北城余情 提交于 2019-12-02 02:22:48
I am developing a simple app , that should toggle between speaker phone and wired headset to play audio on a button click event. I am trying to make use of isWiredHeadsetOn() function, but it says that this is deprecated for Android API lvl 5 onwards. So how do I check if currently audio is playing or not through wired headset so that I can redirect it to the phone speaker? Note: I start my app with the headphone plugged to the 3.5mm jack of the phone. This is my attempt at the code so far: protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView

How to check and redirect audio between wired headset and speaker phone?

跟風遠走 提交于 2019-12-01 23:26:28
问题 I am developing a simple app , that should toggle between speaker phone and wired headset to play audio on a button click event. I am trying to make use of isWiredHeadsetOn() function, but it says that this is deprecated for Android API lvl 5 onwards. So how do I check if currently audio is playing or not through wired headset so that I can redirect it to the phone speaker? Note: I start my app with the headphone plugged to the 3.5mm jack of the phone. This is my attempt at the code so far:

How to stop playing a Sound via Soundpool?

对着背影说爱祢 提交于 2019-12-01 18:54:31
Please, have a look at those pieces of code: private SoundPool soundPool; private int soundID; soundPool = new SoundPool(10, AudioManager.STREAM_MUSIC, 0); soundID = soundPool.load(this, R.raw.batimanbailedosenxutos, 1); and when I press the button: soundPool.play(soundID, volume, volume, 1, 0, 1f); if I press this button twice in the same time, it plays the sound togheter, I want to stop the sound and play again if the user press the button while playing I tryed puting an soundPool.stop(soundID); before the soundPool.play but I don't know why it only work for the 1 time the song is played, do

Soundpool not looping in android 4.3

笑着哭i 提交于 2019-12-01 16:38:47
问题 I have a couple of apps in which I use soundpool to loop the sound of a ticking clock, this works fine in all previous versions of android but after upgrading to android 4.3 the sound no longer loops but just plays once. I know I can use MediaPlayer to loop it instead but this doesn't sound as good. Is there an easy work around for this, will android fix the bug, or do I have to make do with MediaPlayer. 回答1: Check this link. https://code.google.com/p/android/issues/detail?id=58113 Soundpool

How do I know that the Soundpool is ready using SDK target below 2.2?

◇◆丶佛笑我妖孽 提交于 2019-12-01 09:41:47
问题 This question is related to this one. I managed to modify my code to use SoundPool instead of AudioManager. Know it works more or less. public class Sound { private static boolean sound = true; private static final int EAT_SOUND = 1; private static final int SHORT_EAT_SOUND = 2; private static final int EAT_CHERRY_SOUND = 3; private static final int EAT_GHOST_SOUND = 4; private static final int EXTRA_LIVE_SOUND = 5; private static final int INTERMISSION_SOUND = 6; private static final int

Android Soundpool Load(String path, int priority)

守給你的承諾、 提交于 2019-12-01 09:01:59
I am trying to load a sound from android. The sound is under res/raw/myownsound.wav . I know that I can already load the sound using: soundPool.load(context, R.raw.myownsound, 1) For customization purposes, I would like to load it using: soundPool.load("res/raw/myownsound", 1) ... but I get the following error : error loading res/raw/myownsound . I also tried the following : soundPool.loadSound("android.resource://upg.GraphismeBase/raw/myownsound", 1) .. but I get an error as well : error loading android.resource://upg.GraphismeBase/raw/myownsound What is the correct way of using soundPool

Record/capture internal sound playback of Android app and export mp3?

守給你的承諾、 提交于 2019-12-01 05:50:34
Is it possible to record the internal sound generated by the app? My app allows you to create and play back musical sequences. soundPool.play(soundIds[i], 1f, 1f, 1, 0, Constants.TIME_RATE); I'd like to be able to record the sequence and export to mp3. I've looked into Audio Capture but setAudioSource (int audio_source) only seems to accept MIC recording. Thanks No, there's no API for getting the audio output, even for your own app (actually that's not entirely true, because you can get it through the Visualizer API, but it would be of such low quality that I doubt it would be of any use for

AudioCache Heap size overflow issue req size: 1053184, max size: 1048576

假如想象 提交于 2019-12-01 05:39:54
问题 I am developing an app where i want to play two mp3 files simultaneously one as background music and want to control the sound of each player separately. The file size is 5 mb each i have done with main audio file but when i try to play second file with it it throws error SoundManager mSoundManager = new SoundManager(); mSoundManager.initSounds(getBaseContext()); mSoundManager.addSound(1,R.raw.music); mSoundManager.addSound(2,R.raw.mentalafslapning); mSoundManager.playSound(1); mSoundManager

Android Soundpool problems

我们两清 提交于 2019-12-01 05:19:11
I've got an app on the Android Market and have been using the SoundPool classes for the sound effects. I've noticed that, of all the parts of the Android API, this seems to have caused me the most problems. For example: HTC Desire has problems playing WAV files (this causes it to lock up randomly). Using .ogg files fixes this On the Droid, if you exceed the number of channels in the init setup call: mSoundPool = new SoundPool(4, AudioManager.STREAM_MUSIC, 0); the handset would lock up. If you can imagine the difficulty in debugging that! On a handset I don't own. It required a lot of selfless