+1

start/stop audio

ajakhua 12 years ago updated by icahill (Administrator) 12 years ago 12
Was unable to stop audio from playing. Loading 124 seconds long mp3 file from "oninit" action to play continuously and then want to stop it using button click:


<main>
<image name="sound" alias="SOUND" source="images/mute.png" xpos="100" ypos="100" onclickup="stop-music"/>
</main>
<actions>
<action name="initialize" oninit="yes">
<play action="music1" />
<action>

<action name="music1">
<sound action="play" source="sound/s1_music" type="mp3" />
<play action="music2" delay="125" />
</action>
<action name="music2">
<sound action="play" source="sound/s1_music" type="mp3" />
<play action="music1" delay="125" />
</action>
<action name="stop-music">
<sound action="stop" source="sound/s1_music" type="mp3" />
</action>
</actions>


But it never stops. What's wrong?
Let me take a look and I will get back to you. Thanks.
Try using this example. It reuses the sound tag by playing with object variables derived from the play action:


<wire>
<main>
<image name="sound" alias="SOUND" source="button.back.png" xpos="100" ypos="100" onclickup="stop-music"/>
</main>

<actions>
<action name="init" oninit="yes">
<play action="clip" _action="play" _source="baseball1" _type="m4a" />
</action>

<action name="clip">
<sound action="_action" source="_source" type="_type"/>
<play action="clip" _action="_action" _source="baseball1" _type="m4a" delay="3" />
</action>
<action name="clip-stop">
<sound action="_action" source="_source" type="_type"/>
</action>
<action name="stop-music">
<play action="clip" _action="stop" _source="baseball1" _type="m4a" />
<alert message="STOP"/>
</action>

</actions>
</wire>
Thank Ian!

It works now for one WIRE file. But when I'm trying to close subwire and start music in main wire, fusebox crushes. I think it can't find "start-music" action when returning from subwire. Here is the code:

from main.wire:


<main>
<image name="subwire" alias="SUB" source="images/click.png" xpos="100" ypos="100" onclickup="SCENE1"/>

<include name="scene" alias="SCENE" width="100%" height="100%" background="#000000" alpha="0"></include>

</main>
<actions>
<action name="initialize" oninit="yes">
<play action="start-music" />
<action>

<action name="music">
<sound action="_action" source="_source" type="_type" />
<play action="music" _action="_action" _source="_source" _type="_type" delay="125" />
</action>
<action name="stop-music">
<play action="music" _action="stop" _source="sound/s1_music" _type="mp3" />
</action>
<action name="start-music">
<play action="music" _action="start" _source="sound/s1_music" _type="mp3" />
</action>

<action name="SCENE1">
<play action="stop-music" />
<load file="scene1.wire" wirename="scene1" target="SCENE" />
<alpha value="1" time=".5" target="SCENE" />
</action>

<action name="CLOSE-SCENE1">
<sync>
<unload delay=".1" />
<alpha value="0" time=".5" />
</sync>
</action>

</actions>



for subwiere scene1.wire:


<main>
<image name="mainwire" alias="MAIN" source="images/click.png" xpos="100" ypos="100" onclickup="MAINWIRE"/>

</main>
<actions>

<action name="MAINWIRE">
<play action="CLOSE-SCENE1" superwire="yes" target="../.." />
</action>

</actions>


if I put "play action="start-music" " somewhere in CLOSE-SCENE1 or MAINWIRE actions, fusebox crushes when executing it.
on your subwire try adding a play action like this:

<action name="MAINWIRE">
<play action="START-MUSIC" superwire="yes" target="../.." />
<play action="CLOSE-SCENE1" superwire="yes" target="../.." />
</action>
It doesn't help. fusebox crushes..
Did you put your close scene action second?
Yes Ian, I did exactly as you wrote. I'll try to move content from main wire to subwire and use main wire only for load and unload subwires. I'll inform about results.
play/stop audio in subwire works fine. no option for pause, but I hope will be available in feature versions of WIRE. start/stop audio from subwire to main wire is not working.
Double check your target path. If it is still not working, perhaps you could invite me as a collaborator to take a look at the code?
Ian, you are collaborator already
I removed "superwire" parameter from "play" action and now it works fine:

<action name="MAINWIRE">
<play action="start-music" target="../.."/>
<play action="CLOSE" target="../.." />
</action>


That's strange. I'm using "superwire" parameters in my other multiwire app and it works.
Well that is certainly strange. I am going to recreate this and test it outside of fusebox. I am wondering if it will break as a stand alone app.