Book Image

React Native Cookbook

By : Crysfel Villa, Stan Bershadskiy
Book Image

React Native Cookbook

By: Crysfel Villa, Stan Bershadskiy

Overview of this book

<p>React has taken the web development world by storm, and it is only natural that the unique architecture and its ecosystem of third-party support be applied to native application development. This book will take you through the basics of React Native development all the way through to some more advanced components.</p> <p>This book covers topics in React Native ranging from adding basic UI components to successfully deploying for multiple target platforms. The book follows a top-down approach beginning with building rich user interfaces. These UIs will be created with both built-in and custom components that you will create, style, and animate.</p> <p>You will then learn about different strategies for working with data, including leveraging the popular Redux library and optimizing the performance of the application. Then, you will step further into exposing native device functionality. Finally, we will discuss how to put your application into production and maintain its reliability.</p>
Table of Contents (19 chapters)
React Native Cookbook
Credits
Foreword
About the Authors
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Playing audio files on Android


A benefit that Google likes to claim that Android has over iOS is flexibility in dealing with file storage. Android devices support external SD cards that can be filled with media files, and do not need a proprietary method of adding multimedia as iOS does.

In this recipe, we will use Android's native mediaPicker, which is started from an intent. We will then be able to pick a song and have it play through our application.

Getting ready

For this recipe, we created a React Native application titled AudioPlayer.

In this recipe, we will use the react-native-button library. To install it, run the following command in the terminal from your project root directory:

$ npm install react-native-button --save

Make sure you have music files available in your Music/ directory on your Android device or emulator.

How to do it...

  1. Open the Android project using Android Studio. In Android Studio, select Open an existing Android Studio project and open the android directory of the...