如何在 React Native 中处理耳机的播放/暂停按钮 [英] how to handle play/pause button of the headphones in react native

查看:55
本文介绍了如何在 React Native 中处理耳机的播放/暂停按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想处理播放/暂停按钮.如果耳机的按钮被点击,我会做一些思考.我可以控制音量增大或减小按钮,但无法控制播放/暂停按钮.有没有办法做到这一点?

I just want to handle play/pause button. If the button of the headphones is clicked,I will do somethink. I can control the volume-up or down button but I could not control the play/pause button. Is there any way to do that ?

推荐答案

有一个名为 react-native-music-control 的插件可以处理那些与侦听器有关的事情,但是在支持两个平台 (android +ios).

There is a plugin called react-native-music-control that handles those things with listeners but there are some limitations when it comes to support both platforms (android + ios).

在这里查看他们的文档非常简单.https://github.com/tanguyantoine/react-native-音乐控制#register-to-events

Check here their documentation is very straight forward. https://github.com/tanguyantoine/react-native-music-control#register-to-events

这篇关于如何在 React Native 中处理耳机的播放/暂停按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆