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
- Create a Flutter Windows application using just_audio_windows
- Implement the above code for URL generation and audio playback
- Try playing audio with both test cases
- 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
Which API doesn't behave as documented, and how does it misbehave?
The
playUrlmethod 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
Usage in player service
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
Expected behavior
Current behavior
Platform-specific behavior
Flutter SDK version
Flutter (Channel stable, 3.24.2, on Microsoft Windows [Version 10.0.22631.4602], locale vi-VN)
✅ Windows Version (Installed version of Windows is version 10 or higher)
✅ Visual Studio - develop Windows apps (Visual Studio Community 2022 17.7.4)
Desktop Information:
just_audio: ^0.9.42just_audio_windows: ^0.2.2Additional context