doublesymmetry / react-native-track-player

A fully fledged audio module created for music apps. Provides audio playback, external media controls, background mode and more!
https://rntp.dev/
Apache License 2.0
3.3k stars 1.02k forks source link

[iOS] s3 wav audio url is not playing on iOS Simulator #2357

Open janandaraj opened 3 months ago

janandaraj commented 3 months ago

Describe the Bug I'm trying to play s3 pre-signed url it's working fine on android but not playing on iOS throwing some errors

 LOG  Playback State {"error": {"code": "ios_failed_to_load_resource", "message": "Failed to load resource"}, "state": "error"}
 LOG  {"error": "The operation couldn’t be completed. (SwiftAudioEx.AudioPlayerError.PlaybackError error 1.)"}

Steps To Reproduce

Just use any below s3 url in the url section and press play(this url is temporary will be expired)

https://treblearth.s3.us-east-1.amazonaws.com/output_1724225965651.wav?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=ASIAR5NEKHRDMVJEPZVI/20240821/us-east-1/s3/aws4_request&X-Amz-Date=20240821T073926Z&X-Amz-Expires=3600&X-Amz-Security-Token=IQoJb3JpZ2luX2VjEGgaCXVzLWVhc3QtMSJIMEYCIQDhVGwd2Nrj06dpG7DE+aJiCWtirzRKokZ4a/qUjUCg7wIhALBPFrzrH5OqPl2rLGrLocJf8tugVvqQCBU/rLZViUGyKuoCCHEQAhoMMTMxODc3OTc3MTU4IgwJ0FZqtF6t6ThQavkqxwKdhb73BVVdnkxtnp5UsAc5u4EryHlkCg4XdK1hRy027pmAh3buhw/+HKd6SBhUW3i+ET+N/nS9sX02xxc7VyJe4fQcccqxLYgXBZVKRq4BZZv7dQppeZoA06xzF8xQzbUBr+3DuplrB5Gt90XqqclRTZs7SFqq1hZgAZxiW1Lbs6/G4xkbDHmbzDTqv3HaRitLMLJvZYlIH736VTPigxu2EDDftjRn/wc3+fHhXLNUqfyvlR0hV6CND1FR3rt/AtwyTH5gbKEFQAWKqaYRJpBRYab7915bEr4NJQAWTVqjSug+0KBazFwkJ9/Nx7Potv2lcQtz2zZbDexyfKeGprcfO129EJMFznfHhzgY6H6xYOu0s7W9fSBIvNbOzlx2e4VDdceZLKEWNuMvS67QhCmzSkiOHt9ha1dyZa3lP7Rr8m+Nbe0q4QgwrrGWtgY6nQGR/rmFuN7ZXILdIq2OCbKfh3a0Y0cnC9AdVUTrICN+vnUPOpP6BzRyEJdzjV0XKktLZ9kdhLpScsMrps+7F4CE2zDPa1wkAYNUqFm7unlL4aC3gHw36r//U2kOVsSuRM/5fRAfHMeND772YGYpRWNUFnZ+t/NPXgn0ro7vX7M9q33V1y4/D0i4eTyju/AcvMkpVmBIxK3u7eVMx7jz&X-Amz-Signature=06a5d16ecd8c24c78b3e397cc1a9f40cfe1ee81e042e0afca6464a0ea3947256&X-Amz-SignedHeaders=host&response-content-type=audio/wav&x-id=GetObject

Note: I have tried decodingURI component still no luck

Code To Reproduce

var url = above s3 urls;

await TrackPlayer.add({ id: 'trackId', url: url, title: 'Track Title', artist: 'Track Artist', artwork: require('./app/track.png'), album: 'while(1<2)', genre: 'Progressive House, Electro House', date: '2014-05-20T07:00:00+00:00', // RFC 3339 type: TrackType.Default, });

//onButton click await TrackPlayer.play()

Environment Info:

System: OS: macOS 14.5 CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz Memory: 69.14 MB / 16.00 GB Shell: version: "5.9" path: /bin/zsh Binaries: Node: version: 20.13.1 path: /usr/local/bin/node Yarn: version: 3.6.4 path: /usr/local/bin/yarn npm: version: 10.5.2 path: /usr/local/bin/npm Watchman: version: 2024.06.24.00 path: /usr/local/bin/watchman Managers: CocoaPods: version: 1.15.2 path: /usr/local/bin/pod SDKs: iOS SDK: Platforms:

"react-native-track-player": "^4.1.1"

Real device? Or simulator? Simulator - iOS Android works fine

What OS are you running? No

How I can Help Give a fix to resolve that issue even a temp patch works

janandaraj commented 3 months ago

replace fileNameUrl = [NSURL URLWithString:fileNameEscaped]; with fileNameUrl = [NSURL URLWithString:fileName];

I have also tried other packages, like react-native-sound, but it has the same issue. However, I found a solution that seems to fix it: Stack Overflow link. Please check if this applies here as well.

lovegaoshi commented 3 months ago

shouldnt YOU try the solution first by identifying if your link has special charcgers? and stop posting links with expiration tokens they don't work for anyone else

github-actions[bot] commented 3 days ago

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 7 days.