#N canvas 931 293 685 546 10; #X obj 280 346 ofelia define -k \$0-video; #A set if type(window) ~= "userdata" then \; window = ofWindow() \; end \; \; local canvas = pdCanvas(this) \; local clock = pdClock(this \, "setup") \; local videoPlayer = ofVideoPlayer() \; \; function ofelia.bang() \; ofWindow.addListener("setup" \, this) \; ofWindow.addListener("update" \, this) \; ofWindow.addListener("exit" \, this) \; window:setPosition(30 \, 100) \; window:setSize(800 + 40 \, 600 + 40) \; if type(window) ~= "userdata" then \; window = ofWindow() \; end \; \; window:create() \; if ofWindow.exists then \; clock:delay(0) \; end \; end \; \; function ofelia.free() \; window:destroy() \; ofWindow.removeListener("setup" \, this) \; ofWindow.removeListener("update" \, this) \; ofWindow.removeListener("draw" \, this) \; ofWindow.removeListener("exit" \, this) \; end \; \; function ofelia.setup() \; ofSetWindowTitle("Video Player") \; ofBackground(0 \, 0 \, 0 \, 255) \; end \; \; function ofelia.moviefile(path) \; videoPlayer:load(path) \; ofWindow.addListener("draw" \, this) \; videoPlayer:setLoopState(OF_LOOP_NORMAL) \; videoPlayer:setPaused(true) \; end \; \; function ofelia.setSpeed(f) \; videoPlayer:setSpeed(f / 100) \; end \; \; function ofelia.play() \; videoPlayer:play() \; end \; \; function ofelia.stop() \; videoPlayer:setFrame(0) \; videoPlayer:setPaused(true) \; end \; \; function ofelia.setPaused(f) \; if f == 1 then pause = true \; else pause = false \; end \; videoPlayer:setPaused(pause) \; end \; \; function ofelia.setFrame(f) \; videoPlayer:setFrame(f) \; end \; \; function ofelia.setPosition(f) \; videoPlayer:setPosition(f) \; end \; \; function ofelia.setVolume(f) \; videoPlayer:setVolume(f / 100) \; end \; \; function ofelia.update() \; videoPlayer:update() \; end \; \; function ofelia.draw() \; ofSetHexColor(0xFF8F8F) \; videoPlayer:draw(20 \, 20 \, 800 \, 600) \; local pixels = videoPlayer:getPixels() \; local vidWidth = pixels:getWidth() \; local vidHeight = pixels:getHeight() \; local mulW = 800 / pixels:getWidth() \; local mulH = 600 / pixels:getHeight() \; local nChannels = pixels:getNumChannels() \; for i = 4 \, vidWidth-1 \, 8 do \; for j = 4 \, vidHeight-1 \, 8 do \; local r = pixels:getColor((j * 320 + i)*nChannels).r \; local val = 1 - (r / 255) \; ofSetColor (20 \, 50 \, 100 \, ofelia.alpha) \; ofDrawRectangle(10 + i * mulW \, 10 + j * mulH \, 20*val \, 20*val ) \; end \; end \; local outputList = {} \; outputList[1] = videoPlayer:getPosition() \; outputList[2] = videoPlayer:getCurrentFrame() \; outputList[3] = videoPlayer:getTotalNumFrames() \; return outputList \; end \; \; function ofelia.exit() \; videoPlayer:close() \; end \;; #X obj 331 114 openpanel; #X obj 331 94 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; #X msg 331 135 moviefile \$1; #X msg 280 80 play; #X msg 296 110 stop; #X floatatom 555 138 5 0 0 0 - - -; #X floatatom 191 149 5 0 0 0 - - -; #X msg 555 117 100; #X obj 555 96 loadbang; #X obj 335 160 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 1; #X obj 56 119 metro 40; #X obj 56 141 f; #X obj 56 99 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 1 ; #X msg 464 146 setVolume \$1; #X floatatom 464 126 5 0 100 0 - - -; #X obj 464 84 loadbang; #X obj 283 466 hsl 128 15 0 1 0 0 empty empty getPosition -2 -8 0 10 -257985 -1 -1 2255 1; #X msg 56 260 setPosition \$1; #X obj 59 240 hsl 128 15 0 1 0 0 empty empty setPosition -2 -8 0 10 -257985 -1 -1 8714 1; #X obj 280 398 unpack f f f; #X floatatom 280 419 5 0 0 3 pos - -; #X floatatom 314 419 5 0 0 3 frame - -; #X floatatom 349 419 8 0 0 0 - - -; #X obj 56 204 /; #X obj 113 79 hsl 128 15 -1000 1000 0 1 empty empty speed -2 -8 0 10 -257985 -1 -1 4700 1; #X obj 83 141 + 100; #X obj 56 162 / 100; #X obj 137 120 * 100; #X obj 122 141 mod; #X obj 349 440 s \$0-tFrameNum; #X obj 71 183 r \$0-tFrameNum; #X obj 137 99 r \$0-tFrameNum; #X msg 555 157 setSpeed \$1; #X msg 335 180 setPaused \$1; #X msg 191 169 setFrame \$1; #X obj 221 257 loadbang; #X obj 223 294 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; #X msg 466 313 alpha \$1; #X floatatom 466 293 5 0 255 0 - - -; #X msg 466 272 100; #X obj 466 251 loadbang; #X msg 464 105 50; #X connect 0 0 20 0; #X connect 1 0 3 0; #X connect 2 0 1 0; #X connect 3 0 0 0; #X connect 4 0 0 0; #X connect 5 0 0 0; #X connect 6 0 33 0; #X connect 7 0 35 0; #X connect 8 0 6 0; #X connect 9 0 8 0; #X connect 10 0 34 0; #X connect 11 0 12 0; #X connect 12 0 26 0; #X connect 12 0 27 0; #X connect 13 0 11 0; #X connect 14 0 0 0; #X connect 15 0 14 0; #X connect 16 0 42 0; #X connect 18 0 0 0; #X connect 19 0 18 0; #X connect 20 0 21 0; #X connect 20 1 22 0; #X connect 20 2 23 0; #X connect 21 0 17 0; #X connect 23 0 30 0; #X connect 24 0 19 0; #X connect 25 0 26 1; #X connect 26 0 29 0; #X connect 27 0 24 0; #X connect 28 0 29 1; #X connect 29 0 12 1; #X connect 31 0 24 1; #X connect 32 0 28 0; #X connect 33 0 0 0; #X connect 34 0 0 0; #X connect 35 0 0 0; #X connect 36 0 0 0; #X connect 37 0 0 0; #X connect 38 0 0 0; #X connect 39 0 38 0; #X connect 40 0 39 0; #X connect 41 0 40 0; #X connect 42 0 15 0;