react-native-streaming-player
IOS class to add react-native implementation for web audio urls(look at AVPlayer documentation for audio compatibility). Tested using mp3 urls.
Add it to your project
- Run 'npm install react-native-streaming-player --save'
- Add .h and .m files to "your_project_name" folder in XCode and restart application
- var audio = require('react-native').NativeModules.RNStreamingAudioPlayer;
Basic usage
//To initialize the audio clip with meta data var songInfo = name: "Name of the song" artist_name: "Song's band name" artwork: "Song's cover image"; audio; //To retrieve the length of the clip in seconds as a floataudio; //To play audio clipaudio; //To pause audio clipaudio; //To set volume of the playeraudio; //To seek to a specific time in secondsaudio;
New Additions
- Audio will automatically set time to zero once it has reached the end
- New Function to seek to a certain time in the audio clip
// Import var NativeEventEmitter = ;const audioEvent = NativeModulesRNStreamingAudioPlayer; //Listen for audio endvar subscription = NativeAppEventEmitter; //Listen for previous song action from Media centervar subscription = NativeAppEventEmitter; //Listen for next song action from Media centervar subscription = NativeAppEventEmitter;