In my app, I have an audio-file playing screen, which will play audio files the user has uploaded. I want to know if:
i) Is there any way to display the length of the audio file?
ii) Is it possible to have a progress bar that can set the position of the audio file when dragged?
iii) Display how much of the song has finished?
iv) Also, is there any way to set the image of m data viewer list back to the play icon once the song has finished? I know how to change the image of a certain DVL part, but itās not changing once the song has finished playing.
This is my code:
Edit: It worked only on the phone during Live Test, that was the issue
@domhnallohanlon This audio manipulation is something I would dearly want with the sound component, along with finding the length of the file, because I am not pre-defining the audio clips.
Any ideas on how to do this?
You can only do this in a very limited way and only if the duration of the media file is known in advance. Timers would come in handy inthis scenario. If you have an Android device you can check my DeluxeTube tech-demo app which imements just that for its playlist mode. Check the description and limitations in the post as well.
The media file is definitely not know in advance as these audio clips are stuff that the user has recorded within the app.
How can I use timers to figure out the maximum time? Any help would be appreciated if you have tried this.
Wow! I read your post on DeluxeTube, and I found it quite impressive. I do have an Android device, and will definitely check it out. Would it be possible for you to make it open-source, because I would love to take a look at the code.
Thanks!
The timer comes in handy when you know the duration of the media file and you need to advance to the next media file. This works by setting the timer duration equal to the length of the media file (i.e. in seconds) plus 2 or 3 seconds in case it is streamed for buffering delays etc. and then load the next media file when the timer fires. Of course, if the user moves back and forth in the media file then the timer sync will be off and this will not work. Since we donāt have the necessary controlls, this is the best I could come up with.
Thanks @Deluxe! But in this case, I donāt know the length of the media file because the user has recorded the files. Also, thereās no need to load the next file, because the user has to click on files to play them(they are all displayed in a screen. Yes, itās confusing because we canāt predict what the user will do. These controls(length of sound file, from sound1 set position, from sound1 call get elapsed) would be very helpful and would make it so much easier.
Thank you for your help.
Iām going to guess you could determine the audio file duration by uploading it to cloudinary and then using the API to retrieve the duration.
But itās a guess because I havenāt found that feature in their documentation yet. It would also be a bit slow to upload everything (even temporarily) to cloudinary if you donāt otherwise need to store it in the cloud.
Wellā¦ there is a way. Get the seconds since 1970 before and after taking the video (EDIT: or audio), subtract, store in a local table for reference when later viewing the video in the app.
Hi @tatiang thatās a great idea! How can I view the JSON response of the media_db, in order to retrieve max length? Since itās a default component in Thunkable, thereās no need to have the JSON. How do I do this? Thanks.
Wow @Deluxe ! That is an amazing idea! Will definitely try that. I should set the max length of the slider to the length of the song to make the progress bar, right? Also, how do I move the slider in order to show the completed part of the song?
Thanks.
But when I tested it, I got -47.31 as the recording time. What have I done wrong?
**Edit: I fixed it using in text replace - with **
Thereās also another problem. Iām unable to get the code to narrow itself down to minutes and seconds if more than 60. I got 1.87 in my time, even though I coded this:
The duration is going to be [seconds since 1970] - [app variable start seconds since 1970]. Thereās no need for an [app variable end seconds since 1970] block.
Itās not perfectā¦ for example, I didnāt āpadā the values. So 2 minutes and 5 seconds will appear as 2:5, not 2:05. You also probably need to round the duration before you use it in the expressions below it.
To test it out, just set [app variable duration] to an integer such as 210. You can do that right below the set [app variable duration] block.