百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
R

react-native-music-control

> 前端框架
开源

在锁屏和iOS和Android通知中心显示并管理媒体控制.

694 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

在锁屏和iOS和Android通知中心显示并管理媒体控制.

⚠️ NO LONGER MAINTAINED ⚠️

Please use react-native-track-player instead ✅


react-native-music-control

Display and manage media controls on lock screen and notification center for iOS and Android.

Project

With Yarn:

yarn add react-native-music-control

or with NPM:

npm install react-native-music-control --save

iOS

  1. pod install --project-directory=ios/
  2. Enable Audio Background mode in XCode project settings

Android

  1. Add the android.permission.FOREGROUND_SERVICE permission to your AndroidManifest.xml:
  2. Set the launchMode of MainActivity to singleTask by adding in AndroidManifest.xml:

For React Native {

  this.props.dispatch(playRemoteControl());
})

// on iOS this event will also be triggered by audio router change events
// happening when headphones are unplugged or a bluetooth audio peripheral disconnects from the device
MusicControl.on(Command.pause, ()=> {
  this.props.dispatch(pauseRemoteControl());
})

MusicControl.on(Command.stop, ()=> {
  this.props.dispatch(stopRemoteControl());
})

MusicControl.on(Command.nextTrack, ()=> {
  this.props.dispatch(nextRemoteControl());
})

MusicControl.on(Command.previousTrack, ()=> {
  this.props.dispatch(previousRemoteControl());
})

MusicControl.on(Command.changePlaybackPosition, (playbackPosition)=> {
  this.props.dispatch(updateRemoteControl(playbackPosition));
})

MusicControl.on(Command.seekForward, ()=> {});
MusicControl.on(Command.seekBackward, ()=> {});

MusicControl.on(Command.seek, (pos)=> {}); // Android only (Seconds)
MusicControl.on(Command.volume, (volume)=> {}); // Android only (0 to maxVolume) - Only fired when remoteVolume is enabled

// Android Only (Boolean for RATING_HEART or RATING_THUMBS_UP_DOWN, Number for other types)
MusicControl.on(Command.setRating, (rating)=> {});

MusicControl.on(Command.togglePlayPause, ()=> {}); // iOS only
MusicControl.on(Command.enableLanguageOption, ()=> {}); // iOS only
MusicControl.on(Command.disableLanguageOption, ()=> {}); // iOS only
MusicControl.on(Command.skipForward, ()=> {});
MusicControl.on(Command.skipBackward, ()=> {});

// Android Only
MusicControl.on(Command.closeNotification, ()=> {
  this.props.dispatch(onAudioEnd());
})

}

…

MusicControl.on(Command.play, () => { // A valid funcion must be present player.play() })


## Customization

It is possible to customize the icon used in the notification on Android. By default you can add a drawable resource to your package with the file name `music_control_icon` and the notification will use your custom icon. If you need to specify a custom icon name, or change your notification icon during runtime, the `setNowPlaying` function accepts a string for an Android drawable resource name in the `notificationIcon` prop. Keep in mind that just like with `music_control_icon` the resource specified has to be in the drawable package of your Android app.

```javascript
MusicControl.setCustomNotificationIcon('my_custom_icon')

Contributing

Of course! We are waiting for your PR :)

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Javaandroidioslockscreennow-playing

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类前端框架
定价开源

> 相关工具

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架