-
-
Notifications
You must be signed in to change notification settings - Fork 504
Closed
Description
Good getlocaltime()!
I'm struggling to pass any data to _backgroundAudioPlayerTask
function (according to this example https://github.com/ryanheise/audio_service/blob/master/example/lib/main.dart). I want to pass URL to play.
var res = AudioService.start(
backgroundTask: () async {
// I modified CustomAudioPlayer also
CustomAudioPlayer player = CustomAudioPlayer("HERE IS MY URL");
AudioServiceBackground.run(
onStart: player.run,
onPlay: player.play,
onPause: player.pause,
onStop: player.stop,
onClick: (MediaButton button) => player.playPause(),
);
},
// omited
);
But it doesn't work. It returns instance of Future<bool>
which resolves to false:
I/flutter (19613): Instance of 'Future<bool>'
I/flutter (19613): false
I also was trying to do something like this:
Function play(String url) {
void handler() async {
CustomAudioPlayer player = CustomAudioPlayer(url);
AudioServiceBackground.run(
onStart: player.run,
onPlay: player.play,
onPause: player.pause,
onStop: player.stop,
onClick: (MediaButton button) => player.playPause(),
);
}
return handler;
}
Error:
E/flutter (20407): [ERROR:flutter/shell/common/shell.cc(184)] Dart Error: Unhandled exception:
E/flutter (20407): NoSuchMethodError: No top-level getter 'handler' declared.
E/flutter (20407): Receiver: top-level
E/flutter (20407): Tried calling: handler
E/flutter (20407): #0 NoSuchMethodError._throwNew (dart:core/runtime/liberrors_patch.dart:212:5)
E/flutter (20407): [ERROR:flutter/shell/common/engine.cc(178)] Could not run the isolate.
E/flutter (20407): [ERROR:flutter/shell/common/engine.cc(119)] Engine not prepare and launch isolate.
E/flutter (20407): [ERROR:flutter/shell/platform/android/android_shell_holder.cc(167)] Could not launch engine in configuration.
Can you help me please, what I'm doing wrong?
p.s: I'm new to dart and flutter, so maybe I'm doing something really stupid :)
Metadata
Metadata
Assignees
Labels
No labels