Skip to content

A React Native Module capable of playing Internet Radio Streams

License

Notifications You must be signed in to change notification settings

arakneaweb/react-native-radio-player-akw

 
 

Repository files navigation

react-native-radio-player

FOSSA Status

Play radio streams in react-native

Forked from dehy/react-native-radio-player to be implemented as a foreground service on android

Installation

yarn install react-native-radio-player-akw

Usage

In android/main/AndroidManifest.xml :

  • Add the following permissions
  <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
  <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK"/>
  • Add the following queries intent
  <queries>
    <intent>
      <action android:name="androidx.media3.session.MediaSessionService"/>
    </intent>
  </queries>
  • Add the following service under the application tag
  <service android:name="com.radioplayer.PlaybackService" android:foregroundServiceType="mediaPlayback" android:exported="true">
    <intent-filter>
      <action android:name="androidx.media3.session.MediaSessionService"/>
    </intent-filter>
  </service>
import RadioPlayer, {
  RadioPlayerEvents,
  RadioPlayerMetadata,
} from 'react-native-radio-player';

// ...

const metadataSeparator = "-"; // Used to split artist and title in stream metadata
RadioPlayer.radioURLWithMetadataSeparator('https://...', metadataSeparator);
// or RadioPlayer.radioURL('https://...')
RadioPlayer.stop();
RadioPlayer.play();

// State: error, stopped, playing, paused, buffering
RadioPlayerEvents.addEventListener('stateDidChange', (event) => {
  console.log(event.state);
});
// Metadata: {"artistName": "Example Artist", "trackName": "Example Title"}
RadioPlayerEvents.addListener('MetadataDidChange', (metadata) => {
  console.log(`Artist: ${metadata.artistName}`);
  console.log(`Title: ${metadata.trackName}`);
});

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

FOSSA Status Made with create-react-native-library

About

A React Native Module capable of playing Internet Radio Streams

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Kotlin 35.5%
  • Swift 18.0%
  • TypeScript 13.1%
  • Ruby 12.2%
  • Objective-C 9.0%
  • Objective-C++ 6.6%
  • Other 5.6%