I am developing this audio player app for iOS and after that will be ported to Android too and up until now everything is working fine, untill I got to the point that I had to implement the background play of audio. So basically if I'm switching between different views I have to keep the audio playing. I did a research on that but have not found an answer yet. It's more like keeping a task running in background, so if I am switching between views that task would not be stopped. I've seen some questions related to this one but they werent specifically related between keeping a task running on different views.
You're right about the background task nature of what you're looking at. It is definitely something that should be decoupled from the view. I'd recommend setting up a new module that deals with music management in isolation. Have it export public play and stop methods. Then in your root React Component file require that module and invoke play and stop in your componentWillMount and componentWillUnmount methods. Thus your sound won't be coupled to a specific component and persists while switching views.
This looks like an adequate library to help you with playback: https://github.com/zmxv/react-native-sound