PDA

View Full Version : Button Question


JDog37
06-15-2009, 10:20 PM
I am messing around with the Audio Capture .apz that was on here. I am not sure who's it is (Thank you tho) but I wanted to add a function to the stop capture button. I want to be able to hit the space bar and stop the capture as well as the stop button.



Any help would be much appreciated..

Thanks,
Joe

MicroByte
06-16-2009, 03:31 AM
without seeing some code or the original apz its impossible to help

JDog37
06-16-2009, 07:51 PM
This is the origiinal app, and I added a Hi quality record button.. I want to hit the space bar to have it stop recording /and or playing.

Also is there a way to show a time like: (00:00:00) For the playback or record?? ;)

Thank you so much for a reply!!! :yes

MicroByte
06-17-2009, 01:52 AM
1. use a timer and System.IsKeyDown to check if the spacebar is pressed

if System.IsKeyDown(VK.Spacebar) then
AudioCapture.PlayStop();
AudioCapture.CaptureStop();
end

2, use this function

-- this function will Convert Milliseconds into standard time format ie HH:MM:SS
function MilliSecondsToClock(sMilliSeconds)
local nMilliSeconds = String.ToNumber(sMilliSeconds)
if nMilliSeconds == 0 then
--return nil;
return "00:00:00";
else
nHours = string.format("%02.f", Math.Floor(nMilliSeconds/3600000));
nMins = string.format("%02.f", Math.Floor(nMilliSeconds/60000 - (nHours*60000)));
nSecs = string.format("%02.f", Math.Floor(nMilliSeconds/1000 - nHours*3600000 - nMins *60000));
nMilliSecs = Math.Round(nMilliSeconds - (nHours*3600000) - (nMins *60000) - (nSecs *1000))
return nHours..":"..nMins..":"..nSecs
end
end

and replace the code in the timer
Input.SetText("InputLength", MilliSecondsToClock(AudioCapture.GetLength()));
Input.SetText("InputSize", AudioCapture.GetSize());
Input.SetText("InputStatus", AudioCapture.GetStatus());


that should get you going.

JDog37
06-17-2009, 04:15 AM
Thank you MicroByte for a speedy response!! Only, I am lost, and confused. I am totally novice to code, BUT I do like to ask questions... :o

use a timer and System.IsKeyDown to check if the spacebar is pressed

Where do I find System.IsKeyDown? Timer in the plugins? And number 2???? Lol. I am blown away... Sorry for the questions.

Is it possible to post me a .apz?

JDog37
06-18-2009, 05:09 PM
Can anyone help me out.. Please???:o:o??

JDog37
06-19-2009, 11:47 PM
Com on fellas, can anyone give me a hand? I'll make a few buttons...:D
Seriously tho, any help is much appreciated!

Joe

JDog37
06-20-2009, 04:15 PM
Ok, I found out how to set the timer... after 2 days.. But I can not figure out where to put this code?:

if System.IsKeyDown(VK.Spacebar) then
AudioCapture.PlayStop();
AudioCapture.CaptureStop();
end

I tried in globals but no luck...
I also tried putting this code on the page show:

-- this function will Convert Milliseconds into standard time format ie HH:MM:SS
function MilliSecondsToClock(sMilliSeconds)
local nMilliSeconds = String.ToNumber(sMilliSeconds)
if nMilliSeconds == 0 then
--return nil;
return "00:00:00";
else
nHours = string.format("%02.f", Math.Floor(nMilliSeconds/3600000));
nMins = string.format("%02.f", Math.Floor(nMilliSeconds/60000 - (nHours*60000)));
nSecs = string.format("%02.f", Math.Floor(nMilliSeconds/1000 - nHours*3600000 - nMins *60000));
nMilliSecs = Math.Round(nMilliSeconds - (nHours*3600000) - (nMins *60000) - (nSecs *1000))
return nHours..":"..nMins..":"..nSecs
end
end

But No luck..

longedge
06-21-2009, 03:05 AM
OK I'm probably going to show my ignorance here but VK.Spacebar doesn't mean anything to me or apparently to AMS either :) however the code -

if System.IsKeyDown(32) then

does detect the spacebar state.

p.s. the code will monitor whether a key is up or down so a page timer might be a good place for it although I don't know how that would fit in with everything else.

longedge
06-21-2009, 03:28 AM
Found the answer to VK.Spacebar which is fully explained in Desmond's post in this (http://indigorose.com/forums/showthread.php?p=71950) thread.

Defining the VK table explicitly on my laptop makes it work so the lua file is obviously missing. Must have a look...

longedge
06-21-2009, 04:22 AM
Putting the following in pre-load ( the table defines the table entry "Spacebar" as = to 32)

VK = {
Spacebar = 32,
};

and then the following into the page timer


if System.IsKeyDown(VK.Spacebar) then
AudioCapture.PlayStop();
AudioCapture.CaptureStop();
end

works for me.

JDog37
06-21-2009, 07:25 PM
Thank you longedge, I am going to try it!! Thank you all as well!!

Joe:yes