-
-
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
Fix audio track number not displayed and adds audio disk (media) number #1454
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a30d804
Fix issue track number not displayed if total number of tracks is not…
Borewit c2594f5
Add disk number in addition to track number.
Borewit c7f30df
Update order of audio properties from: album, track, disk, format to …
Borewit e2448ca
Return JSX block.
Borewit 4306569
Get rid of third parameter which is replaced by CSS capitalize
Borewit 8e91840
Fixed error when value is undefined.
codealchemist File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -227,6 +248,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)) | ||
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. Here we can remove the third param, which is not needed anymore. 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. Oops, yeah sure. |
||
if (nrElem) { | ||
elems.push(nrElem) | ||
} | ||
}) | ||
|
||
// Audio metadata: album | ||
if (common.album) { | ||
elems.push(( | ||
|
@@ -269,16 +299,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 || '' | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 we can use CSS to capitalize the label.
If we do that we would only pass
key
and avoid operating directly on the string.On
renderTrack
we would be able to do: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.
I have no experience with React, I blindly followed your suggestion.
But seems to do the job, so well done.