Generic Video Player
De DigiWiki.
Version du 26 août 2013 à 20:24 par Djphil (discuter | contributions)
// Generic Video Player v1.0 integer channel_dialog; list buttons = ["Off"]; integer face = 4; key ToucherID; string message; integer listenID; string category; get_categories() { integer n = 0; while (llGetInventoryName(INVENTORY_NOTECARD,n) != "") { buttons = buttons + llGetInventoryName(INVENTORY_NOTECARD,n); ++n; } } get_videoList(string category) { integer NumLines = osGetNumberOfNotecardLines(category); integer n; for(n=0;n<NumLines;n=n+2) { string NoteCardLine = osGetNotecardLine(category,n); if (NoteCardLine != "") { buttons = buttons + NoteCardLine; } } } play_video(string vid_url) { llSetPrimMediaParams(face, [ PRIM_MEDIA_ALT_IMAGE_ENABLE, 1, PRIM_MEDIA_CURRENT_URL, vid_url, PRIM_MEDIA_AUTO_LOOP, 1, PRIM_MEDIA_AUTO_PLAY, 1, PRIM_MEDIA_AUTO_SCALE, 1, PRIM_MEDIA_PERMS_CONTROL, PRIM_MEDIA_PERM_NONE ]); } string get_video(string title) { integer NumLines = osGetNumberOfNotecardLines(category); integer n; for(n=0;n<NumLines;++n) { string NoteCardLine = osGetNotecardLine(category,n); if (NoteCardLine == title) { NoteCardLine = osGetNotecardLine(category,n+1); return NoteCardLine; } } return ""; } default { state_entry() { llClearPrimMedia(face); channel_dialog = -1 - (integer)("0x" + llGetSubString( (string)llGetKey(), -7, -1) ); state main_menu; } } state main_menu { state_entry() { buttons = ["Off"]; message = "\nChoose a category."; get_categories(); } touch_start(integer num_detected) { ToucherID = llDetectedKey(0); llDialog(ToucherID, message, buttons, channel_dialog); listenID = llListen(channel_dialog, "", ToucherID, ""); } listen(integer channel, string name, key id, string message) { if (message == "Off") { state default; } else { category = message; state sub_menu; } } } state sub_menu { state_entry() { buttons = ["Off"]; message = "\nChoose a video."; get_videoList(category); llDialog(ToucherID, message, buttons, channel_dialog); listenID = llListen(channel_dialog, "", ToucherID, ""); } listen(integer channel, string name, key id, string message) { if (message == "Off") { state default; } else { play_video(get_video(message)); } state main_menu; } }
NoteCard
Video1 http://www.mysite.com/myvideos/video1.mp4 Video2 http://www.mysite.com/myvideos/video2.mp4


