ukasz123 / soundpool

Soundpool plugin for Flutter
87 stars 64 forks source link

Cant play sound in background #51

Open JRakhimov opened 3 years ago

JRakhimov commented 3 years ago

Hey there, I have a problem with playing notification sound when application works in background. I should play sound when application receives push notification from firebase, example:

  static Future<dynamic> onBackgroundMessage(Map<String, dynamic> message) async {
    final pool = Soundpool(streamType: StreamType.notification);
    rootBundle.load('assets/new_offer_sound.mp3').then((value) => pool.load(value)).then((value) => pool.play(value));
  }

and it crashes when I init Soundpool instance

Unhandled Exception: MissingPluginException(No implementation found for method initSoundpool on channel pl.ukaszapps/soundpool)

What i am doing wrong?

ukasz123 commented 3 years ago

What platform this happens on?

Have you checked GeneratedPluginRegistrant to see if soundpool plugin has been added there?

umanamente commented 1 year ago

What platform this happens on?

I have the same error when building for Windows platform (Android works fine).

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: MissingPluginException(No implementation found for method initSoundpool on channel pl.ukaszapps/soundpool)
#0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:313:7)
<asynchronous suspension>
#1      MethodChannelSoundpoolPlatform.init (package:soundpool_platform_interface/method_channel_soundpool_platform.dart:11:100)
<asynchronous suspension>
#2      Soundpool._connect (package:soundpool/soundpool.dart:319:20)
<asynchronous suspension>
eximius313 commented 11 months ago

@umanamente, as far as I can see, Windows is not supported: image

eximius313 commented 11 months ago

Although I see there is some experimental support branch: https://github.com/ukasz123/soundpool/issues/46#issuecomment-1002172727