-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fd17383
commit a7ff2cf
Showing
6 changed files
with
127 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
import React from 'react'; | ||
|
||
const FileInput = (props) => { | ||
return <input type="file" {...props} /> | ||
} | ||
|
||
export default FileInput; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
|
||
import MP3Tag from 'mp3tag.js'; | ||
import axios from 'axios'; | ||
|
||
export async function audioTag (url, tags) { | ||
const response = await axios({ | ||
url, | ||
method: 'GET', | ||
responseType: 'blob' | ||
}); | ||
|
||
const buffer = await response.data.arrayBuffer(); | ||
const mp3tag = new MP3Tag(buffer, true); | ||
mp3tag.read(); | ||
if (mp3tag.error) throw new Error(mp3tag.error); | ||
|
||
if (tags.artwork) { | ||
const artworkBytes = new Uint8Array(await tags.artwork.arrayBuffer()); | ||
mp3tag.tags.v2.APIC = [ | ||
{ | ||
format: tags.artwork.type, | ||
type: 3, | ||
description: '', | ||
data: artworkBytes | ||
} | ||
]; | ||
} | ||
|
||
mp3tag.tags.title = tags.title; | ||
mp3tag.tags.artist = tags.artist; | ||
mp3tag.tags.album = tags.album; | ||
mp3tag.save({ | ||
id3v1: { include: false }, | ||
id3v2: { | ||
include: true, | ||
version: 3, | ||
padding: 1024 | ||
} | ||
}); | ||
if (mp3tag.error) throw new Error(mp3tag.error); | ||
|
||
const blob = new Blob([mp3tag.buffer]); | ||
return URL.createObjectURL(blob); | ||
} |