-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Media stream info in now playing modal (#233)
* feat: add base codec info to player * fix: redundant console.log * chore: translation * fix: only overflow direct play
- Loading branch information
1 parent
189491b
commit 0d09c6f
Showing
14 changed files
with
148 additions
and
13 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { Text } from '@/components/Typography'; | ||
import useCurrentTrack from '@/utility/useCurrentTrack'; | ||
import React from 'react-native'; | ||
import WaveformIcon from '@/assets/icons/waveform.svg'; | ||
import useDefaultStyles from '@/components/Colors'; | ||
import styled, { css } from 'styled-components/native'; | ||
import { useMemo } from 'react'; | ||
import { t } from '@/localisation'; | ||
|
||
const Container = styled.View` | ||
flex-direction: row; | ||
gap: 8px; | ||
margin-top: 12px; | ||
margin-bottom: 16px; | ||
`; | ||
|
||
const Info = styled.View` | ||
flex-direction: row; | ||
justify-content: space-between; | ||
gap: 8px; | ||
flex-grow: 1; | ||
flex-shrink: 1; | ||
`; | ||
|
||
const Label = styled(Text)<{ overflow?: boolean }>` | ||
opacity: 0.5; | ||
font-size: 13px; | ||
${(props) => props?.overflow && css` | ||
flex: 0 1 auto; | ||
`} | ||
`; | ||
|
||
/** | ||
* This component displays information about the media that is being played | ||
* back, such as the bitrate, sample rate, codec and whether it's transcoded. | ||
*/ | ||
export default function MediaInformation() { | ||
const styles = useDefaultStyles(); | ||
const { track, albumTrack } = useCurrentTrack(); | ||
|
||
const mediaStream = useMemo(() => ( | ||
albumTrack?.MediaStreams?.find((d) => d.Type === 'Audio') | ||
), [albumTrack]); | ||
|
||
if (!albumTrack || !track) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Container> | ||
<WaveformIcon fill={styles.icon.color} height={16} width={16} /> | ||
<Info> | ||
<Label numberOfLines={1} overflow> | ||
{track.isDirectPlay ? t('direct-play') : t('transcoded')} | ||
</Label> | ||
<Label numberOfLines={1}> | ||
{track.isDirectPlay | ||
? mediaStream?.Codec.toUpperCase() | ||
: track.contentType?.replace('audio/', '').toUpperCase() | ||
} | ||
</Label> | ||
{mediaStream && ( | ||
<> | ||
<Label numberOfLines={1}> | ||
{((track.isDirectPlay ? mediaStream.BitRate : track.bitRate) / 1000) | ||
.toFixed(0)} | ||
{t('kbps')} | ||
</Label> | ||
<Label numberOfLines={1}> | ||
{(mediaStream.SampleRate / 1000).toFixed(1)} | ||
{t('khz')} | ||
</Label> | ||
</> | ||
)} | ||
</Info> | ||
</Container> | ||
); | ||
} |
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
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
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
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
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
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
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
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