开发者

Creating a variable-speed slideshow based on USB input on OSX

I have a friend who is trying to put together a geeky little contraption for a wedding, where people can view a slideshow. Neither of us use Macs开发者_JAVA技巧, nor have programmed for one, but for various reasons it has to run on a Mac.

There will be a USB ammeter hooked up to a bike dynamo. What we want is for a slideshow to be run, and advance at a speed relative to how fast someone is pedaling on a stationary bike.

After much googling, it seems like we could load an iPhoto slideshow up via applescript. Is it possible to pause the slideshow and advance it with keypress commands?

The applescript commands would be run via a bash script or similar that would monitor the value returned by the USB ammeter's command-line app and issue the keypress events accordingly.

Is there some other app that could be likewise scripted to display photos?Hoping someone has some hints to get us started in the right direction!

Thanks!


I would think controlling a quicktime movie would be easiest. Note that you can save an iPhoto slideshow to a quicktime movie... this might be the best approach.

So assuming you have the slideshow playing as a movie in quicktime player, then you can control it with applescript commands and you could do something like the following...

tell application "QuickTime Player"
    tell front document
        set rate to 1.5
    end tell
end tell

A rate of 1.0 is normal speed. Under 1.0 is slowing the movie and so on. My example speeds the movie up by 50%. You can also do other things to the front document, like "play", "stop", "pause" for example.

And from bash you can run an applescript using osascript. So the above applescript can be run from the command line with the following bash script...

#!/bin/bash
/usr/bin/osascript <<EOT
tell application "QuickTime Player"
tell front document
set rate to 1.5
end tell
end tell
EOT

I hope that helps. Good luck.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜