class CustomAudioPlayer {
static AudioPlayer player = AudioPlayer();
static void playRingtone() {
player.play(AssetSource('noti.wav')); // Play the ringtone
player.onPlayerComplete.listen((event) {
log("Ringtone completed $test");
player.play(AssetSource('noti.wav'));
});
}
static void stopRingtone() {
player.stop();
}
}
@pragma('vm:entry-point')
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
CustomAudioPlayer.playRingtone();
}
Upon getting notification, When I open app from background and click the button that calls
CustomAudioPlayer.stopRingtone();
but the notification sound is not stopping
Please help me out