Offline
Jr. Member
Karma: 0
Posts: 62
2b/!2b
|
 |
« Reply #75 on: April 12, 2011, 01:17:18 pm » |
Does anybody have any possibilities for me please.
I have worked hard on this and got too far to turn back.
There is a solution somewhere, I'm sure of it.
Could someone please look at my code and help me.
Thank you very much.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Tesla Member
Karma: 83
Posts: 8243
:(){:|:&};:
|
 |
« Reply #76 on: April 12, 2011, 02:18:22 pm » |
IMHO the error is here(arduino code): if((val == 10)||(val == 13)) { // if header or stop bytes before the 10 digit reading break; // stop reading }
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 62
2b/!2b
|
 |
« Reply #77 on: April 12, 2011, 02:25:39 pm » |
Thanks for your post. I don't understand what the val is in relation to? The command variable? if (length(command)!=10){ break; } So there is not a possibility of using another file or program to close and open the daemon file that plays the video? Thank you for replying, no other idea's out there any where? Hope to hear something back
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Tesla Member
Karma: 83
Posts: 8243
:(){:|:&};:
|
 |
« Reply #78 on: April 12, 2011, 02:33:36 pm » |
sorry, I was wrong. the error is:
if(bytesread == 10) { // if 10 digit read is complete Serial.println(code); // print the TAG code }
should be
if(bytesread == 10) { // if 10 digit read is complete code[10]='\0'; //add end of string signal Serial.print(code); // print the TAG code }
add the end string signal and remove the "ln" in the print, or in processing you will read \n as character. probably processing should read 11 char, because the last is \0, i dunno, just test
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 62
2b/!2b
|
 |
« Reply #79 on: April 12, 2011, 02:51:09 pm » |
It is so annoying if the error was at the start, but that would make sense.
Somehow I have updated the arduino with the code and tested the arduino and it works, why i left println instead of print i have no idea.
Your right, 10 variable is 0 inclusive, that would make sense.
I'm still getting a error on the processing side, a null pointer exception in the draw method at this line:
synchronized(playingMovie) {//to be sure we don't change video while it is changed by Serial command
I thought it was because it didn't have a video to play but there is sound coming from the program, it is loading file1 straight away.
Also, the sound turns off after 3 seconds.
I used your code previously submitted.
Should the if (playingMovie != null) code be above the synchronize?
Thanks so much for your help again.
Maybe it is feasible.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 62
2b/!2b
|
 |
« Reply #80 on: April 12, 2011, 02:59:31 pm » |
oh my, the previous code that I was working with actually works now. The error was in the arduino board, I would never of thought of that. That was perfect what you said and println was the problem too. Now its just a matter of the sound playing all the way through. I can extract the audio no problem if needed. I will put the code I was originally using: import processing.serial.*; import processing.video.*; import jmcvideo.*;
Serial myPort; // The serial port Movie myMovie;
void movieEvent(Movie m) { m.read(); }
void setup() { size(400,400,P3D); // Open whatever port is the one you're using. myPort = new Serial(this, Serial.list()[1], 2400);
background(0); }
void draw() { while (myPort.available() >= 10) { //Video Code: String command = ""; for (int i=0;i<10;i++){ command += myPort.readChar(); } println(command); myMovie = new Movie(this, command+".mov"); //myMovie.setSize(); myMovie.play(); } if (myMovie != null){ image(myMovie, 0, 0); //image(myMovie, 0, 0, width, height); } } Thank you sooooo much, your obviously very knowledgable with arduino!!!!! 
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 62
2b/!2b
|
 |
« Reply #81 on: April 12, 2011, 03:15:13 pm » |
Should I mark this as solved and create a new forum post asking about the audio?
I can't thank you enough lesto.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Tesla Member
Karma: 83
Posts: 8243
:(){:|:&};:
|
 |
« Reply #82 on: April 12, 2011, 03:40:25 pm » |
 for the audio open a new thread, this is enough full  but if you are going to play audio with processing is better use their forum, here is a little off-topic
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 62
2b/!2b
|
 |
« Reply #83 on: April 12, 2011, 05:48:33 pm » |
I have got audio to work now.
The only problem is the video plays as if it has lag.
I've asked for help on the processing forum.
Thought I would mention is here as well.
Thanks again.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Tesla Member
Karma: 83
Posts: 8243
:(){:|:&};:
|
 |
« Reply #84 on: April 12, 2011, 06:23:47 pm » |
maybe this is because you read serial in draw... serial is really slow, so try to use serialEvent
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 62
2b/!2b
|
 |
« Reply #85 on: April 12, 2011, 08:06:41 pm » |
Perfect  Now I need to work out how to stop the audio files from overlapping. I was thinking of using: myMovie.dispose(); player.close(); and minim.stop(); but i'm not sure where to put it. Updated Code: import processing.serial.*; import processing.video.*; import jmcvideo.*; import ddf.minim.*;
AudioPlayer player; Minim minim;
Serial myPort; // The serial port Movie myMovie;
void movieEvent(Movie m) { m.read(); }
void setup() { size(320,240,P3D); minim = new Minim(this); // Open whatever port is the one you're using. myPort = new Serial(this, Serial.list()[1], 2400);
background(0); }
void draw() {
if (myMovie != null){ image(myMovie, 0, 0); smooth(); ///image(myMovie, 0, 0, 320, 240); } }
void serialEvent(Serial p){ while (myPort.available() >= 10) { //Video Code: String command = ""; for (int i=0;i<10;i++){ command += myPort.readChar(); } println(command); myMovie = new Movie(this, command+".mov"); player = minim.loadFile(command+".wav", 2048); //myMovie.setSize(); myMovie.play(); player.play(); } } Many Thanks
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Tesla Member
Karma: 83
Posts: 8243
:(){:|:&};:
|
 |
« Reply #86 on: April 13, 2011, 06:45:36 am » |
put them before myMovie = new Movie(this, command+".mov"); player = minim.loadFile(command+".wav", 2048);
you just have to check that myMovie isn't null
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 62
2b/!2b
|
 |
« Reply #87 on: April 13, 2011, 02:20:30 pm » |
Working great now.
I had to put them after the code mentioned.
Sometimes i get a null pointer reference but the program still works.
Thank you this is great.
You've been a great help.
Thank you
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 62
2b/!2b
|
 |
« Reply #88 on: April 13, 2011, 04:37:11 pm » |
The video's are playing and the sound is playing but every so often the file will crash and deliver this report: Stable Library ========================================= Native lib Version = RXTX-2.1-7 Java lib Version = RXTX-2.1-7 3600A9C9F8 360073D274 3600A9C9F8 F0000000F0 The file "F0000000F0.mov" is missing or inaccessible, make sure the URL is valid or that the file has been added to your sketch and is readable. error, disabling serialEvent() for //./COM4 java.lang.reflect.InvocationTargetException at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at processing.serial.Serial.serialEvent(Unknown Source) at gnu.io.RXTXPort.sendEvent(RXTXPort.java:732) at gnu.io.RXTXPort.eventLoop(Native Method) at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1575) Caused by: java.lang.NullPointerException at quicktime.util.QTHandle.<init>(QTHandle.java:287) at processing.video.Movie.init(Unknown Source) at processing.video.Movie.<init>(Unknown Source) at processing.video.Movie.<init>(Unknown Source) at dumdum.serialEvent(dumdum.java:80) ... 7 more
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Tesla Member
Karma: 83
Posts: 8243
:(){:|:&};:
|
 |
« Reply #89 on: April 13, 2011, 05:44:35 pm » |
some time your rfid read "F0000000F0" and there is no video with such name.
|
|
|
|
|
Logged
|
|
|
|
|
|