-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Asynchronous music-metadata updates while streaming #1449
Changes from 15 commits
39145b2
0e0b0e6
198c62e
b185a62
a30d804
c2594f5
c7f30df
b73db82
8848534
f925b1f
30276d5
c6944a3
090b906
e2448ca
c85f331
4306569
e508b13
8e91840
50bf7e1
ee9bf1d
e34edc2
db50e97
f7719a7
78b71d3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -204,6 +204,27 @@ function renderOverlay (state) { | |
) | ||
} | ||
|
||
/** | ||
* Render track or disk number string | ||
* @param key should be either 'track' or 'disk' | ||
* @param label should be either 'Track' or 'Disk' | ||
*/ | ||
function renderTrack (common, key, label) { | ||
// Audio metadata: track-number | ||
if (common[key].no) { | ||
let str = `${common[key].no}` | ||
if (common[key].of) { | ||
str += ` of ${common[key].of}` | ||
} | ||
const style = { textTransform: 'capitalize' } | ||
return ( | ||
<div className={`audio-${key}`}> | ||
<label style={style}>{key}</label> {str} | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
function renderAudioMetadata (state) { | ||
const fileSummary = state.getPlayingFileSummary() | ||
if (!fileSummary.audioInfo) return | ||
|
@@ -216,9 +237,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(', ')) || | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is still available, but common.artist is already designed to summarize the artist(s) in a single string. In other words, the code removed is already done in music-metadata. |
||
'(Unknown Artist)' | ||
const artist = common.artist || common.albumartist | ||
if (artist) { | ||
elems.push(( | ||
<div key='artist' className='audio-artist'> | ||
|
@@ -227,6 +246,15 @@ function renderAudioMetadata (state) { | |
)) | ||
} | ||
|
||
// Audio metadata: disk & track-number | ||
const count = ['track', 'disk'] | ||
count.forEach(key => { | ||
const nrElem = renderTrack(common, key, key[0].toUpperCase() + key.substring(1)) | ||
if (nrElem) { | ||
elems.push(nrElem) | ||
} | ||
}) | ||
|
||
// Audio metadata: album | ||
if (common.album) { | ||
elems.push(( | ||
|
@@ -269,16 +297,6 @@ function renderAudioMetadata (state) { | |
)) | ||
} | ||
|
||
// Audio metadata: track-number | ||
if (common.track && common.track.no && common.track.of) { | ||
const track = common.track.no + ' of ' + common.track.of | ||
elems.push(( | ||
<div key='track' className='audio-track'> | ||
<label>Track</label>{track} | ||
</div> | ||
)) | ||
} | ||
|
||
// Audio metadata: format | ||
const format = [] | ||
fileSummary.audioInfo.format = fileSummary.audioInfo.format || '' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this enhancement is worth its own PR.
But if the other folks agree we can add it here.
Really nice catch BTW :)