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
About this entry
You’re currently reading “MHTTPFilePoster Library,” an entry on mobvcasting
- Published:
- 03.05.08 / 11pm
- Category:
- Mobile Processing Libraries
2 Comments
Jump to comment form | comments rss [?] | trackback uri [?]