creating tasks at runtime
Hi,
I'm trying to extract a portion of an image from mediabin, using the c# API.
I understand (I think) that I need to create a task, and load it with the correct primitives, parameters, and parameter elements.
But I'm really unclear on the specifics, and can't find anything in the documentation.
Can I get a bit of help?
Say, starting with an MBAsset object, given that we've got a MediaBinServer object, and I want a tile of the image, given x1, y1, x2, y2 coordinates, what would the code look like? Really I don't think my problem is specific to cropping; I'm having trouble just getting my hands on a task I can work with.
Here's what I've got so far:
public static byte[] getImageTile(spmiws00.MediaBinServer service, MBAsset asset, int tileX, int tileY, int tileWidth, int tileHeight)
{
string taskname = "theTaskName";
// array of primitives; these go to the task
MBPrimitive[] prims = new MBPrimitive[2];
// creating parameter element, setting values
MBParameterElement paraElem = new MBParameterElement();
paraElem.mName = "Output Width";
paraElem.mValue = tileWidth;
// creating parameter
MBParameter param = new MBParameter();
// initialize parameter element array:
param.mElements = new MBParameterElement[1];
// adding parameter element to parameter
param.mElements[0] = paraElem;
// creating primitive
MBPrimitive prim = new MBPrimitive();
// initializing parameters array in primitive
prim.mParameters = new MBParameter[1];
// adding parameter to primitive
prim.mParameters[0] = param;
// adding primitive to array of primitives:
prims[0] = prim;
service.CreateTaskCompleted += new CreateTaskCompletedEventHandler(onHandler);
service.CreateTask(taskname, "some description", prims);
MBTask task = service.GetTaskByName(taskname); // this never works, the task is always null
String taskid ="";
if (task != null)
{
taskid = task.mID;
}
// haven't gotten beyond this point; the task is always null here
// some magic goes here
}
public static void onHandler(object sender, CreateTaskCompletedEventArgs evt)
{
throw new Exception("got into handler!"); // this part never happens
}
fill in the blanks!
Is there a better way to do this? Do I need to create some sort of "task" in the mediabin client interface, then recall it here? How does this work?
Thanks for all your help!