In the chapter Implementing Complex User Interfaces – Part III, we covered building out a relatively sophisticated little audio player in the Creating an Audio Player recipe using the Audio component provided by the Expo SDK. One of the shortcoming of Expo's Audio component, however, is that it cannot be used to play audio when the app is backgrounded. Using the native layer is currently the only way to achieve this.
In this recipe, we will create a native module to show the iOS MediaPicker and then select a music file to play. The selected file will play through the native iOS media player, which allows audio to be played when the app is backgrounded, and allows the user to control the audio via the native iOS control center.