add audioStreams to media info popover

pull/7671/head
Ender 2 months ago committed by GitHub
parent 615a086320
commit 7b38e1595c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -4,34 +4,54 @@ import DescriptionListItem from 'Components/DescriptionList/DescriptionListItem'
import MediaInfoProps from 'typings/MediaInfo';
import formatBitrate from 'Utilities/Number/formatBitrate';
import getEntries from 'Utilities/Object/getEntries';
import styles from './MediaInfo.css';
function MediaInfo(props: MediaInfoProps) {
return (
<DescriptionList>
{getEntries(props).map(([key, value]) => {
const title = key
.replace(/([A-Z])/g, ' $1')
.replace(/^./, (str) => str.toUpperCase());
<div className={styles.mediaInfo}>
<div>
<DescriptionList>
{getEntries(props).map(([key, value]) => {
if (key === 'audioStreams') {
return null;
}
if (!value) {
return null;
}
const title = key
.replace(/([A-Z])/g, ' $1')
.replace(/^./, (str) => str.toUpperCase());
if (key === 'audioBitrate' || key === 'videoBitrate') {
return (
<DescriptionListItem
key={key}
title={title}
data={
<span title={value.toString()}>{formatBitrate(value)}</span>
}
/>
);
}
if (!value) {
return null;
}
return <DescriptionListItem key={key} title={title} data={value} />;
})}
</DescriptionList>
if (key === 'audioBitrate' || key === 'videoBitrate') {
return (
<DescriptionListItem
key={key}
title={title}
data={
<span title={value.toString()}>{formatBitrate(value)}</span>
}
/>
);
}
return <DescriptionListItem key={key} title={title} data={value} />;
})}
</DescriptionList>
</div>
<div className={styles.audioInfo}>
{props.audioStreams && props.audioStreams.length > 0 && (
(() => {
const audioStreamsArray = props.audioStreams.split('+');
return audioStreamsArray.map((audioStream, index) => {
const title = audioStreamsArray.length === 1 ? 'Audio Stream' : `Audio Stream #${index + 1}`;
return <DescriptionListItem key={`audioStream-${index}`} title={title} data={audioStream} />;
});
})()
)}
</div>
</div>
);
}

Loading…
Cancel
Save