# dida.js

> An audio stream blender for the browser

Latest version **1.0.1** (published 2019-11-25) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install dida.js
pnpm add dida.js
yarn add dida.js
bun add dida.js
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-11-25 |
| First published | 2019-09-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 25.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Harvey Zack |
| Maintainers | zhw2590582 |
| Keywords | audio, stream, aac, mp3 |

## Links

- npm: https://www.npmjs.com/package/dida.js
- Repository: https://github.com/zhw2590582/dida.js
- Homepage: https://github.com/zhw2590582/dida.js#readme
- Issues: https://github.com/zhw2590582/dida.js/issues
- npm.io page: https://npm.io/package/dida.js

## Dependencies (1)

- [option-validator](https://npm.io/package/option-validator.md) ^2.0.5

## Alternatives

- [byte-size](https://npm.io/package/byte-size.md) — 2.1M weekly downloads
- [speed-limiter](https://npm.io/package/speed-limiter.md) — 16.0K weekly downloads
- [@powersync/node](https://npm.io/package/@powersync/node.md) — 10.9K weekly downloads
- [@ledgerhq/coin-cardano](https://npm.io/package/@ledgerhq/coin-cardano.md) — 1.0K weekly downloads
- [@jayesol/jayeson.lib.streamfinder](https://npm.io/package/@jayesol/jayeson.lib.streamfinder.md) — 1.0K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2019-11-25
- 1.0.0 — 2019-09-07

## README

# Dida.js

> An audio stream blender for the browser.

## Install

Install with `npm`

```bash
$ npm install dida.js
```

Or install with `yarn`

```bash
$ yarn add dida.js
```

```js
import Dida from 'dida.js';
```

Or umd builds are also available

```html
<script src="path/to/dida.js"></script>
```

Will expose the global variable to `window.Dida`.

## Usage

```js
const dida = new Dida({
  // Default volume
  volume: 0.7,

  // Whether to cache the played audio data
  cache: true,

  // Audio segment size
  chunk: 64 * 1024,

  // Maximum time difference between audio and video synchronization
  maxTimeDiff: 200,

  // Whether to automatically terminate the audio stream
  autoEnd: true,

  // Automatically terminate the audio stream
  autoEndTime: 5000,

  // Activate audio after trying to touch the screen on the mobile
  touchResume: true,

  // Time stamp calibration can be returned when preparing to play the next audio segment
  onNext: t => t,

  // When loading into an audio stream
  onLoad: () => null,

  // Stop playing
  onStop: () => null,

  // When starting to play
  onPlay: () => null,

  // When terminating loading
  onEnd: () => null,

  // When destroyed
  onDestroy: () => null,

  // When audio segmentation decoding is completed
  onDecodeDone: () => null,

  // When decoding is wrong
  onDecodeError: () => null,

  // When the volume changes
  onVolumeChange: () => null,

  // When freeing memory
  onFreeMemory: () => null,
});
```

## Api

```js
// getter and setter of the volume from 0 to 1;
dida.volume;

// Load a Uint8Array and a corresponding timestamp
dida.load(uint8, timestamp);

// Manually terminate loading
dida.end();

// Play by the specified timestamp
dida.play(timestamp);

// Stop play
dida.stop();
```

## License

MIT © [Harvey Zack](https://sleepy.im/)

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