madzadev / audio-player

🎵 Music player with custom controls, playlist, filters, and search.
https://audioplayer.madza.dev
344 stars 49 forks source link

Sort order of Tracks #11

Closed jdaly13 closed 7 months ago

jdaly13 commented 11 months ago

Hello Thank you for your player it is very helpful, I noticed in your code base you are automatically sorting track title alphabetically but if you want to sort the array yourself and control the order of the playlist, currently you are unable to do so

const Player = ({ trackList, includeTags = true, includeSearch = true, showPlaylist = true, autoPlayNextTrack = true, customColorScheme = colors, sortTracks = true, })

if you add sortTracks as a config and a user could pass in False

Then on line 203 of index.js

you can add const sortCompare = (a, b) => { if (!sortTracks) return null return a.title > b.title ? 1 : -1; }

and on line 311 you can just use that fun .sort(sortCompare)

If I put in a PR would you approve?

jagg0409 commented 10 months ago

ey, sorry to bother u maybe u know how to add internal audios like if it was with src

jdaly13 commented 10 months ago

@jagg0409 - I would think they would support relative urls if not - whatever origin you're using from you would need to do the full (absolute) url - like localhost:3000/static/mymp3track.mp3

jagg0409 commented 10 months ago

hey @jdaly13 thanks for the answer, i hv try both but its not working idk if u can help me with that im really trying to learn and this is one of my proyects in case u hv some time to take a look u can check the proyect and more specific the error right here https://github.com/jagg0409/arcticfy-react/blob/master/src/components/albums-inside/AlbumsInside.js thanks a lot for the answer

jdaly13 commented 10 months ago

I would love to help with basic web dev skills but your paths are backwards slashes and also you need to read up on how to access local media within your create react app - https://create-react-app.dev/docs/adding-images-fonts-and-files/ This is not the right forum for this as this thread is originally used for a bug in the original source code of the package you can message me on github and I can try to help you out but again this comment thread is not the appropriate place

madzadev commented 7 months ago

Thanks for the valuable suggestion @jdaly13 ! This could be useful, now deployed!