commit c9075daf5e4ea9d5a67ff42326e820d6ab5184af Author: Victor Giers Date: Sun Feb 12 01:40:53 2017 +0100 Initial commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..6cac4bb --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +Quick minimalistic movie player with zoom for Processing 2.2.1 +Only GUI element is a timeline. +Intended to use for zooming into movies to be able to see details of videos that have a higher resolution than your screen. +Drag & drop a movie from your window manager into the viewport to load and play it. +- Pause/play with middle mouse +- Mousewheel for zooming in / out +- Drag & drop the movies image with left mouse button +- Save a screenshot with right mouse button + +victorgiers.com diff --git a/classes.pde b/classes.pde new file mode 100644 index 0000000..223bd92 --- /dev/null +++ b/classes.pde @@ -0,0 +1,74 @@ +class Viewport { + PGraphics renderer; + int movW; + int movH; + Viewport() { + } + void reload() { + scaleFactor = 1; + translateX = 0; + translateY = 0; + } + void update() { + renderer = createGraphics(width, height); + if (mov.width > mov.height) { + movW = width; + movH = int(map(mov.height, 0, mov.width, 0, width)); + } else { + movH = height; + movW = int(map(mov.width, 0, mov.height, 0, height)); + } + renderer.beginDraw(); + renderer.background(0); + renderer.pushMatrix(); + renderer.translate(translateX, translateY); + renderer.scale(scaleFactor); + renderer.imageMode(CENTER); + renderer.image(mov, width/2, height/2, movW, movH); + renderer.popMatrix(); + renderer.endDraw(); + } + void display() { + image(renderer, 0, 0, width, height-timeline.h); + } +} + +class Timeline { + int x, y, w, h; + int playPos; + boolean clicked; + Timeline(int _x, int _y, int _w, int _h) { + x = _x; + y = _y; + w = _w; + h = _h; + } + void update() { + y = height-20; + w = width; + playPos = int(map(mov.time(), 0, mov.duration(), 0, w)); + } + void display() { + noStroke(); + fill(127); + rect(x, y, w, h); + fill(255); + rect(x, y, playPos, h); + } + boolean hover() { + if (mouseX > x && mouseX < x+w && mouseY > y && mouseY < y+h) + return true; + else + return false; + } + void clicked() { + clicked = true; + jump(); + } + void jump() { + float f = map(mouseX-x, x, w, 0, 1); + float t = mov.duration() * f; + mov.jump(t); + } +} + diff --git a/data/katze.avi b/data/katze.avi new file mode 100644 index 0000000..e6ee959 Binary files /dev/null and b/data/katze.avi differ diff --git a/functions.pde b/functions.pde new file mode 100644 index 0000000..5b21690 --- /dev/null +++ b/functions.pde @@ -0,0 +1,68 @@ +int mouseClickX, mouseClickY; + +void mousePressed() { + if (mouseButton == CENTER) { + playPause(); + } + if (mouseButton == LEFT) { + if (timeline.hover()) { + timeline.clicked(); + } + mouseClickX = mouseX; + mouseClickY = mouseY; + } + if (mouseButton == RIGHT){ + viewport.renderer.save("screenshots/" + month() + day() + hour() + minute() + second() + millis() + ".png"); + } +} + +void mouseDragged() { + if (timeline.clicked) { + timeline.jump(); + } else { + translateX += (mouseX - mouseClickX); + translateY += (mouseY - mouseClickY); + mouseClickX = mouseX; + mouseClickY = mouseY; + } +} + +void mouseReleased() { + timeline.clicked = false; +} + +void mouseWheel(MouseEvent e) { + float mwheel = -e.getAmount(); + scaleFactor += mwheel / 10; + translateX -= mwheel * mouseX / 10; + translateY -= mwheel * mouseY / 10; +} + +boolean b_pause; +void playPause() { + b_pause =! b_pause; + if (b_pause) mov.pause(); + else mov.play(); +} + +void movieEvent(Movie m) { + m.read(); +} + +void dropEvent(DropEvent theDropEvent) { + if (theDropEvent.isFile()) { + loadMovie(theDropEvent.file().getAbsolutePath()); + } +} + +void loadMovie(String _path) { + String path = _path; + if (playing) + mov.stop(); + mov = new Movie(this, path); + mov.loop(); + playing = true; + frame.setTitle(path); + viewport.reload(); +} + diff --git a/zoomableMoviePlayer.pde b/zoomableMoviePlayer.pde new file mode 100644 index 0000000..05f7419 --- /dev/null +++ b/zoomableMoviePlayer.pde @@ -0,0 +1,41 @@ +/* +Quick minimalistic movie player with zoom for Processing 2.2.1 +Only GUI element is a timeline. +Intended to use for zooming into movies to be able to see details of videos that have a higher resolution than your screen. +Drag & drop a movie from your window manager into the viewport to load and play it. +- Pause/play with middle mouse +- Mousewheel for zooming in / out +- Drag & drop the movies image with left mouse button +- Save a screenshot with right mouse button + +victorgiers.com +*/ + +import processing.video.*; +import sojamo.drop.*; + +Movie mov; +SDrop dropimport; +Timeline timeline; +Viewport viewport; + +boolean playing; +float scaleFactor, translateX, translateY; + +void setup() { + size(1200, 800); + frame.setResizable(true); + scaleFactor = 1; + viewport = new Viewport(); + timeline = new Timeline(0, height-20, width, 20); + loadMovie("katze.avi"); + dropimport = new SDrop(this); +} + +void draw() { + timeline.update(); + timeline.display(); + viewport.update(); + viewport.display(); + println(scaleFactor); +}