# react-native-ios-audio

> A react-native interface for ios avplayer

Latest version **0.0.2** (published 2016-08-25) · ISC license · 0 weekly downloads

## Install

```sh
npm install react-native-ios-audio
pnpm add react-native-ios-audio
yarn add react-native-ios-audio
bun add react-native-ios-audio
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2016-08-25 |
| First published | 2016-08-25 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Kyumin Cho |
| Maintainers | drivenbyq |

## Links

- npm: https://www.npmjs.com/package/react-native-ios-audio
- Repository: https://github.com/good2hear/react-native-ios-audio
- Homepage: https://github.com/good2hear/react-native-ios-audio#readme
- Issues: https://github.com/good2hear/react-native-ios-audio/issues
- npm.io page: https://npm.io/package/react-native-ios-audio

## Recent versions

- 0.0.2 (latest) — 2016-08-25

## README

# react-native-ios-audio

react-native interface for ios avplayer

# installation
1. Run 'npm install --save react-native-ios-audio'
2. Open your_project.xcodeproj in ios folder using Xcode
3. Add RNAudioPlayer.h, RNAudioPlayer.m files to your_project folder
(they can also be found in node_modules/react-native-ios-audio/react-native-ios-audio)

# usage
```javascript
var player = require('react-native').NativeModules.RNAudioPlayer;

// initialize 
player.initWithURL("http://your_audio_url");

// get duration
player.getDuration((result) => {
  var duration = result - (result % 1)
  var minutes = parseInt((duration / 60));
  var seconds = parseInt(duration % 60);
  minutes = (minutes < 10) ? "0" + minutes : minutes;
  seconds = (seconds < 10) ? "0" + seconds : seconds;
  this.setState({ duration: minutes + ":" + seconds })
})
    
// get current time (every 0.2 seconds)  
var playSubs = NativeAppEventEmitter.addListener('playListener', 
  (result) => {
    var currentTime = result.currentTime - (result.currentTime % 1)
    var minutes = parseInt((currentTime / 60));
    var seconds = parseInt(currentTime % 60);
    minutes = (minutes < 10) ? "0" + minutes : minutes;
    seconds = (seconds < 10) ? "0" + seconds : seconds;
    this.setState({ currentTime: minutes + ":" + seconds })
  }
)

// get notification when play is finished
var finishSubs = NativeAppEventEmitter.addListener('finishListener',
  (result) => {
    this.setState({ finished: "Finished now" })
  }
)

// play
player.play()

// pause
player.pause()
```

---
_Source: https://npm.io/package/react-native-ios-audio · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
