npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-volume-monitoring

v1.0.0

Published

Volume Monitoring For React Native ios

Downloads

2

Readme

react-native-volume-monitoring

功能:

监听实时语音音量变化。

使用步骤

一、链接VolumeMonitoring库

参考:https://reactnative.cn/docs/0.50/linking-libraries-ios.html#content

手动添加:

1、添加react-native-volume-monitoring插件到你工程的node_modules文件夹下

2、添加VolumeMonitoring 库中的.xcodeproj文件在你的工程中

3、点击你的主工程文件,选择 Build Phases,然后把刚才所添加进去的.xcodeproj下的Products文件夹中的静态库文件(.a文件),拖到Link Binary With Libraries组内。

自动添加:
$ npm install react-native-volume-monitoring --save 
或
$ yarn add react-native-volume-monitoring

$ react-native link

二、简单使用

方法

Event Name | Returns | Notes ------ | ---- | ------- startVolumeMonitoring | null | 开始音量检测 cancleVolumeMonitoring | null | 取消音量检测 VolumeMonitoring | res | 音量检测结果监听事件

js文件
//index.ios.js

import React, { Component } from 'react';
import {
Platform,
StyleSheet,
Text,
View,
Dimensions,
Alert,
ScrollView,
TouchableHighlight,
NativeEventEmitter
} from 'react-native';

import VolumeMonitoring from 'react-native-volume-monitoring';


export default class App extends Component<{}> {


constructor(props: Object) {
super(props)

this.state = {
value: '',
}
}

componentDidMount() {

const VolumeMonitoringEmitter = new NativeEventEmitter(VolumeMonitoring);

const subscription = VolumeMonitoringEmitter.addListener(
'VolumeMonitoring',
(response) => {
this.setState({
value: response.volume,
});
}
);
}

componentWillUnmount(){
//取消订阅
subscription.remove();
}

//开始音量检测
startVolumeMonitoring() {
VolumeMonitoring.startVolumeMonitoring();
}

//取消音量检测
cancleVolumeMonitoring() {
VolumeMonitoring.cancleVolumeMonitoring();
this.setState({
value: '',
});
}


render() {
return (
<ScrollView contentContainerStyle={styles.wrapper}>

<Text style={styles.pageTitle}>{'音量:'+this.state.value}</Text>

<TouchableHighlight 
style={styles.button} underlayColor="#f38"
onPress={this.startVolumeMonitoring}>
<Text style={styles.buttonTitle}>startVolumeMonitoring</Text>
</TouchableHighlight>

<TouchableHighlight 
style={styles.button} underlayColor="#f38"
onPress={this.cancleVolumeMonitoring.bind(this)}>
<Text style={styles.buttonTitle}>cancleVolumeMonitoring</Text>
</TouchableHighlight>


</ScrollView>
);
}
}

const styles = StyleSheet.create({
wrapper: {
paddingTop: 60,
paddingBottom: 20,
alignItems: 'center',
},
pageTitle: {
paddingBottom: 40
},
button: {
width: 200,
height: 40,
marginBottom: 10,
borderRadius: 6,
backgroundColor: '#f38',
alignItems: 'center',
justifyContent: 'center',
},
buttonTitle: {
fontSize: 16,
color: '#fff'
},
});

效果展示: