control player object with mouse scroll wheel

Visuals, audio, animation. Blended, not stirred. If LiveCode is part of your rich media production toolbox, this is the forum for you.

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
Martin Koob
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 237
Joined: Sun May 27, 2007 8:19 pm

control player object with mouse scroll wheel

Post by Martin Koob » Sun Dec 02, 2007 9:39 pm

I was wondering if there was a way to make a player object receive the scroll messages from a mouse with a scroll wheel or from a two finger scroll gesture on a Mac Book Pro track pad.

The Quicktime Player application and a quicktime player in a web page does receive these so you can scrub back and forth in the video with the scroll button or on the track pad. I have tried this with a player in revolution and it does not work.

Martin

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1236
Joined: Sat Apr 08, 2006 1:10 pm
Location: Zurich
Contact:

Post by BvG » Mon Dec 03, 2007 1:47 am

the scrollweel emits rawkeydown messages, so you can catch that, and do anything you want, like increasing or decreasing playloudness, the currentime, or the playrate.
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

Martin Koob
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 237
Joined: Sun May 27, 2007 8:19 pm

Post by Martin Koob » Tue Dec 04, 2007 2:31 am

Thanks for the tip.

I managed to trap the rawkeydown messages and have them change the player's current time by putting the handlers I have listed below in the player's script, but, now when I scroll the mouse wheel up and down the slider in the movie controller moves accordingly but the movie does not redraw. If I click on a step button or push play then the movie will refresh and show the next frame. Is there another command that I need to make it redraw?

I don't have this problem in other situations where I set the currenttime of the player. It jumps to a new location and the movie display is updated. Is it because it is such a small increment?



on rawKeyDown theKeyNumber
if theKeyNumber is 65308 then stepforward -- mouse wheel down
else if theKeyNumber is 65309 then stepbackward -- mouse wheel up
else pass rawKeyDown
end rawKeyDown


on stepforward
set the currenttime of me to (the currenttime of me) + ((the timescale of me / 4))
end stepforward

on stepbackward
set the currenttime of me to (the currenttime of me) - ((the timescale of me / 4))
end stepbackward

Martin Koob

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 962
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Post by trevordevore » Tue Dec 04, 2007 4:05 pm

Hi Martin,

Try changing your code to this:

Code: Select all

on stepforward
    lock screen
    set the currenttime of me to (the currenttime of me) + round(the timescale of me / 4) 
    unlock screen
end stepforward 

on stepbackward
    lock screen
    set the currenttime of me to (the currenttime of me) - round(the timescale of me / 4) 
    unlock screen
end stepbackward 

locking/unlocking the screen worked on my end. Also adding round() to the calculation is necessary for movies that don't have a timescale of 600 (mp4 and mpg for example).
Trevor DeVore
ScreenSteps - http://www.screensteps.com

Levure Application Framework: https://github.com/trevordevore/levure
LiveCode Resources for Developers: http://livecode.bluemangolearning.com

Post Reply

Return to “Rich Media”