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: Inconsistent URL handling with apostrophes in just_audio_windows #46

Open
PhuCG opened this issue Dec 20, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@PhuCG
Copy link

PhuCG commented Dec 20, 2024

Which API doesn't behave as documented, and how does it misbehave?
The playUrl method in just_audio_windows behaves inconsistently when handling URLs containing apostrophes. Some text strings with apostrophes work correctly while others fail, despite having similar structures.

Minimal reproduction project
Here's a minimal code example that demonstrates the issue:

Function build audio url

Uri audioUri(
  String content, {
  String style = 'default',
  Speed speed = Speed.normal,
  String? voice,
}) {
  final parameters = {
    'text': content,
    'style': style,
    'speed': speed.id,
    'voice': voice,
  };

  final baseUrl = '${AppEnv().backendUrl}/speech';
  final uri = Uri.parse(baseUrl).replace(
    queryParameters: parameters..removeWhere((key, value) => value == null),
  );

  return uri;
}

Usage in player service

    Future<void> play(
    String content, {
    String? voice,
    String style = 'default',
    Speed speed = Speed.normal,
  }) async {
    final uri = audioUrl(
      content,
      voice: voice ?? azureName,
      style: style,
      speed: speed,
    );
    await audioService.playSource(AudioSource.uri(Uri.parse(uri)));
  }

Test Cases
Case 1: Not working ❌
final text = "I’d like a coffee, please.";
Url: https://api-dev.ahaspeak.app/speech?text=I%E2%80%99d%20like%20a%20coffee,%20please.&style=default&speed=normal&voice=en-US-AriaNeural
Case 2: Working normally ✅
final text = "I'd like an iced coffee, please.";
Url: https://api-dev.ahaspeak.app/speech?text=I'd%20like%20an%20iced%20coffee,%20please.&style=default&speed=normal&voice=en-US-AriaNeural

To Reproduce

  1. Create a Flutter Windows application using just_audio_windows
  2. Implement the above code for URL generation and audio playback
  3. Try playing audio with both test cases
  4. Observe that Case 1 fails while Case 2 works normally

Expected behavior

  • Both text strings should work correctly on Windows platform
  • URL handling should be consistent across all platforms
  • No special handling should be required for apostrophes in text

Current behavior

  • Case 1 fails to play on Windows
  • Case 2 works normally
  • Both cases work correctly on Android, iOS, and Web platforms
  • No error messages are displayed in the console

Platform-specific behavior

  • ❌ Windows (desktop): Inconsistent handling of URLs with apostrophes
  • ✅ Android: Works correctly with both test cases
  • ✅ iOS: Works correctly with both test cases
  • ✅ Web: Works correctly with both test cases

Flutter SDK version
Flutter (Channel stable, 3.24.2, on Microsoft Windows [Version 10.0.22631.4602], locale vi-VN)

  • Flutter version 3.24.2 on channel stable at C:\src\flutter
  • Upstream repository https://github.com/flutter/flutter.git
  • Framework revision 4cf269e36d (4 months ago), 2024-09-03 14:30:00 -0700
  • Engine revision a6bd3f1de1
  • Dart version 3.5.2
  • DevTools version 2.37.2
    ✅ Windows Version (Installed version of Windows is version 10 or higher)
    ✅ Visual Studio - develop Windows apps (Visual Studio Community 2022 17.7.4)
  • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
  • Visual Studio Community 2022 version 17.7.34031.279
  • Windows 10 SDK version 10.0.22621.0

Desktop Information:

  • OS: Windows 10 Version 22631.4602
  • Package Version:
  • just_audio: ^0.9.42
  • just_audio_windows: ^0.2.2

Additional context

  • The issue is Windows-specific
  • Generated URLs work correctly on all other platforms
  • No error messages or exceptions are thrown
  • The difference in behavior appears to be related to URL handling/encoding on Windows
@PhuCG PhuCG added the bug Something isn't working label Dec 20, 2024
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

1 participant