I'm using Ruby to check the position of videos I'm playing in Quicktime via Scripting Bridge.
At the moment I'm just checking the position like so every n
seconds:
require 'osx/cocoa'
include OSX
OSX.require_framework 'ScriptingBridge'
app = SBApplication.applicationWithBundleIdentifier_("com.apple.QuickTimePlayerX")
while true
app.documents.each do |doc|
p doc.currentTime
p doc.playing
end
wait(n_seconds)
end
This is more CPU intensive than I'd like, is there a way to make Scripting Bridge trigger a Ruby block when a particular event happens?
eg. When a document is opened, closed, paused/resumed and so on?
Thanks in advance!