Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/zzarcon/audio-cover
- Owner: zzarcon
- License: mit
- Created: 2018-12-19T11:59:06.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2018-12-24T01:29:49.000Z (about 6 years ago)
- Last Synced: 2024-11-08T09:55:05.812Z (about 2 months ago)
- Topics: audio, base64, cover, file, filereader, image, preview, promise, tags
- Language: TypeScript
- Homepage: https://zzarcon.github.io/audio-cover
- Size: 312 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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)