Fix audio track number not displayed and adds audio disk (media) number (#1454)
* 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 * Return JSX block. * Get rid of third parameter which is replaced by CSS capitalize * Fixed error when value is undefined.
This commit is contained in:
committed by
Mathias Rasmussen
parent
23e1ab6f21
commit
d40449f2ed
@@ -204,6 +204,28 @@ function renderOverlay (state) {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Render track or disk number string
|
||||
* @param common metadata.common part
|
||||
* @param key should be either 'track' or 'disk'
|
||||
* @return track or disk number metadata as JSX block
|
||||
*/
|
||||
function renderTrack (common, key) {
|
||||
// Audio metadata: track-number
|
||||
if (common[key] && 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
|
||||
@@ -227,6 +249,15 @@ function renderAudioMetadata (state) {
|
||||
))
|
||||
}
|
||||
|
||||
// Audio metadata: disk & track-number
|
||||
const count = ['track', 'disk']
|
||||
count.forEach(key => {
|
||||
const nrElem = renderTrack(common, key)
|
||||
if (nrElem) {
|
||||
elems.push(nrElem)
|
||||
}
|
||||
})
|
||||
|
||||
// Audio metadata: album
|
||||
if (common.album) {
|
||||
elems.push((
|
||||
@@ -269,16 +300,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 || ''
|
||||
|
||||
Reference in New Issue
Block a user