Start and Stop buttons?

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Damlimey
Posts: 31
Joined: Sun May 31, 2009 10:56 am

Start and Stop buttons?

Post by Damlimey » Sat Jun 06, 2009 1:30 pm

Hi Rev World,

I have a function that I currently use two buttons for, Start and Stop. How do I combine those functions into one button so that the first click starts a media file (start player), clicking again stops the file (stop player)? I also want the stop to reset it to the beginning ready for another 'start' click.

Thanks in advance

G

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Post by bn » Sat Jun 06, 2009 1:38 pm

Hi G,

just make a button and set the script to:

Code: Select all

on mouseUp
   put the label of me into myLabel
   if myLabel is not "Stop" then 
      set the label of me to "Stop"
      start player 1
   else
      set the label of me to "Start"
      stop player 1
      -- this resets the player to the beginning
      set the currenttime of player 1 to 0
   end if
end mouseUp
regards
Bernd

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Post by bn » Sat Jun 06, 2009 2:01 pm

G,

you might want to add to the script of the player:

Code: Select all

on  playstopped
   set the label of button 1 to "Start"
end playstopped
That will set the label of the start/stop button to start once the player is done.
regards
Bernd

Post Reply