Sajeee-1 / react-native-track-player

A fully fledged audio module created for music apps. Provides audio playback, external media controls, chromecast support, background mode and more!

Home Page:https://react-native-track-player.js.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

downloads npm discord

A fully-fledged audio module created for music apps. Provides audio playback, external media controls, background mode and more!


⚠️ V2

WARNING: You're currently looking at our v2 branch which is still in progress.

We are currently hard at work trying to release 2.0. We have a 2.0.0-rc18 prerelease out and we're hoping to finalize this release soon (you can track the progress here). We do not have a changelog yet we will wrap that up once the release is more stable.

If you're looking for the readme & examples for react-native-track-player v1.2.7 - find it on github.

Features

  • Lightweight - Optimized to use the least amount of resources according to your needs
  • Feels native - As everything is built together, it follows the same design principles as real music apps do
  • Multi-platform - Supports Android, iOS and Windows
  • Media Controls support - Provides events for controlling the app from a Bluetooth device, the lock screen, a notification, a smartwatch or even a car
  • Local or network, files or streams - It doesn't matter where the media belongs, we've got you covered
  • Adaptive bitrate streaming support - Support for DASH, HLS or SmoothStreaming
  • Caching support - Cache media files to play them again without an internet connection
  • Background support - Keep playing audio even after the app is in background
  • Fully Customizable - Even the notification icons are customizable!
  • Supports React Hooks 🎣 - Includes React Hooks for common use-cases so you don't have to write them

Quick Guides

Why another music module?

After trying to team up modules like react-native-sound, react-native-music-controls and react-native-google-cast, I've noticed, that their structure and the way should be tied together can cause a lot of problems (mainly on Android). Those can heavily affect the app stability and user experience.

All audio modules (like react-native-sound) don't play in a separated service on Android, which should only be used for simple audio tracks in the foreground (such as sound effects, voice messages, etc.)

react-native-music-controls is meant for apps using those audio modules, but it has a few problems: the audio isn't tied directly to the controls. It can be pretty useful for casting (such as Chromecast).

react-native-google-cast works pretty well and also supports custom receivers, but it has fewer player controls, it's harder to integrate and still uses the Cast SDK v2.

First Steps

If you want to get started with this module, check the Getting Started page.

If you want detailed information about the API, check the Documentation. You can also look at our example project here.

Example

A basic example of how to play a track:

import TrackPlayer from 'react-native-track-player';

const start = async () => {
    // Set up the player
    await TrackPlayer.setupPlayer();

    // Add a track to the queue
    await TrackPlayer.add({
        id: 'trackId',
        url: require('track.mp3'),
        title: 'Track Title',
        artist: 'Track Artist',
        artwork: require('track.png')
    });

    // Start playing it
    await TrackPlayer.play();
};
start();

Core Team ✨


David Chavez


Guilherme Chaguri


Dustin Bahr

Community

You can find us as part of the React Native Folks Discord in the #react-native-track-player channel.

About

A fully fledged audio module created for music apps. Provides audio playback, external media controls, chromecast support, background mode and more!

https://react-native-track-player.js.org/

License:Apache License 2.0


Languages

Language:Java 45.3%Language:C++ 21.6%Language:Swift 17.7%Language:TypeScript 9.3%Language:Objective-C 4.1%Language:JavaScript 1.1%Language:Ruby 0.6%Language:Starlark 0.3%Language:C 0.2%