Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/zzarcon/audio-cover

Get the cover from an audio file in the browser
https://github.com/zzarcon/audio-cover

audio base64 cover file filereader image preview promise tags

Last synced: about 1 month ago
JSON representation

Get the cover from an audio file in the browser

Awesome Lists containing this project

README

        

# audio-cover [![Build Status](https://travis-ci.org/zzarcon/audio-cover.svg?branch=master)](https://travis-ci.org/zzarcon/audio-cover) [DEMO](https://zzarcon.github.io/audio-cover)
> Get the cover from an audio file in the browser

### Installation

```
$ yarn add audio-cover
```

### Demo

[https://zzarcon.github.io/audio-cover](https://zzarcon.github.io/audio-cover)

### Usage

```javascript
import getAudioCover from 'audio-cover';

try {
const coverSrc = await getAudioCover(file);

console.log('base64 encoded cover', coverSrc)
} catch (e) {
console.log('no cover available', e)
}
```

### Api

```typescript
getAudioCover: (file: File) => Promise
```

> given a file, returns a promise with the cover in base64, otherwise will reject if cover is not present

### Example

```jsx
import getAudioCover from 'audio-cover';

class App extends React.Component {
state = {}

onChange = async (e) => {
try {
const file = e.target.files[0];
const coverSrc = await getAudioCover(file);
this.setState({coverSrc});
} catch(e) {
console.log('error:', e)
}
}

render() {
const {coverSrc} = this.state;

return (





)
}
}
```

### Author πŸ‘ΆπŸΌ

[@zzarcon](https://twitter.com/zzarcon)