java.lang.IllegalArgumentException: URI scheme is not "file"

What happens if you use that example as it is?
Taifun

Try this one (build the APK and try):
jukebox2.aia (403.9 KB)

New blocks

1 Like

A couple of things,
image
image
(after cpturing error as a readable message and changing from 'Music" to "musica")
image

Make sure there is at least one audio file in the /Music folder.

I swapped these to reflect where my music is stored
image

For large music archives the method FileList gets unresponsive.... use the asynchronous method FileListAsync instead

From the documentation

FileList
Return a list of filenames of a given directory.
Use this method for specific directories to get back a result immediately. To get a list for a complete device or sdcard, which may take a few seconds, use the FileListAsync method instead.

Taifun

Also make sure there are music files available on your internal (emulated) sdcard... it looks like no file was found?

Try @Anke 's modified version, which asks for permissions... the example is already a few years old...

Taifun

This has all been great, and I really do appreciate all the input from all of you;Sunny, Taifun, Tim, Anke. I will play around with what I have now, and bend it all to suit my requirements. I hope this may put an end to the questions, but as the whole android file structure seems to me an incredibly over complicated control device, I will most likely be back.

Charley

In addendum: why does g[lobal listMusic] not show in the list view? And how would one make it show in a list view?
image

Is your question probably "why is the list empty"?
are there mp3 or m4a files in your directory /storage/emulated/0/Music available?
the blocks look fine like this...
did you

use Do it to debug your blocks, see also tip 4 here App Inventor: How to Learn | Pura Vida Apps
see also Live Development, Testing, and Debugging Tools

Unbenannt

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

I did right click n Do it. I get [] as a result. Th juke box still plays music though

if music is playing, then there are music files and then the list can't be empty... I currently do not know, why you get an empty list

To refresh your listview try the Refresh method
https://ai2.appinventor.mit.edu/reference/components/userinterface.html#ListView

Refresh()
Reload the ListView to reflect any changes in the data.

Taifun

Sorry Taifun, it doesn't work until I compile it and install it onto my phone. I wasn't thinking when I posted the question.

jukebox2a.aia (404.2 KB)

maybe my question should be: where is the Music directory on a chrome book? it does not come with one, except in Play Files, but it is not read from there.

I am now in a place I didn't want to be, trying to shape someone else's program to suit my needs. I originally wanted to know how the user (me) can select a directory in which music files are, have the app read the files in situ and then allow the user, (again, me) set up playlists from that selection.

Addendum: It's all a moot point now, as I have found that even having a FilePicker control just creates a blank screen, and nothing loads, no other controls at all. Was there an update to the companion?

well, I don't know, I do not have a Chromebook... usually we work with Android devices here...
but you could use a file manager to find it out yourself...

the file extension and its FileList method also is able to scan the complete storage of the device... use an empty string as directoryName in this case... and as scanning the complete device might take its time, use the FileListAsync method else the device gets unresponsive

obviously you always should use the latest version, which currently is 2.68
here is the latest download link http://ai2.appinventor.mit.edu/companions/MITAI2Companion.apk
Unbenannt

Anke's updated version runs fine on Samsung Galaxy A54 running Android 13 both in companion app and after building

Taifun

1 Like

One question, did you sideload your APK onto the Chromebook, or upload it to the Playstore, then install from there?

Android apps on a Chromebook run in a sandbox separate from the rest of the Chromebook content. For the most part, you should consider running an Android app on a Chromebook as running it an emulator for all intents and purposes.

However, the File Manager: "Files", provides a folder called "Play Files" which contains directories for shared storage directories such as Music, Documents etc. It is possible to copy/paste files from other locations in the chromebook to these directories, which are then accessible from within apps.... (tested using Total Commander)

Sure, but this is no different from if you use a virtual machine program like VirtualBox to run a VM. VirtualBox allows me to map directories from the host into the client. However, that is controlled by VirtualBox and if I don't enable the option the VM has no choice. Similarly, you can take content from ChromeOS (the host) and move it into the Android environment (i.e., "Play Files") but there's nothing to guarantee you can go the other direction, especially without any sort of user intervention.