Skip to content

Commit

Permalink
Asynchronous music-metadata updates while streaming (#1449)
Browse files Browse the repository at this point in the history
* Ensure that default file/protocol handlers are re-installed after updating.

Previously, they were only installed when the preference was changed.
This caused the handlers to point to non-existing files after updates
occurred and older versions were removed by Squirrel.

Closes #791, #911.

* #1340: Switch to async metadata updates.

* Use fat arrow

* Fix issue track number not displayed if total number of tracks is not defined (common.track.of === null).

* Add disk number in addition to track number.

* Update order of audio properties from: album, track, disk, format to track, disk, album, format

* #1340 Update music-metadata to 2.5.0, enabling async 'per' tag updates
#1452 Fix for playing some '.m4b' files

* #1340 Commented out the metadata event debug output.

* #1340 Remove line comment to get rid of max line length lint error

* Update music-metadata 2.6.0 to fix some async events are getting triggered.

* Return JSX block.

* Get rid of third parameter which is replaced by CSS capitalize

* Fixed error when value is undefined.

* Update music-metadata dependency to 2.6.1.

* fix(package): update music-metadata to version 3.1.0

Closes #1478

* Revert "Ensure that default file/protocol handlers are re-installed after updating."

This reverts commit 39145b2.
  • Loading branch information
Borewit authored and mathiasvr committed Sep 26, 2018
1 parent 6a50fe7 commit 06566d3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"location-history": "^1.0.0",
"material-ui": "^0.17.0",
"mkdirp": "^0.5.1",
"music-metadata": "^2.4.2",
"music-metadata": "^3.1.0",
"network-address": "^1.1.0",
"parse-torrent": "^6.0.1",
"prettier-bytes": "^1.0.1",
Expand Down
4 changes: 1 addition & 3 deletions src/renderer/pages/player-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,7 @@ function renderAudioMetadata (state) {
const elems = []

// Audio metadata: artist(s)
const artist = common.albumartist || common.artist ||
(common.artists && common.artists.filter(function (a) { return a }).join(', ')) ||
'(Unknown Artist)'
const artist = common.artist || common.albumartist
if (artist) {
elems.push((
<div key='artist' className='audio-artist'>
Expand Down
12 changes: 8 additions & 4 deletions src/renderer/webtorrent.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,17 +345,21 @@ function getAudioMetadata (infoHash, index) {
const metadata = { title: file.name }
ipc.send('wt-audio-metadata', infoHash, index, metadata)

const options = { native: false, skipCovers: true, fileSize: file.length }
const options = { native: false,
skipCovers: true,
fileSize: file.length,
observer: event => {
ipc.send('wt-audio-metadata', infoHash, index, event.metadata)
} }
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)
.then(() => {
console.log(`metadata for file='${file.name}' completed.`)
}).catch(function (err) {
return console.log('error getting audio metadata for ' + infoHash + ':' + index, err)
})
Expand Down

0 comments on commit 06566d3

Please sign in to comment.