How do I return the name of an audio file "On (tag) ended?"

Get help using Construct 2

Post » Sat Oct 29, 2016 1:02 pm

The audio plugin doesn't seem to have any way to return filenames (according to the manual page). Here's what I'm working with:

Image

When "On 'tracks' ended" is triggered, I want to prevent the same song from playing twice in a row. Ideally I want it to call a function like so:

On "tracks" ended:
--Call function "AudioShuffle"
--Set Parameter 0 to "(name of audio track that triggered this call)"

On Function "AudioShuffle"
If Param(0) and audio are equal, call the function again.
Else, play (choose(track1,track2,etc))


Yes, you could do this in a dictionary or array as well (toggle from 0 to 1 for "chosen track" to stop it from repeating), but I would be surprised if there were not a way to do this as the events currently are. Thank you!
B
22
S
5
G
1
Posts: 41
Reputation: 1,730

Post » Sat Oct 29, 2016 2:57 pm

Mallets wrote:The audio plugin doesn't seem to have any way to return filenames (according to the manual page). Here's what I'm working with:

Image

When "On 'tracks' ended" is triggered, I want to prevent the same song from playing twice in a row. Ideally I want it to call a function like so:

On "tracks" ended:
--Call function "AudioShuffle"
--Set Parameter 0 to "(name of audio track that triggered this call)"

On Function "AudioShuffle"
If Param(0) and audio are equal, call the function again.
Else, play (choose(track1,track2,etc))


Yes, you could do this in a dictionary or array as well (toggle from 0 to 1 for "chosen track" to stop it from repeating), but I would be surprised if there were not a way to do this as the events currently are. Thank you!


Then you have to be surprised, because there ain't :)

As workaround solution instead of your array or dictionary solutions, wouldn't it be easier just to make a list (playlist) and add all your tracks to that and use that as your input string for your audio object. That way you can always make a check vs "text at selected index" to make sure that the same track isn't played again.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,828

Post » Sat Oct 29, 2016 3:51 pm

viewtopic.php?t=163624
You can use this plugin to help randomize the order, and prevent the same sequence playing even.
ImageImageImage
B
71
S
21
G
221
Posts: 3,650
Reputation: 124,229


Return to How do I....?

Who is online

Users browsing this forum: alextro, Ryan Kocourek and 6 guests