Sensor, timer and video

Hello,

I am trying to use the a sensor to trigger a video to player.
Is it possible on oF to allow a video to be played with a the sensor sensed a certain of distance amongst certain of time?
eg. ping sensor sensed 100 for 3 seconds, then play video.
(ps i got oF connected to my ping sensor already)

Cheers,
Karen

Yes, I can’t see any reason why not. There are a number of ways to do this.

One way is to create a Sensor Class that inherits ofThread to poll the sensor; once the sensor value meets your requirements for a given time and distance, stop the thread and request the video playback. Monitor the playback so that once the video ends you can restart the thread.

References:
http://openframeworks.cc/documentation/utils/ofThread.html
http://openframeworks.cc/documentation/video/ofVideoPlayer.html
http://openframeworks.cc/documentation/utils/ofUtils.html#!show_ofGetElapsedTimef