Initial commit

This commit is contained in:
Victor Giers
2017-02-12 01:40:53 +01:00
commit c9075daf5e
5 changed files with 193 additions and 0 deletions

10
README.md Normal file
View File

@@ -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

74
classes.pde Normal file
View File

@@ -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);
}
}

BIN
data/katze.avi Normal file

Binary file not shown.

68
functions.pde Normal file
View File

@@ -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();
}

41
zoomableMoviePlayer.pde Normal file
View File

@@ -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);
}