web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Apps
Unanswered

audio control

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello everyone, I have a list box (Mylistbox) that populates names of songs. I want the user to select a song from the list and get the following:

  1. I added an audio control (Myaudio1) and I want the "Media" property to be set as the one that the user has selected from the list box. I have tried the following Media: Mylistbox.Selected.Value, it does not give me an error but the song does not play.
  2. I want the user to select up to a limit of 3 songs in the list box, how can a limit the number of songs the user can select?
  3. If I add several audio controls (Myaudio1, Myaudio2, Myaudio3), how can I assign "Media" property of each audio control, to take only one value, so to speak, selection1 for Myaudio1, selection 2 for Myaudio2 and selection 3 for Myaudio3.

Thanks for your help

Omar

Categories:
I have the same question (0)
  • Brian Dang Profile Picture
    3,976 on at

    Hi,

    Can you share a little bit more information?

    1. What is the items property of your ListBox? Did you use a datasource, [], or the Table() function? What is selected in the dropdown menu in the advanced panel for your ListBox?
    2. To limit the number of items that can be selected in the ListBox, you will want to go to the Advanced panel in the righthand side and turn the SelectMultiple property to false. Then the user will only be able to select one.
    3. If you have multiple audio controls, you can program them each one by one to match what is selected in the ListBox. There's a few ways to write the formula, but here is probably the easiest way. Think of Mylistbox.SelectedItems as a table; from that table, you want to pare it down to the individual record you want.

      To assign the first audio selected:

      Last(FirstN(Mylistbox.SelectedItems),1).Value
      This means, "From the items selected in Mylistbox, show 1 record from the top of the table (FirstN), then pick the last record from that subset (Last) and show its value (in this case a media file)."

      The second audio file is similar and you will see the pattern from here:

      Last(FirstN(Mylistbox.SelectedItems),2).Value
      This means, "From the items selected in Mylistbox, show 2 records from the top of the table (FirstN), then pick the last record from that subset (Last) and show its value."

    This method will encounter problems though since there is no way to limit the number of items a user can select in the ListBox--it's either one or as many as you want. 

     

    It's more complex, but I'd recommend that you create a gallery of your audio files, then add a button or something with OnSelect so that you can Collect the audio files you want played. You can wrap a condition in the OnSelect property so that you can only Collect if there are fewer than 3 records in the collection. It's harder, but it will be worth it since you can change more of the styling of galleries than a listbox.

     

    Let me know what you go with.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks Mr Dang...

     

    3. Multiple audio controls...

     

    ABOUT LIST BOX

    I have a dropdown control (dropdown1) that populates the type of songs i.e.: rock, salsa, jazz. when the user select lets say "salsa" in the dropdown, I populate song names in the list box (Mylistbox) by using Distinct and Filter functions to a table (songstable) which has songnames and songauthors.

     

    ABOUT SONGS

    I have uploaded songs to powerapps Media.

     

    YOUR METHOD

    If I use your method: Last(FirstN(Mylistbox.SelectedItems,1).Value) produce the following error "The property expects Media values, but this rule produces incompatible Record values". I guess because the Media property expects an actual media file and no a text. I was thinking that perhaps Media property were expecting the complete name like: song1.wav, so I try the Concatenate function but it did not work either. Perhaps the Media property need the route where those media file are store in the cloud, please comment.

     

    2. To limit the number of items that can be selected in the ListBox...

    Is there any way to go around the limitaion of not being able to select exactly 3 items? What about using check boxes?

     

    Thanks

    Omar

     

     

  • Brian Dang Profile Picture
    3,976 on at

    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.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks Mr Dang,

     

    I was able to allocate the songs to audio controls however I am having problems still with the songs user select in the list box...

    So if the user select the first song, the audio control is set to: 

    Last(FirstN(Mylistbox.SelectedItems,1)).song

    If the user select another song from the list box, the first audio control remains with the first selection and this is quite right..

     

    But, the second audio control is set to: Last(LastN(listapiezas.SelectedItems,1)).pieza

    So the second audio control get the second selection made by the user and this is also right.

     

    PROBLEM WITH 3 AUDIO CONTROLS

    However if I do not know how to set the third audio control since we have only FirstN and LastN and nothing in the middle.

     

    PROBLEM WITH THE AMOUNT OF TYPING AND SETTING URL TO AUDIO CONTROLS

    I have uploaded songs to dropbox and google drive... I have produce a URL for such songs... Those URL are set in a column in the excel table (songstable):

    • I have try manually set the url to the media control as "https://www.dropbox.com/s/nkfd5c7z4fh84ek/Al_1_A.wav" and it does not produce any error but it does not play the song.
    • I have try by searching in the excel table as LookUp(songstable,song=Mylistbox.Selected.Value,URL) anf it does not produce an error but it does not play the song.

    I am thinking that this mistake is because of three different reasons: 1) I probably setting wrongly the url in the media property (should it be without http, or with out "), 2) I do not know if the query to the excel table is properly done, 3) I do not know if the url in the excel table sould be set with specific components.

     

    Thanks

    Omar

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 401 Most Valuable Professional

#2
11manish Profile Picture

11manish 201 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 128 Super User 2026 Season 2

Last 30 days Overall leaderboard