Open mbfakourii opened 4 months ago
I'm getting the same error. If i try the audioplayers, the same error appears, simply with a different channel name.
Please provide a reproducible snippet. Make sure you are not calling the plugin from any isolate other than the main thread.
A reproducible snippet from me:
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
@override
initState() {
super.initState();
playWidgetSound();
}
playWidgetSound() async {
//Player is global variable
player.setAsset(songPath);
player.play();
}
@override
Widget build(BuildContext context){
//Rest of the code
}
What is the value of songPath
? You need to add asset:///
before the path to play an asset.
The value of songPath is assets/audio/song.mp3
. It isn't an asset from the web.
You need to add asset:///
as a prefix of your path to play audios from assets.
Ok, the problem has been solved for me. Thank you very much.
Please provide a reproducible snippet. Make sure you are not calling the plugin from any isolate other than the main thread.
final AudioPlayer player = AudioPlayer();
duration = await player.setUrl(urlFile, preload: false);
player.play();
@mbfakourii what is the value of urlFile
? For files, it is recommended to use the file:
scheme.
urlFile
is a web address, for example
https://example.com/1.mp3
same error
Are there any updates here? I get the same error on very first play, then it works as expected:
[just_audio_windows] Called setVolume
[just_audio_windows] Called setSpeed
[just_audio_windows] Called setPitch
[just_audio_windows] Called setSkipSilence
[just_audio_windows] Called setLoopMode
[just_audio_windows] Called setShuffleMode
[just_audio_windows] Called load
[ERROR:flutter/shell/common/shell.cc(1038)] The 'com.ryanheise.just_audio.events.4b09e9ac-b209-4b32-9430-97ba08da1775' channel sent a message from native to Flutter on a non-platform thread. Platform channel messages must be sent on the platform thread. Failure to do so may result in data loss or crashes, and must be fixed in the plugin or application code creating that channel.
See https://docs.flutter.dev/platform-integration/platform-channels#channels-and-platform-threading for more information.
[ERROR:flutter/shell/common/shell.cc(1038)] The 'com.ryanheise.just_audio.data.4b09e9ac-b209-4b32-9430-97ba08da1775' channel sent a message from native to Flutter on a non-platform thread. Platform channel messages must be sent on the platform thread. Failure to do so may result in data loss or crashes, and must be fixed in the plugin or application code creating that channel.
See https://docs.flutter.dev/platform-integration/platform-channels#channels-and-platform-threading for more information.
On mobile it works as expected.
[√] Flutter (Channel stable, 3.19.5, on Microsoft Windows [Version 10.0.22631.3447], locale ru-RU)
• Flutter version 3.19.5 on channel stable at C:\src\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 300451adae (6 weeks ago), 2024-03-27 21:54:07 -0500
• Engine revision e76c956498
• Dart version 3.3.3
• DevTools version 2.31.1
There is this issue with Flutter plug-ins on Windows. It happens with a few packages and have been known to be just a warning.
As some have reported above, the audio plays even with the error printed.
Note that this doesn't happen on all devices and not even all the time, which makes it hard to track and debug.
the funny thing is that audio_player library have the same issue https://github.com/bluefireteam/audioplayers/issues/1635 I wish I knew what is needed to learn windows c++ applications but I can't find good resources for it
Which API doesn't behave as documented, and how does it misbehave? When the audio tries to play, the following error is given
Minimal reproduction project n/a
To Reproduce (i.e. user steps, not code) n/a
Expected behavior I expected the sound to be played and not error
Screenshots n/a
Desktop (please complete the following information):
Smartphone (please complete the following information):
Flutter SDK version
Additional context n/a