update
This commit is contained in:
+36
-3
@@ -33,6 +33,31 @@ type TrackSortField = 'title' | 'artist' | 'album' | 'server' | 'fileId'
|
||||
type EntrySortField = 'name' | 'count'
|
||||
type SortField = TrackSortField | EntrySortField
|
||||
|
||||
const STREAMABLE_FILE_EXTENSIONS = new Set([
|
||||
'm3u8',
|
||||
'mp3',
|
||||
'm4a',
|
||||
'aac',
|
||||
'flac',
|
||||
'wav',
|
||||
'ogg',
|
||||
'oga',
|
||||
'opus',
|
||||
'mp4',
|
||||
'm4v',
|
||||
'webm',
|
||||
'mkv',
|
||||
'mov',
|
||||
'avi',
|
||||
'wmv',
|
||||
'ogv',
|
||||
'mpeg',
|
||||
'mpg',
|
||||
'ts',
|
||||
'm2ts',
|
||||
'flv',
|
||||
])
|
||||
|
||||
type SortOption = {
|
||||
id: SortField
|
||||
label: string
|
||||
@@ -542,6 +567,12 @@ export default function Library({ mediaSection, onPlayNow, onDownloadTrack, isTr
|
||||
return match ? match[1].toLowerCase() : undefined
|
||||
}
|
||||
|
||||
function canStreamTrack(track: Track, details?: HydrusFileDetails | null) {
|
||||
const extension = getTrackExtension(track, details)
|
||||
if (!extension) return false
|
||||
return STREAMABLE_FILE_EXTENSIONS.has(extension)
|
||||
}
|
||||
|
||||
function getTrackCacheKey(serverId?: string, fileId?: number) {
|
||||
return serverId && fileId != null ? `${serverId}:${fileId}` : ''
|
||||
}
|
||||
@@ -1439,9 +1470,11 @@ export default function Library({ mediaSection, onPlayNow, onDownloadTrack, isTr
|
||||
<Button onClick={handleOpenWeb} disabled={!detailsTrack?.url}>
|
||||
Web
|
||||
</Button>
|
||||
<Button onClick={() => void handleStreamTrack()} disabled={!detailsTrack?.url}>
|
||||
Stream
|
||||
</Button>
|
||||
{detailsTrack?.url && canStreamTrack(detailsTrack, detailsData) && (
|
||||
<Button onClick={() => void handleStreamTrack()}>
|
||||
Stream
|
||||
</Button>
|
||||
)}
|
||||
<Button onClick={handleDownloadTrack} startIcon={<DownloadIcon />} disabled={!detailsTrack?.url || detailsLoading || detailsTrackDownloading}>
|
||||
{detailsTrackDownloading ? 'Downloading...' : 'Download'}
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user