bdlukaa / just_audio_windows

Audio Player
10 stars 16 forks source link

Usage Example #44

Open moha-b opened 1 month ago

moha-b commented 1 month ago

To which pages does your suggestion apply?

Quote the sentences(s) from the documentation to be improved (if any)

It just needs more data here just_audio or have a clear instructions in the just_audio_windows readme

Describe your suggestion I need an example or guide on how to use this package on Windows. I tried using it like just_audio, but it didn't work. There was no error or exception of any kind thrown, so it would be helpful to have an example to follow and improve the Windows section in the just_audio package.

bdlukaa commented 1 month ago

You just need to add just_audio_windows as a dependency for it to work. There aren't any significant changes.

moha-b commented 1 month ago

Yes, I agree with you, but the package has an issue. It didn't work the first time you tried to play. On the second click, it works.

in the beginning, I thought it was an issue I searched on it and I thought it was #30 the main project uses examples like issue #39

// This is OK
final _playList = ConcatenatingAudioSource(
children: [
AudioSource.uri(Uri.parse("http://localhost:5000/song1")),
AudioSource.uri(Uri.parse("http://localhost:5000/song2")),
AudioSource.uri(Uri.parse("http://localhost:5000/song3")),
AudioSource.uri(Uri.parse("http://localhost:5000/song4")),
]);

// This has NOT OK : progressbar lost position and got frozen when hit next song.
final _playList = ConcatenatingAudioSource(
children: [
AudioSource.uri(Uri.parse("asset:///assets/songs/song1.mp3")),
AudioSource.uri(Uri.parse("asset:///assets/songs/song2.mp3")),
AudioSource.uri(Uri.parse("asset:///assets/songs/song3.mp3")),
AudioSource.uri(Uri.parse("asset:///assets/songs/song4.mp3")),
]);

I attempted something similar, but it didn't work. Nothing plays and no errors appear. I searched extensively for an example of how to use it on Windows. Maybe I did something wrong, but as you said, it's the same implementation. So, I created a new project with only a button in the center and used this code.

 body: Center(
          child: ElevatedButton(
              onPressed: () async {
                final player = AudioPlayer();
                await player.setFilePath(
                    "C:\\$dir\\$dir\\$dir\\Documents\\muhammad_siddeeq_al-minshaawee\\100.mp3");

                player.play();
              },
              child: Icon(Icons.play_arrow)),
        ),

this was printed

[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(1065)] The 'com.ryanheise.just_audio.events.85e74c38-141f-440f-8b62-c28dac5193d3' 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(1065)] The 'com.ryanheise.just_audio.data.85e74c38-141f-440f-8b62-c28dac5193d3' 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.

After clicking again, it prints the same response and an additional line.

[just_audio_windows] Called play

The whole point is, if there is an issue that takes a lot of time to resolve, you can add a warning to the Windows readme to let us know about it instead of wasting a lot of time searching why it's not working.

moha-b commented 1 month ago

If you still see this and it doesn't matter, please close the issue.

Thanks for listening 🙏

bdlukaa commented 1 month ago

Can you run the app with Visual Studio and get the stacktrace from there? Thanks.

moha-b commented 1 month ago

hmm it works like that and this is Stacktrace

[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 play
[just_audio_windows] Called load
[ERROR:flutter/shell/common/shell.cc(1065)] The 'com.ryanheise.just_audio.events.018c9958-268d-48e8-beec-1a263d2053df' 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.

maybe the issue appear only with the audio source I will test it and update u

bdlukaa commented 1 month ago

@moha-b apparently play is being called before load, so it makes sense no audio is being played.

I did some checking and await player.setFilePath(...) does not await for the entire audio initialization, only for the call to the platform method. It may make sense to call .play after some defined time.

maknon commented 3 weeks ago

facing the same issue but it didn't work at all

Launching lib\main.dart on Windows in debug mode...
Building Windows application...
√ Built build\windows\x64\runner\Debug\haq.exe
Debug service listening on ws://127.0.0.1:49787/LDwArh__iLY=/ws
Syncing files to device Windows...
[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(1063)] The 'com.ryanheise.just_audio.events.071e60b7-7ec4-4a34-915e-e1fcc1308c5c' 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(1063)] The 'com.ryanheise.just_audio.data.071e60b7-7ec4-4a34-915e-e1fcc1308c5c' 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.

any hint would be really appreciated