Jvn Writer
2008年07月13日 08:15
string strURL;
key Query;
integer isHighFormat = FALSE;
default
{
on_rez(integer n){llResetScript();}
link_message(integer sender_num, integer num, string str, key id)
{
if((string)id == "set_quality")
isHighFormat = num;
if((string)id != "set_url")
return;
strURL = str;
state set;
}
}
state set
{
state_entry()
{
if(llSubStringIndex(strURL, "youtube")==-1)
state default;
if(isHighFormat==1)
strURL = "http://pipes.yahoo.com/pipes/pipe.run?_id=5a068edc3e7197ed30c21a4f90363fe2&_render=csv&format=18&url=" + strURL;
else if(isHighFormat==0)
strURL = "http://pipes.yahoo.com/pipes/pipe.run?_id=5a068edc3e7197ed30c21a4f90363fe2&_render=csv&format=17&url=" + strURL;
else if(isHighFormat==2)
strURL = "http://pipes.yahoo.com/pipes/pipe.run?_id=45d0f4c39c45d25fabdfb58fe550419b&_render=csv&url=" + strURL;
Query = llHTTPRequest(strURL, [HTTP_METHOD,"GET"], "");
}
http_response(key request_id, integer status, list metadata, string body)
{
if(request_id != Query)
return;
if(body=="")
{
llSay(0,"Sorry, request url is not converted.");
return;
}
list Ret = llParseString2List(body, ["\n"], []);
strURL = llList2String(Ret,1);
integer idx = llSubStringIndex(strURL, "&");
while( idx > -1)
{
strURL = llDeleteSubString(strURL, idx+1, idx+4);
idx = llSubStringIndex(strURL, "&");
}
state default;
}
state_exit()
{
llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_STOP,
PARCEL_MEDIA_COMMAND_URL,strURL,
PARCEL_MEDIA_COMMAND_TYPE,"video/*"]);
llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_PLAY]);
llSay(0,"Media setting is changed!");
}
}
llMessageLinked(LINK_THIS, 0, "http://jp.youtube.com/watch?v=7hASyYBsExE", "set_url");
llMessageLinked(LINK_THIS, 0, "", "set_quality"); // 中画質モード 軽め
llMessageLinked(LINK_THIS, 1, "", "set_quality"); // 高画質モード 重い mpeg4
llMessageLinked(LINK_THIS, 2, "", "set_quality"); // 携帯用フォーマット 軽い 荒い