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

Issue with space in File Path for "just_audio_windows" #26

Open
fvthakor opened this issue Aug 3, 2023 · 5 comments
Open

Issue with space in File Path for "just_audio_windows" #26

fvthakor opened this issue Aug 3, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@fvthakor
Copy link

fvthakor commented Aug 3, 2023

Which API doesn't behave as documented, and how does it misbehave?
When attempting to load audio files with space in their names, such as "C:\Users\HP\Downloads\Ve Kamleya Rocky Aur Rani Kii Prem Kahaani 320 Kbps.mp3" the "just_audio_windows" seems to encounter issues.

Minimal reproduction project
Provide a link here using one of two options:

Future<void> _init(path) async {
    final session = await AudioSession.instance;
    await session.configure(const AudioSessionConfiguration.speech());
    // Listen to errors during playback.
    _player.playbackEventStream.listen((event) {},
        onError: (Object e, StackTrace stackTrace) {
      print('A stream error occurred: $e');
    });
    // Try to load audio from a source and catch any errors.
    try {
      //var newPath = path.toString().replaceAll(" ", "+");
      //var encoded = Uri.encodeFull(path);
      // String fixedUrl = Uri.encodeQueryComponent(path);
      //print(fixedUrl);
      print(path);
      await _player.setAudioSource(AudioSource.uri(Uri.parse(path)));
      // await _player.setAudioSource(AudioSource.uri(Uri.parse(
      //     "https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3")));
    } catch (e) {
      print("Error loading audio source: $e");
    }
  }

To Reproduce (i.e. user steps, not code)
Steps to reproduce the behavior:

  1. Install the latest version of "just_audio_windows."
  2. Use the following code to load an audio file with a space name:
  3. See error

Error messages

Media error: 
flutter: Error loading audio source: Loading interrupted

Expected behavior
The "just_audio_windows" and "just_audio" should load and play audio files with space in their names without any errors.

Screenshots
image

Desktop (please complete the following information):

  • OS: Windows 11
  • Window app

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]

Flutter SDK version

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.10.6, on Microsoft Windows [Version 10.0.19045.3271], locale en-US)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[√] Chrome - develop for the web                                                
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.6.5)   
[√] Android Studio (version 2022.3)                                             
[√] VS Code (version 1.80.2)                                                    
[√] Connected device (3 available)                                              
[√] Network resources    

Additional context

@fvthakor fvthakor added the bug Something isn't working label Aug 3, 2023
@bdlukaa
Copy link
Owner

bdlukaa commented Aug 3, 2023

May be related to #23

@fvthakor
Copy link
Author

yes, may be

@bdlukaa
Copy link
Owner

bdlukaa commented Dec 4, 2023

The issue is probably related to the path encoding. Space should be encoded to %20, but we currently don't do that.

@gstory0404
Copy link

Is there a solution to the space problem now? I tried using + or %20 but it can’t be played.

@bdlukaa
Copy link
Owner

bdlukaa commented Feb 19, 2024

One solution is to create a temporary file with a path without spaces, then delete when unecessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants