switching between movies

Mark Talluto userev at canelasoftware.com
Tue Aug 24 19:18:22 EDT 2004


On Aug 24, 2004, at 12:36 AM, Cubist at aol.com wrote:

> sez userev at canelasoftware.com:
>> On Aug 23, 2004, at 12:28 AM, Jason Tangen wrote:
>>
>>> I have two movies (both 640x480, 240 frames, ~2MB each).  I want to
>>> allow the user to click a button to switch back and forth between the
>>> two without delay.  Right now - I'm using the following strategy:
>>>
>>> on keydown key
>>>   if key = space then
>>>     put the currentTime of player "A" into Atime
>>>     set lockscreen to true
>>>     hide player "A"
>>>     set the currentTime of player "B" to Atime
>>>     show player "B"
>>>     start player "B"
>>>     set lockscreen to false
>>>   else pass keyDown
>>> end keydown
>>>
>>> ...but this results in a rather noticeable delay between the clips.
>>
>> Hi Jason,
>>
>> I modified your program slightly.  The main thing I noticed was to 
>> take
>> out the lock screen.  This made things pretty snappy.  The faster the
>> computer, the faster the transition.  I put this code at the card 
>> level.
>>
>> on keydown thekey
>>   put thekey
>>   if thekey = "1" then
>>     stop player "B"
>>     put the currentTime of player "B" into Atime
>>     hide player "B"
>>     set the currentTime of player "A" to Atime
>>     show player "A"
>>     start player "A"
>>   end if
>>
>>   if thekey = "2" then
>>     stop player "A"
>>     put the currentTime of player "A" into Atime
>>     hide player "A"
>>     set the currentTime of player "B" to Atime
>>     show player "B"
>>     start player "B"
>>   end if
>>   pass keyDown
>> end keydown
>    Speaking as an amateur with a fetish for minimizing the number of 
> lines of
> code, I'd be interested to see if the following modification of your 
> handler
> is any better or worse than your code...
>
> on keydown thekey
>   put thekey
>   switch theKey
>     case 1
>       put "B" into OldPlay
>       put "lay
>   put the currentTime of player OldPlay into Atime
>   hide player OldPlay
>   set the currentTime of player NuPlay to Atime
>   show player NuPlay
>   start player NuPlay
>
>   pass keyDown
> end keydown
>

I took at guess and made :  put "lay   ---> put "A" into "NuPlay"

In any case, this will not toggle the videos.  It will start the first 
video and nothing more.  Hitting 1 will only restart the video.  But 
yes, it is shorter than my solution.

-- 
Best regards,
Mark Talluto
http://www.canelasoftware.com



More information about the Use-livecode mailing list