slash9494 / react-modern-audio-player

🔊 Simple, accessible and flexible audio player
MIT License
276 stars 17 forks source link

Error: fetch url missing #25

Open jhoanborges opened 1 month ago

jhoanborges commented 1 month ago

According to the docs, playlist should be an empty array [] but if array is empty is gets an error: Error: fetch url missing


    const [playList, setPlayList] = useState<PlayList>([]);

        <AudioPlayer
                            playList={playList}
                            audioInitialState={{
                                muted: false,
                                volume: 1,
                                curPlayId: 1,
                            }}
                            activeUI={{
                                ...activeUI,
                                progress: progressType
                            }}
                            placement={{
                                player: playerPlacement,
                                interface: {
                                    templateArea: interfacePlacement
                                },
                                playList: playListPlacement,
                                volumeSlider: volumeSliderPlacement
                            }}
                            rootContainerProps={{
                                colorScheme: theme,
                                width
                            }}
                        />

image

agohorel commented 1 month ago

@jhoanborges if you look at the types for Playlist you can see which fields you need for each item in the playlist. The minimum information required is a src to the audio file as well as a numeric id for each item in the playlist. The src is used to generate the waveform, so no src = no waveform. I hope this helps!