Skip to content

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

License

Notifications You must be signed in to change notification settings

high-performance-hery/react-native-track-player

This branch is 3 commits ahead of, 612 commits behind doublesymmetry/react-native-track-player:main.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

2d011ea Β· Dec 27, 2019
Oct 21, 2019
Oct 20, 2019
Jun 3, 2019
Dec 27, 2019
Jul 3, 2019
Apr 14, 2019
Apr 28, 2018
Jun 3, 2019
Mar 27, 2017
Jun 24, 2019
Apr 17, 2017
Dec 15, 2017
Jul 18, 2019
Jun 24, 2019
Oct 8, 2017
Apr 23, 2019
Jun 27, 2019
Jun 23, 2019

Repository files navigation

downloads npm discord

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!


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 lockscreen, 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
  • Casting support - Seamlessly switch to any Google Cast compatible device, supporting custom media receivers
  • 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

Platform Support

Feature Android iOS Windows
Load from the app bundle βœ“ βœ“ βœ“
Load from the network βœ“ βœ“ βœ“
Load from the file system βœ“ βœ“ βœ“
Adaptive Bitrate Streaming βœ“ βœ“ βœ“
Play/Pause/Stop/Reset βœ“ βœ“ βœ“
Seeking/Volume βœ“ βœ“ βœ“
Remote Media Controls βœ“ βœ“ βœ“
Caching βœ“ βœ— βœ—
Events βœ“ βœ“ βœ“
Background Mode βœ“ βœ“ βœ“
Casting βœ“ βœ— βœ—

Check Platform Support for more information.

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 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 foreground (such as sound effects, voice messages, etc)

react-native-music-controls is meant for apps using those audio modules, although it has a few problems due to how the audio is not directly tied 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

Example

If you want to get started with this module, check the API page. If you want detailed information about the API, check the Documentation. You can also look at our example project here.

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

// Creates the player
TrackPlayer.setupPlayer().then(async () => {

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

    // Starts playing it
    TrackPlayer.play();

});

Maintainers

David Chavez & Guilherme Chaguri

Community

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

Support the development

Support the further development of this and other libraries.

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 47.5%
  • C# 19.0%
  • Swift 17.0%
  • JavaScript 12.8%
  • Objective-C 3.4%
  • Ruby 0.3%