comparing a value to the value of a player
Posted: Mon Nov 09, 2009 7:51 pm
It seems to me that i missing something in my code. I have a player, it has a scroll bar that shows current Time of player, and a duration filed that shows the time running "Time Elapsed: 00:30:31", my calculations are in seconds.
I watch the clip and click a button that records in a text field the value of starting time and duration it took me to click that button again, the results are look like this in the text field
2.458333 0.818333
4.093333 1.116667
I then want to play the clip and make a button show when the player reaches "2.458333" and show for "0.818333" then disappear
i am trying to compare the value from the running player to a rounded (2.458333 for example) then show the button, but comparing them does not work.
on mouseUp
put empty into fld "countdown" of card "codeCard" of stack "videoCode"
# calculate time duration in ticks
put "Seconds" into tTimeUnit
put 60 into tFactor
# converting to seconds, truncate to whole number
put trunc(fld "totalDuration" of card "codeCard" of stack "videoCode" * tFactor) into tDuration
# setingt up the progress bar
set the endvalue of scrollbar "timeleft" to tDuration
set the endvalue of scrollbar "timeleft" of card "codeCard" of stack "videoCode" to tDuration
set the thumbposition of scrollbar "timeleft" to 0
set the thumbposition of scrollbar "timeleft" of card "codeCard" of stack "videoCode" to 0
# set the starting time -- note that this variable is declared as script local
put the ticks into startTicks
updateProgress
end mouseUp
-- progress handler
on updateProgress
put 0 into x
get the thumbposition of scrollbar "timeleft"
get the thumbposition of scrollbar "timeleft" of card "codeCard" of stack "videoCode"
put (the ticks - startTicks) into tElapsed
put padNum(tElapsed div (60*60)) into tMins
put padNum(tElapsed mod (60*60) div 60) into tSecs
put padNum(tElapsed mod 60) into tTicks -- remember 'mod' gives the remainder of a div
put "Time elapsed: " & tMins & ":" & tSecs & ":" & tTicks into fld "countdown"
put "Time elapsed: " & tMins & ":" & tSecs & ":" & tTicks into fld "countdown" of card "codeCard" of stack "videoCode"
set the thumbposition of scrollbar "timeleft" to (the ticks - startTicks)
set the thumbposition of scrollbar "timeleft" of card "codeCard" of stack "videoCode" to (the ticks - startTicks)
if the thumbposition of scrollbar "timeleft" of card "codeCard" of stack "videoCode" < the endvalue of scrollbar "timeleft" of card "codeCard" of stack "videoCode" then
send updateProgress to me in 5 tick
-- trying to compare values below
if field "trackPlayer" of card "dateSelect" of stack "studentWork" is not empty then
put (x + 1) into x
put word 1 of line x of field "trackPlayer" of card "dateSelect" of stack "studentWork" into Cvalue
put Cvalue
--round (Cvalue,2)
if (tSecs = Cvalue) then
show button "light1" of card "codeCard" of stack "videoCode"
put x + 2 into x
put word 2 of line x of field "trackPlayer" of card "dateSelect" of stack "studentWork" into wValue
show button "light1" of card "codeCard" of stack "videoCode" for wValue
end if
end if
else
put line 1 of field "totalDuration" of card "codeCard" of stack "videoCode" into fld "countdown" of card "codeCard" of stack "videoCode"
end if
end updateProgress
Is there a more efficient way of doing this ?
I have another working solution that is very slow and choppy, if all fails.
THANKS !
I watch the clip and click a button that records in a text field the value of starting time and duration it took me to click that button again, the results are look like this in the text field
2.458333 0.818333
4.093333 1.116667
I then want to play the clip and make a button show when the player reaches "2.458333" and show for "0.818333" then disappear
i am trying to compare the value from the running player to a rounded (2.458333 for example) then show the button, but comparing them does not work.
on mouseUp
put empty into fld "countdown" of card "codeCard" of stack "videoCode"
# calculate time duration in ticks
put "Seconds" into tTimeUnit
put 60 into tFactor
# converting to seconds, truncate to whole number
put trunc(fld "totalDuration" of card "codeCard" of stack "videoCode" * tFactor) into tDuration
# setingt up the progress bar
set the endvalue of scrollbar "timeleft" to tDuration
set the endvalue of scrollbar "timeleft" of card "codeCard" of stack "videoCode" to tDuration
set the thumbposition of scrollbar "timeleft" to 0
set the thumbposition of scrollbar "timeleft" of card "codeCard" of stack "videoCode" to 0
# set the starting time -- note that this variable is declared as script local
put the ticks into startTicks
updateProgress
end mouseUp
-- progress handler
on updateProgress
put 0 into x
get the thumbposition of scrollbar "timeleft"
get the thumbposition of scrollbar "timeleft" of card "codeCard" of stack "videoCode"
put (the ticks - startTicks) into tElapsed
put padNum(tElapsed div (60*60)) into tMins
put padNum(tElapsed mod (60*60) div 60) into tSecs
put padNum(tElapsed mod 60) into tTicks -- remember 'mod' gives the remainder of a div
put "Time elapsed: " & tMins & ":" & tSecs & ":" & tTicks into fld "countdown"
put "Time elapsed: " & tMins & ":" & tSecs & ":" & tTicks into fld "countdown" of card "codeCard" of stack "videoCode"
set the thumbposition of scrollbar "timeleft" to (the ticks - startTicks)
set the thumbposition of scrollbar "timeleft" of card "codeCard" of stack "videoCode" to (the ticks - startTicks)
if the thumbposition of scrollbar "timeleft" of card "codeCard" of stack "videoCode" < the endvalue of scrollbar "timeleft" of card "codeCard" of stack "videoCode" then
send updateProgress to me in 5 tick
-- trying to compare values below
if field "trackPlayer" of card "dateSelect" of stack "studentWork" is not empty then
put (x + 1) into x
put word 1 of line x of field "trackPlayer" of card "dateSelect" of stack "studentWork" into Cvalue
put Cvalue
--round (Cvalue,2)
if (tSecs = Cvalue) then
show button "light1" of card "codeCard" of stack "videoCode"
put x + 2 into x
put word 2 of line x of field "trackPlayer" of card "dateSelect" of stack "studentWork" into wValue
show button "light1" of card "codeCard" of stack "videoCode" for wValue
end if
end if
else
put line 1 of field "totalDuration" of card "codeCard" of stack "videoCode" into fld "countdown" of card "codeCard" of stack "videoCode"
end if
end updateProgress
Is there a more efficient way of doing this ?
I have another working solution that is very slow and choppy, if all fails.
THANKS !