You can check for free downloads by checking if there is a song price.
For songs that have already been purchased, you'd need to check the purchase history for the viewing user and if the song has been purchased send the user to their My Files. This would be a lot of work for the server to check on every show of every song in every list for every visitor, so probably best to avoid doing it.
You can use an onclick to show a popup. If you are using a core page button the onclick will be the third parameter.
Or in a link
onclick="if(confirm('Are you sure you want to download this? ')){ window.location='{$jamroom_url}/{$murl}/download/audio_file/{$item._item_id}' }"
But as with the check for songs that have already been purchased, you will need to look up that information for every user and every song just to show a list of songs. So I'd say it would be better to check after the confused user has accidentally clicked to try to buy the same song again rather than checking every song for every user before displaying your list of songs just in case a user gets confused and tries to buy the same song again.
--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)