diff --git a/package.json b/package.json index 4820f11d..ed471578 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "location-history": "^1.0.0", "material-ui": "^0.17.0", "mkdirp": "^0.5.1", - "musicmetadata": "^2.0.2", + "music-metadata": "^0.9.8", "network-address": "^1.1.0", "parse-torrent": "^5.7.3", "prettier-bytes": "^1.0.1", diff --git a/src/renderer/lib/torrent-player.js b/src/renderer/lib/torrent-player.js index 6a77d25b..723d2cfa 100644 --- a/src/renderer/lib/torrent-player.js +++ b/src/renderer/lib/torrent-player.js @@ -33,12 +33,18 @@ function isVideo (file) { function isAudio (file) { return [ '.aac', + '.aiff', + '.ape', '.ac3', - '.mp3', - '.ogg', - '.wav', '.flac', - '.m4a' + '.m4a', + '.mp2', + '.mp3', + '.oga', + '.ogg', + '.opus', + '.wav', + '.wma' ].includes(getFileExtension(file)) } diff --git a/src/renderer/pages/player-page.js b/src/renderer/pages/player-page.js index 7e768ca7..c6a2b72a 100644 --- a/src/renderer/pages/player-page.js +++ b/src/renderer/pages/player-page.js @@ -207,25 +207,18 @@ function renderOverlay (state) { function renderAudioMetadata (state) { const fileSummary = state.getPlayingFileSummary() if (!fileSummary.audioInfo) return - const info = fileSummary.audioInfo + const common = fileSummary.audioInfo.common // Get audio track info - let title = info.title - if (!title) { - title = fileSummary.name - } - let artist = info.artist && info.artist[0] - let album = info.album - if (album && info.year && !album.includes(info.year)) { - album += ' (' + info.year + ')' - } - let track - if (info.track && info.track.no && info.track.of) { - track = info.track.no + ' of ' + info.track.of - } + const title = common.title ? common.title : fileSummary.name // Show a small info box in the middle of the screen with title/album/etc const elems = [] + + // Audio metadata: artist(s) + const artist = common.albumartist || common.artist || + (common.artists && common.artists.filter(function (a) { return a }).join(', ')) || + '(Unknown Artist)' if (artist) { elems.push((
@@ -233,14 +226,44 @@ function renderAudioMetadata (state) {
)) } - if (album) { + + // Audio metadata: album + if (common.album) { elems.push((
- {album} + {common.album}
)) } - if (track) { + + // Audio metadata: year + if (common.year) { + elems.push(( +
+ {common.year} +
+ )) + } + + // Audio metadata: release information (label & catalog-number) + if (common.label || common.catalognumber) { + const releaseInfo = [] + if (common.label) { + releaseInfo.push(common.label) + } + if (common.catalognumber) { + releaseInfo.push(common.catalognumber) + } + elems.push(( +
+ { releaseInfo.join(' / ') } +
+ )) + } + + // Audio metadata: track-number + if (common.track && common.track.no && common.track.of) { + const track = common.track.no + ' of ' + common.track.of elems.push((
{track} @@ -248,6 +271,37 @@ function renderAudioMetadata (state) { )) } + // Audio metadata: format + const format = [] + if (fileSummary.audioInfo.format.dataformat) { + format.push(fileSummary.audioInfo.format.dataformat) + } + if (fileSummary.audioInfo.format.bitrate) { + format.push(fileSummary.audioInfo.format.bitrate / 1000 + ' kbps') + } + if (fileSummary.audioInfo.format.sampleRate) { + format.push(fileSummary.audioInfo.format.sampleRate / 1000 + ' kHz') + } + if (fileSummary.audioInfo.format.bitsPerSample) { + format.push(fileSummary.audioInfo.format.bitsPerSample + ' bit') + } + if (format.length > 0) { + elems.push(( +
+ { format.join(', ') } +
+ )) + } + + // Audio metadata: comments + if (common.comment) { + elems.push(( +
+ {common.comment.join(' / ')} +
+ )) + } + // Align the title with the other info, if available. Otherwise, center title const emptyLabel = (