feat: add 'single' play mode option and corresponding icon in MusicPlayer
This commit is contained in:
@@ -17,7 +17,8 @@ import {
|
|||||||
List,
|
List,
|
||||||
Maximize2,
|
Maximize2,
|
||||||
Minimize2,
|
Minimize2,
|
||||||
Minus
|
Minus,
|
||||||
|
ArrowRightToLine
|
||||||
} from 'lucide-react'
|
} from 'lucide-react'
|
||||||
import { formatDuration } from '@/lib/format-duration'
|
import { formatDuration } from '@/lib/format-duration'
|
||||||
|
|
||||||
@@ -79,13 +80,15 @@ export function MusicPlayer() {
|
|||||||
return <Repeat1 className="h-4 w-4" />
|
return <Repeat1 className="h-4 w-4" />
|
||||||
case 'random':
|
case 'random':
|
||||||
return <Shuffle className="h-4 w-4" />
|
return <Shuffle className="h-4 w-4" />
|
||||||
|
case 'single':
|
||||||
|
return <ArrowRightToLine className="h-4 w-4" />
|
||||||
default:
|
default:
|
||||||
return <Play className="h-4 w-4" />
|
return <Play className="h-4 w-4" />
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handlePlayModeToggle = () => {
|
const handlePlayModeToggle = () => {
|
||||||
const modes = ['continuous', 'loop-playlist', 'loop-one', 'random'] as const
|
const modes = ['continuous', 'loop-playlist', 'loop-one', 'random', 'single'] as const
|
||||||
const currentIndex = modes.indexOf(playMode)
|
const currentIndex = modes.indexOf(playMode)
|
||||||
const nextIndex = (currentIndex + 1) % modes.length
|
const nextIndex = (currentIndex + 1) % modes.length
|
||||||
setPlayMode(modes[nextIndex])
|
setPlayMode(modes[nextIndex])
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export interface Track {
|
|||||||
url: string
|
url: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export type PlayMode = 'continuous' | 'loop-playlist' | 'loop-one' | 'random'
|
export type PlayMode = 'continuous' | 'loop-playlist' | 'loop-one' | 'random' | 'single'
|
||||||
|
|
||||||
interface MusicPlayerContextType {
|
interface MusicPlayerContextType {
|
||||||
// Playback state
|
// Playback state
|
||||||
|
|||||||
Reference in New Issue
Block a user