Music Player stopping

Dear all
I need a help. I need to run a music player for a specific duration for example the player running from the 3 seconds to 6 seconds only. Actually, I did the starting but how can I stop the player after some seconds?
thank you in advance
Salam.

Use Clock component.

Set Clock timer to duration after which you want to stop the music. When clock timer finishes use stop player block.

2 Likes

thank you for your reply. I used a clock and it works well but after 35 seconds the player runs from beginning, I do not know why?!

Check your music file length. May be it is shorter than 35 seconds.

Can you show relevant blocks.

file length is more than 2 minutes …please find the attached

2

set Seek To position to 3000 as well as Clock.TimerInterval to 3000
Unbenannt
Taifun

yes, it works but after 35 second it is repeat from beginning

so the file now plays correctly from second 3 to second 6, then there is a pause of 35 seconds and the file restarts from the beginning?

how does your Clock.Timer event look like?

btw. your blocks look almost the same, which means, you could use a procedure to simplify your blocks…
DRY - Don’t repeat yourself

Taifun

2 Likes

thank you for your reply.
I built 13 buttons, and there is a mp3 file (more than two minutes). when I press button 1 the mp3 runs from 0 sec to 2 sec. if I press button 2, the player runs from 2nd second to 10th second and so on. but when I press button 6 which must start from second 35, unfortunately it starts from beginning. I don’t know why. (it works perfect till 34th second but after that it repeats from beginning).
I used (seek to position) to start the player and used (Time interval ) to stop the player.
if you an idea to fix it or to change the procedure please tell me.
BTW, I will reduce blocks when I complete the idea if the App.
Thank you for your consideration.

edit: I solved the problem. I changed the mp3 file there was a problem in mp3 file. thank you for all replies

1 Like

I glad your problem is solved.

Also you can cut your mp3 file in many parts as you want and play each part when necessary.

2 Likes

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