React-native-track-player: Possible problem with spaces in file path on IOS (crashing app)

Created on 27 Mar 2018  路  1Comment  路  Source: react-native-kit/react-native-track-player

I have a problem with initializing player with MP3 file that have space in path, for example:

/Users/username/Library/Developer/CoreSimulator/Devices/186A325C-45B8-4FF4-861E-8A582D90BCAC/data/Containers/Data/Application/4D4792DA-3135-4695-9457-08A912B237E6/Documents/subfolder/Name of the file with spaces.mp3

The app crashes giving me following Error:
Fatal error: Unexpectedly found nil while unwrapping an Optional value

This problem only occurs on ios and only with files that have spaces in path. On android everything works fine.

App crash occurs in

RNTrackPlayer/Models/MediaURL.swift
Line 28: value = URL(string: url)!

Here is the screenshot from XCode with crash: https://imgur.com/a/YD2lk

Most helpful comment

encodeURI for path solved the problem, it should be noted in documentation, that I need to encode string before adding track to the queue, instead I had to look deeper into other issues few moths ago and read that encoding has been removed from code.

>All comments

encodeURI for path solved the problem, it should be noted in documentation, that I need to encode string before adding track to the queue, instead I had to look deeper into other issues few moths ago and read that encoding has been removed from code.

Was this page helpful?
0 / 5 - 0 ratings