Listpicker filter bar

I have a music player that uses listpicker to find and play a song. I also have a text box that shows the song picked. If I pick a song from the list, that is sorted alphabetically, the correct song shows in the text box and hit the play button plays that song.
If I use the filter box to find a song, pick one from the available list shown, the correct song shows in the text box, hit play and it plays the wrong song.
If I scroll down the list to find the song just picked with the search method it plays correctly.

When I use listview to do the same thing it works correctly.

The listpicker filter bar creates new indexing when you filter.

Why would it do that and what can I do about it?

I believe it is by design, it has always been that way

Get the Selection, as opposed to the selectionIndex, then iterate over the original listpicker list to get the index of the song in that list.

Alternatively, build your own custom listpicker search bar which overcomes this issue. (Search the community for some ideas)

Just use the Selection Richard - if all the relevant file names are identical (re my Crazy Horses example in your other Topic), then you only want the Selection and not the index.

I am using selection. It works fine when I select from the scroll down list. It doesn't work when I type in a search and pick from that list.

Try this, using the filter bar (search bar):

List_MusicTitles.aia (5.1 KB)

That works as I would expect it to. The list is all in the app there is no sound associated with it.
Here is a short video of what I am talking about. Notice that I pick the SAME song two different ways. One by picking and one by using the search bar. Notice that in each case the correct title appears in the text box. If you have your sound on you can hear that they are different songs. The first one is correct.

Hi Richard

The video does not help - the problem is somewhere in your code. Note, the fact that in my example the List of Titles is in-app should make no difference.

The sound is associated with the music title (= List Selection). You can build the file name to play thus:

DeviceMusicFolder + PlayMusicFolder + MusicFolder + ListSelection + ".mp3"

So here is a crude working example:

MusicTitles.aia (36.4 KB)

...it just lists the files in the Android Music Folder and plays your selection

How would I know if it is playing the correct song? Your list isn't a list of music files, it's just a list. Have you even read my posts or look at the video? I KNOW it's in the code I have known that from the very first post.

Yes. Please don't shout at the people helping you.

It's easier on my side to offer a working code snippet rather than try to correct your Project. I have other people to help and other things to do - we, the Power Users, are unpaid volunteers supporting free software, so time is of the essence.

The Project I posted resulted in a list length of zero, which means it didn't find a music folder or it did but there were no files in it - strange, my folder has several files that were delivered with the device by the manufacturer. Can you put some mp3 files in the music folder and test again?

Edit: Please ensure the TaifunFile Extension is loaded into the Project.

2 Likes

Sorry, getting frustrated, to me it seems like the answers don't fit the questions.
I just did everything over again. Built your file again, just to make sure I did everything right. TaifunFile Extension is loaded. I didn't originally have any music in the tablet music folder. There are now mp3 files in both the internal and external "Music" folders. I get the same error. It's Android 10. Also tried on another Android 10 and an Android 7, neither of them will keep the app open. (My apps do work both)

That's even stranger, it works on Android 11 here, but I have tested via the Companion, sounds like your test is an APK, I'll take a look.

I just tested in companion and it does work that way.

Stranger still!

Build Server is busy at the moment.

Right, ran it as an APK, crashes immediately. Sometimes that can be caused by a heavy event being launched @ Screen Initialize, so I moved the File List Async Block to a Clock Timer but still crashes.

I have asked for people to test the Project. There have been more reports of start-up crashes than normal, but I'm not sure if this one is related to the others. Let's see what the others find - could very well be a bug by me.