From 8868128d6ec9aa8e4b5b41e1a4b81d71f33abe45 Mon Sep 17 00:00:00 2001 From: Borewit Date: Sun, 17 Sep 2017 20:57:57 +0200 Subject: [PATCH] Add audio format information to play screen. Extended album information with release lebel if available. Make use of music-metadata module (musicmetadata appears to be no longer maintained) --- package.json | 3 ++- src/renderer/pages/player-page.js | 43 +++++++++++++++++++++++++------ src/renderer/webtorrent.js | 16 +++++++----- 3 files changed, 46 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index fe5820cc..72a785ef 100644 --- a/package.json +++ b/package.json @@ -30,8 +30,9 @@ "languagedetect": "^1.1.1", "location-history": "^1.0.0", "material-ui": "^0.17.0", + "mime": "^2.0.1", "mkdirp": "^0.5.1", - "musicmetadata": "^2.0.2", + "music-metadata": "^0.8.4", "network-address": "^1.1.0", "parse-torrent": "^5.7.3", "prettier-bytes": "^1.0.1", diff --git a/src/renderer/pages/player-page.js b/src/renderer/pages/player-page.js index abcf502a..abab1066 100644 --- a/src/renderer/pages/player-page.js +++ b/src/renderer/pages/player-page.js @@ -206,23 +206,42 @@ 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 + let title = common.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 artist = common.albumartist || common.artist || + (common.artists && common.artists.filter(function (a) { return a }).join(', ')) || '(Unknown Artist)' + let album = common.album + if (album && common.year && !album.includes(common.year)) { + album += ' (' + common.year + ')' + if (common.label) { + album += ', ' + common.label + } } let track - if (info.track && info.track.no && info.track.of) { - track = info.track.no + ' of ' + info.track.of + if (common.track && common.track.no && common.track.of) { + track = common.track.no + ' of ' + common.track.of } + let 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') + } + format = format.join(', ') + // Show a small info box in the middle of the screen with title/album/etc const elems = [] if (artist) { @@ -247,6 +266,14 @@ function renderAudioMetadata (state) { )) } + if (format) { + elems.push(( +
+ {format} +
+ )) + } + // Align the title with the other info, if available. Otherwise, center title const emptyLabel = (