Severian commited on
Commit
01a52f1
·
verified ·
1 Parent(s): 3691856

Update src/components/ControlPlinth.tsx

Browse files
Files changed (1) hide show
  1. src/components/ControlPlinth.tsx +4 -22
src/components/ControlPlinth.tsx CHANGED
@@ -35,12 +35,12 @@ const ControlPlinth: React.FC<ControlPlinthProps> = ({ tracks, audioControls })
35
  getPreviousTrack
36
  } = useNexusStore()
37
 
38
- // Load initial track and auto-start playback
39
  useEffect(() => {
40
  const loadInitialTrack = async () => {
41
  if (tracks.length > 0 && !playback.currentTrack) {
42
  try {
43
- console.log('Loading initial track:', tracks[0].title)
44
 
45
  // Test basic audio playback first
46
  if (audioControls.testAudioPlayback) {
@@ -58,25 +58,7 @@ const ControlPlinth: React.FC<ControlPlinthProps> = ({ tracks, audioControls })
58
 
59
  setCurrentTrack(tracks[0])
60
  await audioControls.loadTrack(tracks[0])
61
- console.log('Initial track loaded successfully')
62
-
63
- // Auto-start playback if autoplay is enabled (with small delay for better browser compatibility)
64
- if (autoPlayEnabled) {
65
- setTimeout(async () => {
66
- try {
67
- console.log('🎵 Attempting auto-start playback...')
68
- await audioControls.play()
69
- setIsPlaying(true)
70
- console.log('✅ Auto-start playback successful')
71
- } catch (autoplayError) {
72
- console.warn('⚠️ Autoplay blocked by browser policy:', autoplayError)
73
- console.log('💡 User interaction required to start audio - showing play button')
74
- // Don't set error state, just let user manually start
75
- }
76
- }, 500) // 500ms delay to ensure full initialization
77
- } else {
78
- console.log('ℹ️ Autoplay disabled - track loaded but not playing')
79
- }
80
  } catch (error) {
81
  console.error('Failed to load initial track:', error)
82
  setIsTestingAudio(false)
@@ -85,7 +67,7 @@ const ControlPlinth: React.FC<ControlPlinthProps> = ({ tracks, audioControls })
85
  }
86
 
87
  loadInitialTrack()
88
- }, [tracks, playback.currentTrack, setCurrentTrack, audioControls, autoPlayEnabled, setIsPlaying])
89
 
90
  const handlePlayPause = async () => {
91
  if (!playback.currentTrack) {
 
35
  getPreviousTrack
36
  } = useNexusStore()
37
 
38
+ // Load initial track (auto-start is now handled by LivingNexusApp)
39
  useEffect(() => {
40
  const loadInitialTrack = async () => {
41
  if (tracks.length > 0 && !playback.currentTrack) {
42
  try {
43
+ console.log('Loading initial track for controls:', tracks[0].title)
44
 
45
  // Test basic audio playback first
46
  if (audioControls.testAudioPlayback) {
 
58
 
59
  setCurrentTrack(tracks[0])
60
  await audioControls.loadTrack(tracks[0])
61
+ console.log('Initial track loaded successfully (auto-start handled by main app)')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  } catch (error) {
63
  console.error('Failed to load initial track:', error)
64
  setIsTestingAudio(false)
 
67
  }
68
 
69
  loadInitialTrack()
70
+ }, [tracks, playback.currentTrack, setCurrentTrack, audioControls, setIsTestingAudio])
71
 
72
  const handlePlayPause = async () => {
73
  if (!playback.currentTrack) {