Skip to content Skip to sidebar Skip to footer

How Can I Fix My Audio? (prioritize)

When two audio's are played at the same time...the sound is canceling out. How do I fix this weird phenomenon? I have some code where there is audio on button click and audio in t

Solution 1:

You may have a race condition. In these three lines

1if(!manager.isMusicActive()) {
2MediaPlayerpop= MediaPlayer.create(context, R.raw.pop);
3        pop.start();

Between line 1 and line 3, there is opportunity for another player to get the media player and start playing, especially if line 2 is slow.

I would suggest making one media player that both players access (i.e. create the "MediaPlayer pop" elsewhere and share it), or find another way to synchronize the different players. Perhaps issuing a stop right before a play, rather than checking for play state.

Post a Comment for "How Can I Fix My Audio? (prioritize)"