2021-04-06 17:30:17 -08:00
|
|
|
import React from 'react'
|
|
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
|
import Chip from '@material-ui/core/Chip'
|
2021-04-06 18:18:48 -08:00
|
|
|
import config from '../config'
|
2021-04-06 17:30:17 -08:00
|
|
|
|
2021-04-06 18:18:48 -08:00
|
|
|
const llFormats = new Set(config.losslessFormats.split(','))
|
|
|
|
|
const placeholder = 'N/A'
|
|
|
|
|
|
|
|
|
|
export const QualityInfo = ({ record, ...rest }) => {
|
|
|
|
|
let { suffix, bitRate } = record
|
|
|
|
|
let info = placeholder
|
|
|
|
|
|
|
|
|
|
if (suffix) {
|
|
|
|
|
suffix = suffix.toUpperCase()
|
|
|
|
|
info = suffix
|
|
|
|
|
if (!llFormats.has(suffix)) {
|
|
|
|
|
info += ' ' + bitRate
|
|
|
|
|
}
|
2021-04-06 17:30:17 -08:00
|
|
|
}
|
2021-04-06 18:18:48 -08:00
|
|
|
|
|
|
|
|
return <Chip {...rest} variant="outlined" label={info} />
|
2021-04-06 17:30:17 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QualityInfo.propTypes = {
|
|
|
|
|
record: PropTypes.object.isRequired,
|
|
|
|
|
size: PropTypes.string,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QualityInfo.defaultProps = {
|
|
|
|
|
size: 'small',
|
|
|
|
|
record: {},
|
|
|
|
|
}
|