Playing Multiple sounds at the same time in Android

Playing Multiple sounds at the same time in Android

Content Index :

Playing Multiple sounds at the same time in Android
Tag : android , By : PPD
Date : January 10 2021, 01:47 PM

No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Android - Multiple appWidgets playing different sounds

Tag : java , By : firebasket
Date : March 29 2020, 07:55 AM
Hope that helps I'm writing an android soundboard wich allow the user to create multiple desktop widgets, one for each sound. I'm using an activity for the user to choose wich sound he wants to create the widget for. For each widget created i store a shared preference in the form of , I had the same problem and solved it like this:
Intent intent = new Intent(context, YourActivity.class)
        .putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
PendingIntent pi = PendingIntent.getActivity(context, appWidgetId, intent,
int currentWidgetId = this.getIntent().getIntExtra(
       AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
private void updateWidgetView() {
    views = new RemoteViews(YourWidget.class.getPackage().getName(),
    mgr = AppWidgetManager.getInstance(this);
    views.setTextViewText(R.id.some_text_view, someText);
    // Tell the AppWidgetManager to perform an update on the current App Widget
    mgr.updateAppWidget(currentWidgetId, views);

Android - Playing multiple sounds sequencially

Tag : android , By : vasil
Date : March 29 2020, 07:55 AM
it fixes the issue SoundPool is commonly used to play multiple short sounds. You could load up all your sounds in onCreate(), storing their positions in a HashMap.
Creating SoundPool
public static final int SOUND_1 = 1;
public static final int SOUND_2 = 2;

SoundPool mSoundPool;
HashMap<Integer, Integer> mHashMap;

public void onCreate(Bundle savedInstanceState){
  mSoundPool = new SoundPool(2, AudioManager.STREAM_MUSIC, 100);
  mSoundMap = new HashMap<Integer, Integer>();

  if(mSoundPool != null){
    mSoundMap.put(SOUND_1, mSoundPool.load(this, R.raw.sound1, 1));
    mSoundMap.put(SOUND_2, mSoundPool.load(this, R.raw.sound2, 1));
*Call this function from code with the sound you want e.g. playSound(SOUND_1);
public void playSound(int sound) {
    AudioManager mgr = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE);
    float streamVolumeCurrent = mgr.getStreamVolume(AudioManager.STREAM_MUSIC);
    float streamVolumeMax = mgr.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
    float volume = streamVolumeCurrent / streamVolumeMax;  

    if(mSoundPool != null){
        mSoundPool.play(mSoundMap.get(sound), volume, volume, 1, 0, 1.0f);

swift sprite kit - AVAudioPlayer not playing multiple sounds in same time simultaneously

Tag : ios , By : kangfoo2
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , There may be a more efficient way, but you can try this for each sound. I tried it out with a couple sounds and it worked. If you don't want the your sounds to interrupt music that the user may be listening to, then just change AVAdudioSessionCategoryPlayback to AVAdudioSessionCategoryAmbient.
var audioPlayer = AVAudioPlayer()

func playSound() {

var dropSound = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("drop", ofType: "mp3")!)

AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback, error: nil)
AVAudioSession.sharedInstance().setActive(true, error: nil)

var error: NSError?
audioPlayer = AVAudioPlayer(contentsOfURL: dropSound, error: &error)


Playing 2 sounds together at same time

Tag : chash , By : billputer
Date : March 29 2020, 07:55 AM

Playing sounds sequentially on android's google chrome (given the new restrictions on playing sound)

Tag : android , By : usingtechnology
Date : March 29 2020, 07:55 AM
like below fixes the issue To start with, Google Chrome on Android has been having the limitation of not allowing applications to play HTML audio(s) without an explicit action by the user. However, it is different than how stock browser(s), in most cases, handles it.
Related Posts Related QUESTIONS :
  • Manifest Permissions vs App Setttings Permissions
  • NumberFormatException in Try-Catch while converting String to Int
  • How to pass observable fields through include tag?
  • Next button on Android keyboard not submitting form
  • Does Firestore support automatic functions for updates?
  • Why app crashing because of a missing dimension (for google maps) only when I apply changes?
  • How to make a grouping, ordering and sorting: Kotlin collection
  • how to use augmented reality to change the color of a qr code once it is detected using with arcore and ml kit firebase
  • how to resolve Firebase projects adding quota problem?
  • Why it Kotlin giving me the wrong Int value when converting from a String
  • How to add bottom navigation listeners to fragments
  • Why is scrollview hiding buttons behind other views?
  • Open Settings using Linking.sendIntent()
  • How do I access an unknown node in firebase while retrieving data?
  • Can't retrieve list of all users from firebase authetication
  • many activities with same content (adview, reward adview, functions...) how to avoid repeating code?
  • Popup doesn't hide when touch outside
  • proper way to handling images in Android? by using Firebase
  • Android: Button is faded gray when it should be transparent
  • Gradle DSL method not found: 'deleteAllActions()'
  • In Clean Architecture, must Repository is Android or Kotlin module?
  • Kotlin parse double from string
  • Inconsistency detected. Invalid view holder adapter positionViewHolder
  • In App Update API always returns 1 (UPDATE_NOT_AVAILABLE)
  • Event of ImageView when click
  • Basic precautions to prevent piracy?
  • What is the difference between 'center' and 'centerCrop' in the "ImageView"?
  • Unable to receive SIP calls when app is killed
  • Android emulator not processing http get request, but iOS simulator works fine
  • Android Problem with sharing temporary file
  • How to add Broadcast in Android?
  • How to hide 'Running in Chrome' toast on TWA application on Android devices?
  • How to Fix Error: Could not find method deleteAllActions() for arguments [] on task
  • Android Deep Linking not working with https
  • WARNING: API 'variant.getMergeResources()' is obsolete and has been replaced with 'variant.getMergeResourcesProvider()'
  • setSupportActionBar (androidx.appcompat.widget.Toolbar) in AppCompatActivity¬†cannot be applied
  • Manifest merger failed after adding Firebase core version 17.0.0
  • Marker from Firestore map data type
  • Cordova signed apk produces a blank screen after splash screen
  • How to clear EditText input from all item views of RecyclerView?
  • Android Studio Mac Fresh install - error after error after error
  • Android Q, programmatically connect to different WiFi AP for internet
  • Application is becoming very slow while retrieving data from server
  • How to get Accelerometer value in Android XAML App(Xamarin.Forms)
  • androidx.constraintlayout.widget.ConstraintLayout cannot be cast to android.widget.TextView
  • Synchronized singleton in Kotlin
  • Product details from barcode
  • What is the difference between armeabi-v7a, arm64-v8a, x86?
  • Where did the "Profile or Debug APK..." option disappear to in Android Studio 3.4.1?
  • App crashes when trying to enter onDataChange Firebase Android
  • Combining WorkContinuation doesn't work as expected
  • Could not get unknown property 'config' for type com.google.gms.googleservices.GoogleServicesPlugin$GoogleServicesPlugin
  • Firebase Storage image upload successful through Android App but how to get url?
  • Xamarin cross platform - Couldn't connect debugger
  • How to customize Android Studio's import ordering in Kotlin to ignore whether they are "static" imports?
  • TV Remote Control Spatial Navigation
  • Google Admob always shows test adds on emulator even if the application is download and installed from the play store
  • Unable to load images into ImageView using Glide
  • A variable in for loop is not identifiable rather than it is declared and initialize in loop
  • View become null after inject constructor presenter with dagger 2
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com