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