How to work out remaining time on a video

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
UtahCode197
Posts: 21
Joined: Sat Jun 22, 2013 9:36 pm

How to work out remaining time on a video

Post by UtahCode197 » Fri Dec 20, 2013 9:57 am

I'm trying to make a countdown next to a video that will start when the video starts and countdown until the video ends. So far I've got:

Code: Select all

subtract duration of player "My Video" from currenttime of player "My Video" 
If this is right then all I need to know is how to get it onto a label text field

Thanks a lot!

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: How to work out remaining time on a video

Post by Simon » Fri Dec 20, 2013 10:19 am

Hi Rory,
Here's what I have:

Code: Select all

on playStarted
whatTime
end playStarted

on whatTime
   put (the currentTime of me/the timeScale of me) into tCurrent
   put (the duration of me/the timeScale of me) into totalSeconds
   put round(totalSeconds - tCurrent) into fld 1
   send whatTime to me in 1 second
end whatTime
All that in the script of the video player works.

Simon
Edit: Important edit

Code: Select all

on playStarted
whatTime
end playStarted

on whatTime
   put (the currentTime of me/the timeScale of me) into tCurrent
   put (the duration of me/the timeScale of me) into totalSeconds
   put round(totalSeconds - tCurrent) into fld 1
   if fld 1 <= 0 then exit whatTime
   send whatTime to me in 1 second
end whatTime
Have to stop that send :)
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Klaus
Posts: 14187
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: How to work out remaining time on a video

Post by Klaus » Fri Dec 20, 2013 1:07 pm

Hi Rory,
RoryJMcEwan wrote:

Code: Select all

subtract duration of player "My Video" from currenttime of player "My Video" 
besides from what Simon said, you really should think this logics over!
If you really don't see what's wrong here, substitute "duration" and "currenttime" with real time values 8)


Best

Klaus

Post Reply