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 = (
)
elems.unshift((
diff --git a/src/renderer/webtorrent.js b/src/renderer/webtorrent.js
index 2d6c39cd..44b67377 100644
--- a/src/renderer/webtorrent.js
+++ b/src/renderer/webtorrent.js
@@ -8,7 +8,7 @@ const defaultAnnounceList = require('create-torrent').announceList
const electron = require('electron')
const fs = require('fs')
const mkdirp = require('mkdirp')
-const musicmetadata = require('musicmetadata')
+const mm = require('music-metadata')
const networkAddress = require('network-address')
const path = require('path')
const WebTorrent = require('webtorrent')
@@ -334,16 +334,26 @@ function stopServer () {
server = null
}
+console.log('Initializing...')
+
function getAudioMetadata (infoHash, index) {
const torrent = client.get(infoHash)
const file = torrent.files[index]
- musicmetadata(file.createReadStream(), function (err, info) {
- if (err) return console.log('error getting audio metadata for ' + infoHash + ':' + index, err)
- const { artist, album, albumartist, title, year, track, disk, genre } = info
- const importantInfo = { artist, album, albumartist, title, year, track, disk, genre }
- console.log('got audio metadata for %s: %o', file.name, importantInfo)
- ipc.send('wt-audio-metadata', infoHash, index, importantInfo)
- })
+
+ const options = {native: false, skipCovers: true, fileSize: file.length}
+ const onMetaData = file.done
+ // If completed; use direct file access
+ ? mm.parseFile(path.join(torrent.path, file.path), options)
+ // otherwise stream
+ : mm.parseStream(file.createReadStream(), file.name, options)
+
+ onMetaData
+ .then(function (metadata) {
+ console.log('got audio metadata for %s (length=%s): %o', file.name, file.length, metadata)
+ ipc.send('wt-audio-metadata', infoHash, index, metadata)
+ }).catch(function (err) {
+ return console.log('error getting audio metadata for ' + infoHash + ':' + index, err)
+ })
}
function selectFiles (torrentOrInfoHash, selections) {
diff --git a/static/main.css b/static/main.css
index d1258dd5..49f6e35f 100644
--- a/static/main.css
+++ b/static/main.css
@@ -820,12 +820,17 @@ video::-webkit-media-text-track-container {
.audio-metadata label {
display:inline-block;
- width: 100px;
+ width: 120px;
text-align: right;
font-weight: normal;
margin-right: 25px;
}
+.audio-metadata .audio-format,
+.audio-metadata .audio-comments {
+ font-weight: normal;
+}
+
/*
* ERRORS
*/
diff --git a/test/screenshots/win32/play-torrent-wired-2.png b/test/screenshots/win32/play-torrent-wired-2.png
index f7ff49ef..8a3efa51 100644
Binary files a/test/screenshots/win32/play-torrent-wired-2.png and b/test/screenshots/win32/play-torrent-wired-2.png differ
diff --git a/test/screenshots/win32/play-torrent-wired-3.png b/test/screenshots/win32/play-torrent-wired-3.png
index 15d66d22..4be5acf0 100644
Binary files a/test/screenshots/win32/play-torrent-wired-3.png and b/test/screenshots/win32/play-torrent-wired-3.png differ
diff --git a/test/screenshots/win32/play-torrent-wired-4.png b/test/screenshots/win32/play-torrent-wired-4.png
index 15d66d22..02ca813e 100644
Binary files a/test/screenshots/win32/play-torrent-wired-4.png and b/test/screenshots/win32/play-torrent-wired-4.png differ
diff --git a/test/screenshots/win32/play-torrent-wired-5.png b/test/screenshots/win32/play-torrent-wired-5.png
index 22a9a47c..bdb5dabb 100644
Binary files a/test/screenshots/win32/play-torrent-wired-5.png and b/test/screenshots/win32/play-torrent-wired-5.png differ
diff --git a/test/screenshots/win32/play-torrent-wired-fullscreen.png b/test/screenshots/win32/play-torrent-wired-fullscreen.png
index 1710eb6b..22d3d90a 100644
Binary files a/test/screenshots/win32/play-torrent-wired-fullscreen.png and b/test/screenshots/win32/play-torrent-wired-fullscreen.png differ
diff --git a/test/screenshots/win32/play-torrent-wired.png b/test/screenshots/win32/play-torrent-wired.png
index 920ee941..c6d51fe8 100644
Binary files a/test/screenshots/win32/play-torrent-wired.png and b/test/screenshots/win32/play-torrent-wired.png differ