import processing.core.*; import com.mobvcasting.mvideocapture.*; import com.mobvcasting.mvideoplayback.*; import com.mobvcasting.mmmsmessaging.*; public class week7 extends PMIDlet { MMMSMessaging mmssender; MVideoPlayback vidplay; MVideoCapture vidcap; byte[] videoData; String captureKey = "Capture"; String stopCaptureKey = "Stop Capture"; String playKey = "Play Video"; String stopPlayKey = "Stop Video"; String sendKey = "Send Video"; String statusMessage = "Not Captured"; PFont font; public static int MAX_MESSAGE_SIZE = 305000; public void setup() { softkey(captureKey); font = loadFont("Arial-Black-12.mvlw"); textFont(font); vidcap = new MVideoCapture((PMIDlet)this); vidcap.showCamera(); mmssender = new MMMSMessaging(this); noLoop(); } public void draw() { background(255); text(statusMessage,10,15); } public void softkeyPressed(String label) { if (label.equals(captureKey)) { //vidcap.timedCapture(20); vidcap.startCapture(); softkey(stopCaptureKey); } else if (label.equals(stopCaptureKey)) { vidcap.stopCapture(); } else if (label.equals(playKey)) { vidplay = new MVideoPlayback(this,videoData,"video/3gpp"); vidplay.showPlayer(0, 0, width, height); vidplay.playVideo(); softkey(stopPlayKey); } else if (label.equals(stopPlayKey)) { vidplay.stopVideo(); softkey(sendKey); } else if (label.equals(sendKey)) { if (videoData.length < MAX_MESSAGE_SIZE) { mmssender.sendMMS("rringrring@gmail.com","subject","body",videoData,"video/3gpp","avideo.3gp"); } else { // Too big, divide up int numSegments = (int)Math.ceil((double)((double)videoData.length/(double)MAX_MESSAGE_SIZE)); for (int i = 0; i < numSegments; i++) { byte[] newOutputArray; if (i < numSegments - 1) { newOutputArray = new byte[MAX_MESSAGE_SIZE]; System.arraycopy(videoData, i*MAX_MESSAGE_SIZE, newOutputArray, 0, MAX_MESSAGE_SIZE); } else { newOutputArray = new byte[videoData.length - i*MAX_MESSAGE_SIZE]; System.arraycopy(videoData, i*MAX_MESSAGE_SIZE, newOutputArray, 0, newOutputArray.length); } mmssender.sendMMS("rringrring@gmail.com","capturedVideo " + (i+1) + " of " + numSegments,"body",newOutputArray,"video/3gpp","avideo_part_" + i + ".3gp"); } } statusMessage = "Sending Video"; } redraw(); } public void libraryEvent(Object library, int event, Object data) { if (library.getClass().isInstance(vidcap) && event == MVideoCapture.CAPTURE_COMPLETE) { videoData = (byte[])data; vidcap.hideCamera(); vidcap.closeCamera(); softkey(playKey); redraw(); } } }