react-native-track-player

doublesymmetry活跃维护

为 React Native 提供功能完整的音频播放器,支持后台播放、缓存预加载、Android Auto 和媒体控制,解决跨平台音乐播放的集成难题。

The best audio player for React Native. Built on the New Architecture — Android Auto, caching, preloading, background playback, and more.

v5发布于 2026-09-30 15:38 UTC3,708star1,199fork同步于 2026-11-10 11:40 UTC

怎么上手

由 README 提炼,执行前请确认
npm install @rntp/player
cd ios && pod install
硬件要求按 README 说明

README 未说明

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

React Native 音频播放器,基于新架构实现后台播放、缓存与预加载

为 React Native 提供功能完整的音频播放器,支持后台播放、缓存预加载、Android Auto 和媒体控制,解决跨平台音乐播放的集成难题。

核心能力

  • 基于 JSI/TurboModule 同步调用原生接口
  • 支持后台播放与锁屏、通知栏、耳机控制
  • 内置音频缓存,减少带宽并支持离线播放
  • 预加载后续曲目,实现接近无缝的播放
  • 提供 useIsPlaying、useProgress 等 React Hooks

容易踩的坑

V5 起商用需付费授权,个人和教育用途免费;V5 与 V4 不兼容,旧项目需留在 v4 分支;要求 React Native 0.76+ 且启用新架构与 bridgeless 模式

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

1 个版本v5
  1. v5Release notes最新正式版2026-09-30 · 2026-09-30 15:38 UTC

    Release notes for every version live at rntp.dev/changelog.

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    react-native-track-player

    The premium audio player for React Native.

    Built on the New Architecture with synchronous native calls — background playback, Android Auto, audio caching, preloading, and more.

    [!IMPORTANT] Starting with V5, react-native-track-player is commercially licensed. Personal and educational use remains free; commercial use requires a paid license — see rntp.dev/pricing. V4 and earlier remain available under Apache-2.0 on the v4 branch.

    npm version npm downloads License


    Features

    • Simple TypeScript API — Clean, minimal API fully typed for React Native developers
    • New Architecture Native — Built on JSI with TurboModule support, no bridge overhead, no jitter
    • Background Playback — Audio continues when the app is backgrounded or screen is off
    • Android Auto — Full support for native car dashboard integration
    • Preloading — Background buffering of upcoming tracks for gapless-like playback
    • Audio Caching — Built-in caching to reduce bandwidth and enable offline playback
    • Remote Controls — Lock screen, notification controls, and headset support out of the box
    • React Hooks — usePlaybackState, useIsPlaying, useProgress, useActiveMediaItem, and more

    Requirements

    • React Native 0.76 or later
    • New Architecture enabled (Fabric + TurboModules), with bridgeless enabled

    Installation

    npm install @rntp/player
    

    Then for iOS:

    cd ios && pod install
    

    Android links automatically.

    Quick Start

    import TrackPlayer from '@rntp/player';
    
    // 1. Set up the player (call once at app startup, in the foreground on Android)
    await TrackPlayer.setupPlayer({
      contentType: 'music',
      handleAudioBecomingNoisy: true,
      android: { wakeMode: 'network' },
    });
    
    // 2. Add tracks and play
    await TrackPlayer.setMediaItems([
      {
        url: 'https://example.com/track.mp3',
        title: 'Track Title',
        artist: 'Artist Name',
        artwork: 'https://example.com/artwork.jpg',
      },
    ]);
    
    TrackPlayer.play();
    
    // 3. Use hooks in your UI
    import { useIsPlaying, useProgress, useActiveMediaItem } from '@rntp/player';
    
    function PlayerUI() {
      const { playing } = useIsPlaying();
      const { position, duration } = useProgress();
      const track = useActiveMediaItem();
    
      return (/* your player UI */);
    }
    

    Documentation

    Full documentation, API reference, and guides are available at rntp.dev.

    V5

    V5 is a complete rewrite and is not backwards-compatible with V4.

    Key improvements in V5:

    • Built on JSI — getProgress(), getQueue(), isPlaying() return synchronously
    • Full TurboModule and Fabric support
    • Rewritten Android and iOS native layers

    License

    Free for non-commercial use. Commercial use requires a license.

    See license.txt for details or visit rntp.dev/pricing to purchase a commercial license.

    For questions: [email protected]