native-audio icon indicating copy to clipboard operation
native-audio copied to clipboard

Android Audio loop not work

Open alb99 opened this issue 4 years ago • 6 comments

When I call the loop method, the sound is not played. Only Android

To Reproduce Steps to reproduce the behavior: Angular Call await NativeAudio.loop({assetId:soundToPlay.key});

Expected behavior sound should be played

Smartphone (please complete the following information):

  • Device: Gigaset GS270 plus
  • OS: Android 8.1.0

Problem located There was no exception.

File: AudioDispatcher.java line 93 public void loop() throws Exception { mediaPlayer.setLooping(true); }

I fix the problem with this change public void loop() throws Exception { mediaPlayer.setLooping(true); mediaPlayer.start(); }

I don't know if this is the right place but it works.

alb99 avatar Aug 25 '21 08:08 alb99

I'm having the same issue, Android version 11 on a Galaxy Tab S6. The 'play' function works fine

Imfliba avatar Sep 02 '21 08:09 Imfliba

Same here.

sverdlov avatar Feb 09 '22 09:02 sverdlov

@alb99 's solution works fine for me

9imanroslan7 avatar Feb 14 '22 17:02 9imanroslan7

for anyone interested, calling loop after play seems to solve the problem on android, can't test on ios

yelhouti avatar Mar 24 '22 17:03 yelhouti

@yelhouti this seems to work, but only if you call loop after play and without await. Working Example:

NativeAudio.play({
      assetId: assetId,
      time: 0
})
NativeAudio.loop({
      assetId: assetId
});

But it doesn't work like that:

await NativeAudio.play({ assetId: assetId, time: 0 })
NativeAudio.loop({ assetId: assetId });

studentrk avatar Jan 13 '23 21:01 studentrk

This issue is still relevant in 2023, the solution proposed by @studentrk works though

zoualmamy avatar Mar 28 '23 16:03 zoualmamy