private LSL_List GetPrimMediaParams(ISceneChildEntity obj, int face, LSL_List rules)
{
IMoapModule module = World.RequestModuleInterface<IMoapModule>();
if (null == module)
throw new Exception("Media on a prim functions not available");
MediaEntry me = module.GetMediaEntry(obj, face);
// As per http://wiki.secondlife.com/wiki/LlGetPrimMediaParams
if (null == me)
return new LSL_List();
LSL_List res = new LSL_List();
for (int i = 0; i < rules.Length; i++)
{
int code = (int)rules.GetLSLIntegerItem(i);
if (code == ScriptBaseClass.PRIM_MEDIA_ALT_IMAGE_ENABLE)
{
// Not implemented
res.Add(new LSL_Integer(0));
}
else if (code == ScriptBaseClass.PRIM_MEDIA_CONTROLS)
{
res.Add(me.Controls == MediaControls.Standard
? new LSL_Integer(ScriptBaseClass.PRIM_MEDIA_CONTROLS_STANDARD)
: new LSL_Integer(ScriptBaseClass.PRIM_MEDIA_CONTROLS_MINI));
}
else if (code == ScriptBaseClass.PRIM_MEDIA_CURRENT_URL)
{
res.Add(new LSL_String(me.CurrentURL));
}
else if (code == ScriptBaseClass.PRIM_MEDIA_HOME_URL)
{
res.Add(new LSL_String(me.HomeURL));
}
else if (code == ScriptBaseClass.PRIM_MEDIA_AUTO_LOOP)
{
res.Add(me.AutoLoop ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
}
else if (code == ScriptBaseClass.PRIM_MEDIA_AUTO_PLAY)
{
res.Add(me.AutoPlay ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
}
else if (code == ScriptBaseClass.PRIM_MEDIA_AUTO_SCALE)
{
res.Add(me.AutoScale ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
}
else if (code == ScriptBaseClass.PRIM_MEDIA_AUTO_ZOOM)
{
res.Add(me.AutoZoom ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
}
else if (code == ScriptBaseClass.PRIM_MEDIA_FIRST_CLICK_INTERACT)
{
res.Add(me.InteractOnFirstClick ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
}
else if (code == ScriptBaseClass.PRIM_MEDIA_WIDTH_PIXELS)
{
res.Add(new LSL_Integer(me.Width));
}
else if (code == ScriptBaseClass.PRIM_MEDIA_HEIGHT_PIXELS)
{
res.Add(new LSL_Integer(me.Height));
}
else if (code == ScriptBaseClass.PRIM_MEDIA_WHITELIST_ENABLE)
{
res.Add(me.EnableWhiteList ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
}
else if (code == ScriptBaseClass.PRIM_MEDIA_WHITELIST)
{
string[] urls = (string[])me.WhiteList.Clone();
for (int j = 0; j < urls.Length; j++)
urls[j] = Uri.EscapeDataString(urls[j]);
res.Add(new LSL_String(string.Join(", ", urls)));
}
else if (code == ScriptBaseClass.PRIM_MEDIA_PERMS_INTERACT)
{
res.Add(new LSL_Integer((int)me.InteractPermissions));
}
else if (code == ScriptBaseClass.PRIM_MEDIA_PERMS_CONTROL)
{
res.Add(new LSL_Integer((int)me.ControlPermissions));
}
}
return res;
}