I'm making a project using Osculator and Processing, and the Wiimote controls a video that is displayed through Processing.
I am having trouble switching between videos by using the directional pad on the Wiimote. I want it so up switches to video 1 and down video 2 etc. but it isn't working, can anyone see the issue in the code?
Another issue involves the roll. I have it so that rolling left rewinds and rolling right fast forwards, however I want it so when the video returns to the central position it plays the video in normal time again, but it doesn't do this at present.
FYI the A button plays and pauses the video and this works fine.
If anyone could offer help and assistance on these two issues it would be much appreciated.
Thank you
..And here is my code in full:
import codeanticode.gsvideo.*; // import GSvideo Library
import oscP5.*; // import oscP5 Library
import netP5.*; // import netP5 Library (part of oscP5 Library)
OscP5 osculator;
GSMovie player;
//global variables
int direction;
boolean speedSet = false;
boolean isPlaying = true;
boolean rollBool = true;
boolean pressA = true;
float rollVar;
boolean backward;
boolean forward;
boolean pressUp;
boolean pressRight;
boolean pressLeft;
public void setup() {
size(640, 480);
background(0)
osculator = new OscP5(this, 9000);
osculator.plug(this, "xyz", "/wii/1/accel/pry");
osculator.plug(this, "buttonA", "/wii/1/button/A");
osculator.plug(this, "buttonLeft", "/wii/1/button/Left");
osculator.plug(this, "buttonRight", "/wii/1/button/Right");
osculator.plug(this, "buttonUp", "/wii/1/button/Up");
osculator.plug(this, "buttonDown", "/wii/1/button/Down");
// GSvideo setup
player = new GSMovie(this, "tdogg.mov");
player.loop();
}
void draw() {
image(player, 0, 0, width, height);
//PLAY/PAUSE
if (pressA || press1) {
player.play();
speedSet = false;
}
if (!pressA) {
player.pause();
//speedSet = false;
}
//FORWRD AND REWIND
if (forward) {
//speedSet = false;
forward();
}
if (backward) {
//speedSet = false;
backward();
}
if (pressLeft){
buttonLeft();
}
if (pressRight){
buttonRight();
}
if (pressUp){
buttonUp();
}
//ACTION TO CALL BUTTON A
void buttonA (float press) {
if (press != 0) {
//speedSet = false;
pressA = !pressA; // toggle
press1 = !press1; // toggle
}
}
//ACTION TO CALL ROLL
void xyz (float p, float r, float y, float a) {
rollVar = r;
if (rollVar <= 0.35) {
backward = true;
forward = false;
}
if (rollVar >= 0.65) {
forward = true;
backward = false;
}
if (rollVar < 0.65 && rollVar > 0.35) {
isPlaying = true;
forward = false;
backward = false;
}
}
//MOVIE EVENT
void movieEvent(GSMovie player) {
player.read();
}
//TAB TO CHANGE VIDEO
void buttonLeft() {
player = new GSMovie (this, "tdogg.mov");
}
void buttonRight() {
player = new GSMovie (this, "bunny.mov");
}
void buttonUp () {
player = new GSMovie (this, "transit.mov");
}
//TAB THAT SHOULD REWIND VIDEO
void backward() {
if (!speedSet) {
player.pause();
// Setting the speed should be done only once, this is the reason for the if statement.
speedSet = true;
// 2.0 means playback at 3 x normal speed.
player.speed(-2.0);
player.loop();
}
}
//TAB THAT SHOULD FAST FORWARD VIDEO
void forward() {
if (!speedSet) {
player.pause();
// Setting the speed should be done only once, this is the reason for the if statement.
speedSet = true;
player.speed(3.0);
player.loop();
}
}
I am having trouble switching between videos by using the directional pad on the Wiimote. I want it so up switches to video 1 and down video 2 etc. but it isn't working, can anyone see the issue in the code?
Another issue involves the roll. I have it so that rolling left rewinds and rolling right fast forwards, however I want it so when the video returns to the central position it plays the video in normal time again, but it doesn't do this at present.
FYI the A button plays and pauses the video and this works fine.
If anyone could offer help and assistance on these two issues it would be much appreciated.
Thank you
..And here is my code in full:
import codeanticode.gsvideo.*; // import GSvideo Library
import oscP5.*; // import oscP5 Library
import netP5.*; // import netP5 Library (part of oscP5 Library)
OscP5 osculator;
GSMovie player;
//global variables
int direction;
boolean speedSet = false;
boolean isPlaying = true;
boolean rollBool = true;
boolean pressA = true;
float rollVar;
boolean backward;
boolean forward;
boolean pressUp;
boolean pressRight;
boolean pressLeft;
public void setup() {
size(640, 480);
background(0)
osculator = new OscP5(this, 9000);
osculator.plug(this, "xyz", "/wii/1/accel/pry");
osculator.plug(this, "buttonA", "/wii/1/button/A");
osculator.plug(this, "buttonLeft", "/wii/1/button/Left");
osculator.plug(this, "buttonRight", "/wii/1/button/Right");
osculator.plug(this, "buttonUp", "/wii/1/button/Up");
osculator.plug(this, "buttonDown", "/wii/1/button/Down");
// GSvideo setup
player = new GSMovie(this, "tdogg.mov");
player.loop();
}
void draw() {
image(player, 0, 0, width, height);
//PLAY/PAUSE
if (pressA || press1) {
player.play();
speedSet = false;
}
if (!pressA) {
player.pause();
//speedSet = false;
}
//FORWRD AND REWIND
if (forward) {
//speedSet = false;
forward();
}
if (backward) {
//speedSet = false;
backward();
}
if (pressLeft){
buttonLeft();
}
if (pressRight){
buttonRight();
}
if (pressUp){
buttonUp();
}
//ACTION TO CALL BUTTON A
void buttonA (float press) {
if (press != 0) {
//speedSet = false;
pressA = !pressA; // toggle
press1 = !press1; // toggle
}
}
//ACTION TO CALL ROLL
void xyz (float p, float r, float y, float a) {
rollVar = r;
if (rollVar <= 0.35) {
backward = true;
forward = false;
}
if (rollVar >= 0.65) {
forward = true;
backward = false;
}
if (rollVar < 0.65 && rollVar > 0.35) {
isPlaying = true;
forward = false;
backward = false;
}
}
//MOVIE EVENT
void movieEvent(GSMovie player) {
player.read();
}
//TAB TO CHANGE VIDEO
void buttonLeft() {
player = new GSMovie (this, "tdogg.mov");
}
void buttonRight() {
player = new GSMovie (this, "bunny.mov");
}
void buttonUp () {
player = new GSMovie (this, "transit.mov");
}
//TAB THAT SHOULD REWIND VIDEO
void backward() {
if (!speedSet) {
player.pause();
// Setting the speed should be done only once, this is the reason for the if statement.
speedSet = true;
// 2.0 means playback at 3 x normal speed.
player.speed(-2.0);
player.loop();
}
}
//TAB THAT SHOULD FAST FORWARD VIDEO
void forward() {
if (!speedSet) {
player.pause();
// Setting the speed should be done only once, this is the reason for the if statement.
speedSet = true;
player.speed(3.0);
player.loop();
}
}
Comment