Flame Audio does not stop the AudioPlayer #1249
-
Working with Flame and Flame Audio, I cannot resolve an issue. The stop function on AudioPlayer returned by FlameAudio, does not stop playing the loop. I am not sure whether this is a problem in my code, a problem in AudioPlayer, or a problem of FlameAudio. Below is the piece of code that starts the sound on start, and should stop it on end or cancel. With single pointer dragging it works. However, when using multidrag with multiplee pointers, and releasing all at once the sound keeps playing. The code should play only one sound while at least one drag is active. Can anyone tell me, if I am doing something wrong or is there a bug. The minimum working example, which exhibits the problem on my phone, is available at https://github.com/markohrastovec/flame_audio_test.
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Is the code within the @override
void onDragStart(int pointerId, DragStartInfo info) async {
if (loopPlayer == null && activeDrag.isEmpty) {
activeDrag.add(pointerId);
loopPlayer = await FlameAudio.audioCache.loop('sfx/flame.mp3');
} else {
activeDrag.add(pointerId);
}
} |
Beta Was this translation helpful? Give feedback.
-
Thank you. You are right. I was too concentrated on drag end when problem was starting to show and not on drag start when it actually started. |
Beta Was this translation helpful? Give feedback.
Is the code within the
if
cases triggered? I wonder if this could have something to do with the methods beingasync
and it actually created two players, but replaces the first created one with a new one in the variable? Does this happen if you do something like this in `onDragStart: