Player Duration to hh:mm:ss

Bill Marriott wjm at wjm.org
Mon Dec 19 14:40:10 EST 2005


There is no built-in function, but the custom function below (place it in 
the stack script) should get you started:

===================================

function ConvertSeconds mySecondsTime

  if isNumber(mySecondsTime) then

    -- 3600 seconds in an hour
    put the trunc of (mySecondsTime / 3600) into myHours
    if myHours < 10 then put "0" before myHours -- leading zero

    -- 60 seconds in a minute
    put the trunc of ((mySecondsTime - (3600 * myHours)) / 60) into 
myMinutes
    if myMinutes < 10 then put "0" before MyMinutes -- leading zero

    -- the remainder is seconds
    put mySecondsTime - 3600 * myHours - 60 * myMinutes into mySeconds
    if mySeconds < 10 then put "0" before MySeconds -- leading zero
    return myHours & ":" & myMinutes & ":" & mySeconds

  else

    return "Error: ConvertSeconds() requires a number"

  end if

end ConvertSeconds

===================================

>From this you can use ConvertSeconds(number) from any handler in the stack 
to get the result you want.

Example:

ConvertSeconds(60) returns "00:01:00"
ConvertSeconds(121.5) returns "00:02:01.5"

- Bill


"Garrett Hylltun" <garretthylltun at gmail.com> 
wrote in message news:DFA618F5-E5A1-4050-B37F-1E9B4DE6C247 at gmail.com...
> Greetings,
>
> Is there a command or function to convert the Player duration into 
> hh:mm:ss?
>
> I know that the following gives me the total seconds of the media  file, 
> but I'm lost as to how to convert
>
> divide duration of Player "objPlayerMain" by the timeScale of player 
> "objPlayerMain"
>
> I browsed through the documentation and saw a few things like  "convert", 
> but could not see how to use it in this situation.
>
> I'm still a newb with Rev, but some things are coming along fine,  while 
> other still seem to confuse me a bit like the above.
>
> Thanks in advance,
> -Garrett
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your 
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
> 






More information about the use-livecode mailing list