Hi,
I think I know what is going on and how to make it play your songs.
If your songs are uploaded to the Media console in PowerApps, you will need to reference them either by
- collecting them to a Collection or
- by invoking the Table() function--
They are the only ones that can recall things like that. Unfortunately, if you store the name of a media file in an Excel table, it is only treated as text and can't retrieve the media file uploaded in Media.
So you will need to revise the Items property of the Listbox to something like:
Table(
{id: 1, type: "Jazz", author: "Louis Armstrong", song: 'what-a-wonderful-world'},
{id: 2, type: "Jazz", author: "Louis Armstrong", song: 'what-a-wonderful-world'},
{id: 3, type: "Jazz", author: "Louis Armstrong", song: 'what-a-wonderful-world'},
)
Or Collect it to a collection so it can be referenced in multiple places:
Collect(songstable,
Table(
{id: 1, type: "Jazz", author: "Louis Armstrong", song: 'what-a-wonderful-world'},
{id: 2, type: "Jazz", author: "Louis Armstrong", song: 'what-a-wonderful-world'},
{id: 3, type: "Jazz", author: "Louis Armstrong", song: 'what-a-wonderful-world'},
)
)
Beside song, in red is the name of the media file between apostrophes. This will reference the file uploaded to the Media console in PowerApps.
It can be a lot of typing if you have lots of songs. If you have more songs than you are willing to type up, I would upload them to Azure or Google Cloud and get URLs for them all which you can put into an Excel table and lookup.
But I'll proceed assuming you collected a table.
Next you will change the Items property of the Listbox so that it can filter the songs you want. The problem with the Distinct function is that it drops all other columns--it will be good for your dropdown, but not good for your listbox.
Set your dropdown menu to:
Distinct(songstable,type)
Now you are ready to write the Items property of the ListBox:
Filter(songstable,type=Dropdown1.Selected.Result)
That shows all songs whose type matches the one selected in the dropdown menu. I use .Result since it goes to the "type" column automatically.
And since the songstable collection has not lost any columns, when we reference a song, we will not use ".Value" but instead ".song" or whatever you named that column.
So in the first audio control, set its Media property to:
First(Filter(songstable,id=Last(FirstN(Mylistbox.SelectedItems,1)).id)).song
or simply
Last(FirstN(Mylistbox.SelectedItems,1)).song
.Value was probably returning the text name of the song and not the media file itself--that's why it wasn't working for you before.
I gave it some thought and if you want to stick to using a Listbox, there is a way to stop at 3. You could disable the Listbox when the number of items selected equals 3. As I mentioned in the last post, Mylistbox.SelectedItems is like a collection, so you can Count it.
You could set the DisplayMode property (formerly Disabled property) to:
If(CountRows(Mylistbox.SelectedItems)=3,DisplayMode.Disabled,DisplayMode.Edit)
This means, "If there are 3 items selected in the listbox, then disable the listbox, otherwise allow editing."
The problem with this method is that you will need to build a button to reset the listbox if you choose the wrong thing or change your mind on a song.