Skip to content

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

Description

@fvthakor

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions