PDA

View Full Version : on key toggle audio


Alan vanBiervliet
08-21-2005, 09:53 AM
I have had no success doing what i thought should be an easy task. I simply want to use the spacebar to toggle audio on and off. I can get a button to work fine. However, I am having no success placing Audio.TogglePlay(CHANNEL_NARRATION); in an e-key in the on key event on the page. I can get the space bar to play or pause the audio, but not toggle. The audio starts playing when the page opens. I have a toggle button on the page that works fine.

this is not working
if e_Key == 32 then
Audio.TogglePlay(CHANNEL_NARRATION);
end

But it does work if I switch to Audio.Play or Audio.Pause. i have even tried using a Page.clickobject directed at the toggle button on the page and that does not work.

Final question i I am trying to use arrow keys for navigation as well. I get odd behavior when I use rt arrow( e_Key == 39). Rather than next page it appears to be issueing 2 next pages. this also happens if I use the click object command directed to the next button on the page. the next button on the page works fine. Any clues?

Alan

Roboblue
08-21-2005, 07:50 PM
If you already have a toggle button on the page that works, then in the page on key event, try this

--if the space key is pressed, click object search
if e_Key == 32 then
Page.ClickObject("Toggle_btn");
end

with the name of the toggle button in place of Toggle_btn.

Alan vanBiervliet
08-21-2005, 08:28 PM
If you already have a toggle button on the page that works, then in the page on key event, try this

--if the space key is pressed, click object search
if e_Key == 32 then
Page.ClickObject("Toggle_btn");
end

with the name of the toggle button in place of Toggle_btn.

Well I had tried this trick earlier with no success. I tried again just to make sure I was not using the wrong syntax. No go. I also tried using a alpha key to trigger the script. Nope still doesn't work. I can trigger other scripts no problem, including playing and pausing audio. But it will not toggle (the button on the page works fine). Any ideas?

Alan

yosik
08-21-2005, 11:05 PM
Alan,
It works for me here.
I am attaching a dummy project. check the Project Audio (as music is launched at startup and the onKey event.

Yossi

Roboblue
08-22-2005, 06:38 AM
works here too. With the audio in the project audio section.
If you are playing a different background audio on each page, then you would load play in the page events.
So, I tried loading the audio on page preload, then play on page show instead of in the project audio section. I even added a toggle button then using the Enter key clicking the toggle button. The space bar directly toggling the audio. It all works.

Alan vanBiervliet
08-29-2005, 07:19 PM
Alan,
It works for me here.
I am attaching a dummy project. check the Project Audio (as music is launched at startup and the onKey event.

Yossi

Thanks for the help. I was using narration audio rather than background. I need to explore the diferrences. thanks again.

Corey
08-29-2005, 07:28 PM
Hi, I might be wrong but I don't think there is any difference between the audio channels except the naming. So you can use whichever you like, you just have to make sure to reference it accordingly in any subsequent actions. I may be wrong about this, there may be a subtle difference with the background channel which I haven't noticed, so I stand to be corrected by the dev guys. :)