Add albumArtUrl to state

Helps with #510
This commit is contained in:
Jordan Eldredge 2018-04-18 09:10:54 -07:00
parent 8d7ad0acc1
commit b86413cda3
2 changed files with 10 additions and 3 deletions

View file

@ -360,10 +360,16 @@ export function fetchMediaTags(file, id) {
dispatch({ type: MEDIA_TAG_REQUEST_INITIALIZED, id });
return genMediaTags(file)
.then(data => {
const { artist, title } = data.tags;
// There's more data here, but we don't have a use for it yet:
// https://github.com/aadsm/jsmediatags#shortcuts
dispatch({ type: SET_MEDIA_TAGS, artist, title, id });
const { artist, title, picture } = data.tags;
let albumArtUrl = null;
if (picture) {
const byteArray = new Uint8Array(picture.data);
const blob = new Blob([byteArray], { type: picture.type });
albumArtUrl = URL.createObjectURL(blob);
}
dispatch({ type: SET_MEDIA_TAGS, artist, title, albumArtUrl, id });
})
.catch(() => {
dispatch({ type: MEDIA_TAG_REQUEST_FAILED, id });

View file

@ -179,7 +179,8 @@ const playlist = (state = defaultPlaylistState, action) => {
...state.tracks[action.id],
mediaTagsRequestStatus: MEDIA_TAG_REQUEST_STATUS.COMPLETE,
title: action.title,
artist: action.artist
artist: action.artist,
albumArtUrl: action.albumArtUrl
}
}
};