Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

await player.play(BytesSource(bytes)) in Windows. Lost connection to device after build #1847

Open
2 tasks done
danjko350 opened this issue Oct 8, 2024 · 2 comments
Open
2 tasks done
Labels

Comments

@danjko350
Copy link

Checklist

  • I read the troubleshooting guide before raising this issue
  • I made sure that the issue I am raising doesn't already exist

Current bug behaviour

Occurs if you follow the steps in "expected behavior"

Expected behaviour

If you replace "await player.setSource(assetSource('ambient_c_motion.mp3'))" with "await player.play(BytesSource(bytes))" in Windows and start debarking, then the connection to the device is immediately lost

Steps to reproduce

  1. Execute flutter run on the code sample
  2. ...
  3. ...

Code sample

Code sample
void main() {
}

Affected platforms

Windows

Platform details

Windows 11

AudioPlayers Version

^6.1.0

Build mode

No response

Audio Files/URLs/Sources

void initState() {
super.initState();

// Create the audio player.
player = AudioPlayer();

// Set the release mode to keep the source after playback has completed.
player.setReleaseMode(ReleaseMode.stop);

// Start the player as soon as the app is displayed.
WidgetsBinding.instance.addPostFrameCallback((_) async {
  //await player.setSource(AssetSource('ambient_c_motion.mp3'));
  //await player.play(DeviceFileSource(localFile));
  await player.play(BytesSource(bytes));
  await player.resume();
});

}

Screenshots

No response

Logs

my relevant logs
Full Logs
my full logs or a link to a gist

Flutter doctor:

Output of: flutter doctor -v

Related issues / more information

No response

Working on PR

no way

@danjko350 danjko350 added the bug label Oct 8, 2024
@sonhoang-diqit
Copy link

I guess that you are using flavor. If true, you try to put F.appFlavor = Flavor.dev (based on your environment) at first in the main method.

@gh-pap
Copy link

gh-pap commented Jan 10, 2025

FYI - I'm also on Windows and encountered exactly the same error.
await player.play(BytesSource(bytes));
The cause was that my bytes were raw PCM16 without a wavheader. Added the header and all was well. "Lost connection to device" wasn't the best error but ultimately it was my fault (as usual!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants