MMMSMessaging Library

In my ongoing series of libraries for Mobile Processing, I put together a library for sending MMS Messages. You can download the library and the source.

Here is a quick example using it (this example also uses my MVideoCapture library):

import processing.core.*;

import com.mobvcasting.mmmsmessaging.*;
import com.mobvcasting.mvideocapture.*;

public class MMMSMessagingTest extends PMIDlet
{
MMMSMessaging mms;

MVideoCapture vidcap;

String captureKey = "Capture Video";
String stopKey = "Stop Capture";
String sendMessageKey = "Send Message";
String statusMessage = "";

byte[] outputArray;

//public static int MAX_MESSAGE_SIZE = 307200;
public static int MAX_MESSAGE_SIZE = 305000;

public void setup()
{
mms = new MMMSMessaging(this);
vidcap = new MVideoCapture(this);

softkey(captureKey);

noLoop();
}

public void draw()
{
background(255);
}

public void softkeyPressed(String label)
{
if (label.equals(sendMessageKey))
{
if (outputArray.length < MAX_MESSAGE_SIZE) { mms.sendMMS("youremailorphonenumber","subject","body",outputArray,"video/3gpp","avideo.3gp"); } else { // Too big, divide up int numSegments = (int)Math.ceil((double)((double)outputArray.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(outputArray, i*MAX_MESSAGE_SIZE, newOutputArray, 0, MAX_MESSAGE_SIZE); } else { newOutputArray = new byte[outputArray.length - i*MAX_MESSAGE_SIZE]; System.arraycopy(outputArray, i*MAX_MESSAGE_SIZE, newOutputArray, 0, newOutputArray.length); } mms.sendMMS("youremailorphonenumber","subject part " + (i+1) + " of " + numSegments,"body",newOutputArray,"video/3gpp","avideo_part_" + i + ".3gp"); } } } else if (label.equals(captureKey)) { softkey(stopKey); vidcap.showCamera(); vidcap.startCapture(); } else if (label.equals(stopKey)) { softkey(sendMessageKey); vidcap.stopCapture(); vidcap.hideCamera(); outputArray = vidcap.getCapturedVideo(); } } }

You can find more examples and a discussion on using this library from my course Mobile Media Week 7 notes

MHTTPFilePoster Library

Along with my MVideoCapture and MVideoPlayback libraries, I needed to develop a means to post those files to the web through standard HTTP. For this reason, I put together this library.

You can download the library and source.

Here is an example which also uses the MVideoCapture library:

import processing.core.*;

import com.mobvcasting.mhttpfileposter.*;
import com.mobvcasting.mvideocapture.*;

public class MHTTPFilePosterTest extends PMIDlet
{
MVideoCapture vidcap;
MHTTPFilePoster poster;

String captureKey = "Capture Video";
String stopKey = "Stop Capture";
String uploadKey = "Upload Video";
String uploadStatus = "Check Upload";

String statusMessage = "Not Captured";

byte[] outputArray;

PFont font;

public void setup()
{
vidcap = new MVideoCapture(this);

softkey(captureKey);
font = loadFont("ArialMT-12.mvlw");
textFont(font);
}

public void draw()
{
background(255);
text(statusMessage,10,15);
}

public void softkeyPressed(String label)
{
if (label.equals(captureKey))
{
softkey(stopKey);
vidcap.showCamera();
vidcap.startCapture();
}
else if (label.equals(stopKey))
{
softkey(uploadKey);
vidcap.stopCapture();
vidcap.hideCamera();
outputArray = vidcap.getCapturedVideo();
//outputArray = new byte[]{(byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff};
}
else if (label.equals(uploadKey))
{
poster = new MHTTPFilePoster(this, "http://your.server/upload.php", "avideofile", "bytes", outputArray);
poster.startUpload();
statusMessage = "Uploading Video";
softkey(uploadStatus);
}
else if (label.equals(uploadStatus))
{
statusMessage = poster.getStatus() + " " + poster.getServerResponse();
}
}

public void libraryEvent(Object library, int event, Object data)
{

}
}

Here is the PHP that this posts to (PHP is not required, any language can be used to receive the standard HTTP file upload that comes from the example):

You can find more examples and a discussion on using this library from my course Mobile Media Week 7 notes

MVideoPlayback Library

I recently needed to develop a library for Mobile Processing for video playback that works with my MVideoCapture library. You can download the library and source.

Here is a quick example for using it (this example also uses my MVideoCapture library):

import processing.core.*;
import com.mobvcasting.mvideocapture.*;
import com.mobvcasting.mvideoplayback.*;

public class MVideoCaptureTest extends PMIDlet
{
MVideoPlayback vidplay;
MVideoCapture vidcap;
byte[] videoData;

String captureKey = "Capture";
String stopCaptureKey = "Stop Capture";
String playKey = "Play Video";

public void setup()
{
softkey(captureKey);

vidcap = new MVideoCapture((PMIDlet)this);
vidcap.showCamera();

noLoop();
}

public void draw()
{
}

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

You can find more examples and a discussion on using this library from my course Mobile Media Week 7 notes

MVideoCapture Library

I recently needed to develop a library for Mobile Processing for video capture. You can download the library and source.

Here is a quick example for using it (this example also uses my MVideoPlayback library):

import processing.core.*;
import com.mobvcasting.mvideocapture.*;
import com.mobvcasting.mvideoplayback.*;

public class MVideoCaptureTest extends PMIDlet
{
MVideoPlayback vidplay;
MVideoCapture vidcap;
byte[] videoData;

String captureKey = "Capture";
String stopCaptureKey = "Stop Capture";
String playKey = "Play Video";

public void setup()
{
softkey(captureKey);

vidcap = new MVideoCapture((PMIDlet)this);
vidcap.showCamera();

noLoop();
}

public void draw()
{
}

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

You can find more examples and a discussion on using this library from my course Mobile Media Week 7 notes

MVideoCapture Library – Mobile Processing

UPDATE: An updated post about this library can be found here: http://www.mobvcasting.com/wp/?p=455

I just finished up a library for Mobile Processing called MVideoCapture.

I don’t have time to document it at the moment but you can download, look at the source and try out the following sample code:

import com.mobvcasting.mvideocapture.*;

MVideoCapture vidcap;
byte[] videoData;

String captureKey = "Capture";
String captureStop = "Stop Capture";
String showCamera = "Show Camera";

PFont font;

void setup()
{
softkey(showCamera);
vidcap = new MVideoCapture(this);

font = loadFont("ArialMT-12.mvlw");
textFont(font);
text("Welcome to the test MVideoCapture application",10,15);
noLoop();
}

void draw()
{

}

void softkeyPressed(String label)
{
if (label.equals(captureKey))
{
softkey(captureStop);
vidcap.startCapture();
}
else if (label.equals(captureStop))
{
softkey(captureKey);
vidcap.stopCapture();
}
else if (label.equals(showCamera))
{
softkey(captureKey);
vidcap.showCamera();
}
}

void libraryEvent(Object library, int event, Object data)
{
if (library.getClass().isInstance(vidcap) && event == MVideoCapture.CAPTURE_COMPLETE)
{
videoData = (byte[])data;

saveBytes("savedvideobytes",(byte[])data);

softkey(captureKey);

}
}

New QuickTime Audio/Video Posting Plugin for WordPress

I just finished up a slightly different/easier QuickTime Posting Plugin for WordPress. This one differs a bit from my original QuickTime Posting Plugin in that it has a GUI interface and uses JavaScript to dynamically embed the audio/video instead of directly embedding them. This has been a common request amongst people using the original version as pages with many videos could take a long time to load. This solves that problem..! Yay!

Please give it a shot and let me know if you have any comments or further requests (the comments section below would be a good place to post those).

Download Version 1.2.2a (now with LOOPING!)

Quick Instructions:

1: Download the qtAudioVideoPosting.zip file and extract the files (keeping the folder in place).
2: Upload the folder, including the files inside of it (qtAudioVideoPosting.php and qtobject.js) to your WordPress Plugins folder (wp-content/plugins).
3: Go to the “Plugins” tab in your WordPress console and click “Activate”.
4: Now when you write a post, you should see a new section called “QuickTime Audio/Video Posting”.
5: In the “Audio/Video URL” field, enter the full URL to the QuickTime audio or video file (something like http://myhost.com/avideofile.mov)
6: Enter in a “Width” and “Height” in the appropriate fields.
7: Optionally include a URL for an image to display otherwise the text in the “Text link” field will be displayed.
8: Click publish and check it out on your blog.

Thanks go out to John Schimmel as well as those using the original plugin for all of the help and suggestions.

Oh yeah: Below is an example..