Android Audio loop not work
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.
I'm having the same issue, Android version 11 on a Galaxy Tab S6. The 'play' function works fine
Same here.
@alb99 's solution works fine for me
for anyone interested, calling loop after play seems to solve the problem on android, can't test on ios
@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 });
This issue is still relevant in 2023, the solution proposed by @studentrk works though