Building a music player
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Building a music player
Hello guys,
I want to build a music player with LiveCode. Could you please give me some advice on how to approach things or give me some reference examples.
The goal is that the user can select his songs from a dropdown list, add them to to a playlist (scrolling list field) where he can change the songs order and choose where to start playing.
Also I want it to display the duration of all the songs combined and things like bpm etc. which are stored in a table in MySQL.
Currently I am trying to do it with a DataGrid, which is not visible.
Whenever the user selects a song from the dropdown and adds it to the playlist - the songs is also inserted in the DataGrid, where I also store more information about it like the path/link of the song.
But I am finding it difficult to somehow synchronize them both. -> for example to keep the order the same, whenever the user reorders songs in the playlist.
Best regards,
Rado
I want to build a music player with LiveCode. Could you please give me some advice on how to approach things or give me some reference examples.
The goal is that the user can select his songs from a dropdown list, add them to to a playlist (scrolling list field) where he can change the songs order and choose where to start playing.
Also I want it to display the duration of all the songs combined and things like bpm etc. which are stored in a table in MySQL.
Currently I am trying to do it with a DataGrid, which is not visible.
Whenever the user selects a song from the dropdown and adds it to the playlist - the songs is also inserted in the DataGrid, where I also store more information about it like the path/link of the song.
But I am finding it difficult to somehow synchronize them both. -> for example to keep the order the same, whenever the user reorders songs in the playlist.
Best regards,
Rado
-
- VIP Livecode Opensource Backer
- Posts: 9580
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Building a music player
Hi.
Never done anything like this, but do go to the dictionary and start reading all about anything with "play" in it. The other stuff is standard LC, and if you need help with that let us know.
There are others that will chime in about playing music files.
But what does this mean:
Never done anything like this, but do go to the dictionary and start reading all about anything with "play" in it. The other stuff is standard LC, and if you need help with that let us know.
There are others that will chime in about playing music files.
But what does this mean:
CraigCurrently I am trying to do it with a DataGrid, which is not visible.
-
- VIP Livecode Opensource Backer
- Posts: 7215
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Building a music player
A datagrid is overkill for this. It would be much easier to manage a regular LC field. You can set the tabstops to make it look like a grid if you need to, and it's much easier to parse each line, move them around, etc.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Building a music player
Sorry, i should have been more specific.
By invisible DataGrid, i mean that the grid is not visible for the user.
Whenever the user builds his playlist(selects songs from the dropdown and adds them), only the song title is inserted into the scrolling list field and more detailed information about the selected song is inserted in the data grid-which stays invisible in the background like: bpm, time, path/link etc.
I have attached a photo from my testing stack.
Thank you both for the input, i will continue to read and try stuff out.
Best regards,
Rado
By invisible DataGrid, i mean that the grid is not visible for the user.
Whenever the user builds his playlist(selects songs from the dropdown and adds them), only the song title is inserted into the scrolling list field and more detailed information about the selected song is inserted in the data grid-which stays invisible in the background like: bpm, time, path/link etc.
I have attached a photo from my testing stack.
Thank you both for the input, i will continue to read and try stuff out.
Best regards,
Rado
-
- Livecode Opensource Backer
- Posts: 9287
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Building a music player
I find datagrids far too complex and go for tableFields in a big way.
Re: Building a music player
I may have misunderstood the premise, but not sure why a data grid or even a normal field is required, if invisible to the user.
I would have thought using an array would achieve the same end result and be much faster? (there is a bit of speed penalty using the data grid).
From the developer point of view, you could use a tree widget to get a graphical representation of the array if that's needed.
The array would basically do exactly the same as the data grid and can be re-ordered as needed, eg if your array is musicA, it would look like this to resemble the image of the DG shown:
musicA[1]["music_fileName"]
musicA[1]["music_time"]
musicA[1]["music_bpm"]
musicA[2]["music_fileName"]
musicA[2]["music_time"]
musicA[2]["music_bpm"]
...
musicA[n]["music_fileName"]
musicA[n]["music_time"]
musicA[n]["music_bpm"]
where the integer key (1,2...n) is basically equivalent the row in the data grid and represents order of this associative (multi-dimensional) array. You can re-order easily, just search the forum for 'sort multidimensional array' there have been many discussions about this...
Now having said that, i'm not sure i understand what the OP is trying to 'synchronise', but it's probably just a matter using the array to determine order...
I would have thought using an array would achieve the same end result and be much faster? (there is a bit of speed penalty using the data grid).
From the developer point of view, you could use a tree widget to get a graphical representation of the array if that's needed.
The array would basically do exactly the same as the data grid and can be re-ordered as needed, eg if your array is musicA, it would look like this to resemble the image of the DG shown:
musicA[1]["music_fileName"]
musicA[1]["music_time"]
musicA[1]["music_bpm"]
musicA[2]["music_fileName"]
musicA[2]["music_time"]
musicA[2]["music_bpm"]
...
musicA[n]["music_fileName"]
musicA[n]["music_time"]
musicA[n]["music_bpm"]
where the integer key (1,2...n) is basically equivalent the row in the data grid and represents order of this associative (multi-dimensional) array. You can re-order easily, just search the forum for 'sort multidimensional array' there have been many discussions about this...
Now having said that, i'm not sure i understand what the OP is trying to 'synchronise', but it's probably just a matter using the array to determine order...
Re: Building a music player
Stam,
thank you very much!
Yes DataGrid was obviously a overkill.. I am trying to do it with arrays now.
Forget about the synchronise part..
Best regards,
Rado
thank you very much!
Yes DataGrid was obviously a overkill.. I am trying to do it with arrays now.
Forget about the synchronise part..
Best regards,
Rado
-
- Livecode Opensource Backer
- Posts: 9287
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Building a music player
Or a scrolling list field.overkill
Re: Building a music player
On select files for import:
Code: Select all
on mouseUp
answer folder "Choose the folder containing the sound files?"
if the result is not cancel then
set the cSoundFilesFolder of this card to it
set the defaultFolder to it
put the files into tFiles
put return before line 1 of field "playlist"
put the files into line 1 of field "playlist"
filter lines of field "playlist" with regex pattern "(?i)\.(wav|aif|wmv|mp3|wma)$"
end if
end mouseUp
Code: Select all
on mouseUp
put the selectedText of me into tFile
set the filename of player "P2" to (the cSoundFilesFolder of this card & "/"& tFile)
put the cUserDefinedName of me into tUserDefindName
start player P2
end mouseUp
If we're treading on thin ice, well you might as well dance.
-
- Posts: 1
- Joined: Mon Feb 20, 2023 8:11 pm
Re: Building a music player
Please let me know if you managed to implement this project. I want to do something similar.rado wrote: ↑Tue May 25, 2021 9:51 amHello guys,
I want to build a music player with LiveCode. Could you please give me some advice on how to approach things or give me some reference examples.
The goal is that the user can select his songs from a dropdown list, add them to to a playlist (scrolling list field) where he can change the songs order and choose where to start playing.
Also I want it to display the duration of all the songs combined and things like bpm etc. which are stored in a table in MySQL.
Currently I am trying to do it with a DataGrid, which is not visible.
Whenever the user selects a song from the dropdown and adds it to the playlist - the songs is also inserted in the DataGrid, where I also store more information about it like the path/link of the song.
But I am finding it difficult to somehow synchronize them both. -> for example to keep the order the same, whenever the user reorders songs in the playlist.
Best regards,
Rado