Component player

…but why can I never get a KODULAR component to work without problems?
I tried my hand at the player component.
I just want to listen to songs stored in my phone.
I went crazy trying to find how to use the player.source method.
It is not specified anywhere how player.source wants the mp3 file name.
The file is in the Music folder and called ABC.mp3?
OK, after several searches found: file:///storage/emulated/0/Music/ABC.mp3
However, if the file contains a space it is no longer OK.
OK, it’s HTML and it wants HTML encoding so if the file name is Music/D E F.mp3
will become file:///storage/emulated/0/Music/D%20E%20F.mp3
To make it accept the space I identify it with the hex encoding %20.
It finally seemed like everything was working, too bad!!!
If I have a file named è.mp3 (with an accented e) it no longer works.
Not even with %E8 encoding or è as dictated by the HTML specifications.
How should I use this player?
Advice?

  1. regarding your post (tip: no need to write a diary):
    How to ask a question?
  2. just go on as you recently did.search the forum and you will get the answer! You spend 18 min readtime with your recent questions and searches.This really isn‘t too hard or too much.
    Maybe better use the TaifunPlayer extension .Best choice in my opinion.
    You will also get in touch on your journey with problems of file handling and permissions on later android versions.But you will find answers for those problems too. Just search,read and learn.
    Good luck and happy coding!

Try the UriEncode method from the web component
Taifun

Optimal. With the UriEncode method from the web component I solved it.
Think I had a specific procedure to transcode.
Except that the symbols in the ASCII table that I found on the internet don’t match.
For example, the symbol “è” was %E8 for me but for UriEncode it was %C3.
I just had to correct a “strange” encoding that the UriEncode does: the space encodes it with the “+” symbol.
The player instead wants %20 (instead of space) in the file name as per HTML specifications.
For the rest all OK.
Thanks Taifun

In no case do I have a problem playing the respective audio file. Here is a simple app with a ListPicker, a Player component and 2 labels.
The audio files are the following 3 as you suggested:

  • è.mp3
  • ABC.mp3
  • D E F.mp3

These are located in the /Music folder. So make sure that these 3 mp3 files are also there on your test device. And then test this app: PlayerPath.apk (4.4 MB)

So there is no need to replace any characters.

Blocks

This is an old issue … already in my jukebox example, which is a few years old, I had to replace spaces by %20… App Inventor Extensions: File | Pura Vida Apps

Taifun

Have you tested my APK? I don’t believe that. If you had done that, you would have found that there is no need to replace spaces (with %20) or è with anything else.

Here is another test app with which you don’t have to create your own MP3s. These are automatically copied from the assets to the /Music directory.

PlayerPath_2.apk (4.5 MB)

If these MP3 files are already there, remove them and uninstall the previous app (APK).

no I did not… obviously…
I was talking about replacing space by %20 which was necessary a few years ago…
great, that this is now not necessary anymore…
Taifun

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.