How do I get data Uri .mp3 file time?

So I made my app to choose .mp3 files using Activity Starter and it plays the audio file with no problem but, it doesn't recognize the audio time. For example, the audio last 16 seconds so I want a label to say the seconds it last (which is 16 seconds).

Thanks to anyone who would like to help!

the player extension offers the Duration property you could use...
https://puravidaapps.com/player.php

Taifun


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

I saw your extension and blocks.
Can you show me examples of how to get the file name from the fata uri?
Thank you.

I've replaced all the player 1 blocks to your extension but when I press play, it says Error 701 error to load content (file name and path)

use the file component and its GetFileName method

It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

To get an image of your blocks, right click in the Blocks Editor and select "Download Blocks as Image". You might want to use an image editor to crop etc. if required. Then post it here in the community.

Taifun


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

Thanks.
Don't worry, I replaced all the extensions block to the normal player blocks.


Those are the blocks that I'm using. What I'm trying to do is to play the normal player and run the extension at the same time just to have the seconds.

Also, the "Player 1 source" is the Result URI, which is the audio file.

And also, to use the Duration block you need the Player to be playing but what player is it? Is it the Taifun Player extension or the normal player?

???

use only one player... and if you need want to use the Duration method, then only use the TaifunPlayer rather than both Player and TaifunPlayer

the extension can't play uris...
as already suggested

to convert an uri into a filename

Taifun

Can you teach me how to do that?
I have the extension downloaded but It was I little bit confusing for me.
Thank you.

Sorry for not explaining well. What I was trying to say is that I had replaced the blocks from the Player 1 to the taifun player, then changed it again to the normal player blocks.

sure...
just use that block together with your uri to get a filename
you might want to try something and if you got stuck, then post a screenshot of your relevant blocks

also 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

Taifun


I've used that method to add the item in the list and replace the file path to the original name but when it adds to the list it says "null"


And when I use this method it doesn't appear any name in the list, it's just blank and the audio file doesn't starts.

@TTG_Studioz

Here an extension: com.KIO4_Base64.aix
http://kio4.com/appinventor/277_extension_imagen_string.htm

Can you try the "UriToPath" block to get the file path by supplying the "ResultUri"?

YAYYYY IT DOES SHOW THE NAME!! but, it still shows the file path..
I think I can solve it with the replace text block


How can I set the status as Playing?
It still says that the Player must be in playing status.
I thought that by adding the TaifunPlayer.Start would work but it didn't.

try to get the Duration a few milliseconds later after the Player has been started
you can use a Clock component for that...

Tiafun

Hmmm, I don't understand.
Can you show me an example?
Thank you.

Ok, it is now working.
But it seems that the time displayed are milliseconds instead of seconds and I'm pretty sure I got to divide or something to get the seconds.
So, how can I convert the milliseconds into minutes?
I tried dividing the Duration by 60000 I don't know if it did worked or not it gives numbers that aren't similar to minutes.

yes, this is correct

It would really help if you provided a screenshot of your relevant blocks including Do it result of your Duration, so we can see what you are trying to do, and where the problem may be.

To get an image of your blocks, right click in the Blocks Editor and select "Download Blocks as Image". You might want to use an image editor to crop etc. if required. Then post it here in the community.

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
Taifun


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

Let's say you have 1000ms this is 1s. If you divide it by 60000, you get the result 0.0166666667. It is 0.016 minutes, which is correct. If you want human readable minutes, use this block.

Instead of a box that says 60000, put your song duration there in millisecond format.