/* RealVideo Plugin - DMS - dec 99 - by Sylvain HUET */ /* rev April 00 - by Sebastien DENEUX */ /*to do - pause - mute */ var avfile="Dms/3d/Plugins/Real/x.m3d";; typeof class=S;; typeof font=ObjFont;; typeof mater=HMat3d;; typeof myObs = [[Ob [Ob I ObjBitmap RealStream HTx3d S]] r1];; fun myObByName (e, b) = let e -> [o _] in !strcmp ObName o b ;; fun myObByOb (e, b) = let e -> [o _] in o == b ;; fun cbDestroyREAL(o, z) = let z->[_ _ tx movie txt textureName] in ( set myObs = removef_from_list myObs @myObByOb o; _DSbitmap tx; REALdestroy movie; match hd ObAnchor o with (objAnchor [ah am _ _] -> ( M3renameTexture session txt textureName; M3blitTexture16 session txt openBMP textureName; M3chgMaterialTexture session am txt; M3setType session am (M3getType session am)|1; 0 ) ); ) ;; fun applytx(x, t) = match x with (objAnchor [_ m _ _] -> (M3chgMaterialTexture session m t; M3setType session m (M3getType session m)|1)) |(_->nil) ;; fun cbreal(x,z)= let z->[o _ tx _ txt _] in ( REALblit tx x; M3blitTexture16 session txt tx; apply_on_list ObAnchor o @applytx txt ); 0 ;; fun disptxt(o, tx, txt, s) = _DRAWrectangle tx 0 230 256 20 DRAW_SOLID 0 0x00ffffff DRAW_SOLID 0x00ffffff; _DRAWtext tx font 128 245 (TD_BASELINE|TD_CENTER) 0 s; M3blitTexture16 session txt tx; apply_on_list ObAnchor o @applytx txt; 0 ;; fun _CBseek(t, b) = let b -> [bb o player x y pos tx txt] in ( _deltimer t; if x>0 && pos!=nil /*&& !REALisLive player*/ then ( mutate bb <- [_ nil]; _fooS "#### realSEEK"; REALseek player (atoi pos)*1000 ) else nil; /*_fooS strcat "###live = " itoa REALisLive player; _fooS strcatn "###pos = "::(itoa x)::"/"::(itoa y)::nil;*/ if x==y && !REALisLive player then ( _DMSevent this strcat class ".finished" strbuild ("instance"::(ObName o)::nil)::nil nil; disptxt o tx txt "video finished" ) else nil ) ;; fun cbstate(player, b, s) = let b -> [z pos] in let z->[o _ tx _ txt _] in match s with (RealBuffering i -> disptxt o tx txt strcat strcat "buffering " itoa i "%") |(RealContacting s ->disptxt o tx txt "...contacting...") |(RealPosition [x y] ->(_rfltimer _starttimer _channel 10 @_CBseek [b o player x y pos tx txt];0)) /*|(RealOnBegin ->(if pos!=nil && !REALisLive player then (_fooS "### seek";REALseek player (atoi pos)*1000) else nil))*/ |(RealOnPause ->(disptxt o tx txt "video paused")) ;; fun startplay(o, param, z) = let z->[_ f tx movie txt _] in ( if f then ( disptxt o tx txt "video stopped"; _DSbitmap tx; REALdestroy movie; mutate z<-[_ 0 nil nil _ _] ) else nil; let lineextr param -> [url[pos _]] in if (strlen url)<=0 then nil else let _CRbitmap _channel 256 256 -> textureBMP in let REALcreate _channel url -> movie in ( if movie==nil then ( disptxt o textureBMP txt "cannot find RealPlayer"; 0 ) else ( REALcbState REALcbImage movie @cbreal z @cbstate [z pos]; 0 ); mutate z<-[_ 1 textureBMP movie _ _] ); 0 ) ;; fun play(o, from, action, param, rep, z) = startplay o param z ;; fun stop(o, from, action, param, rep, z) = startplay o nil z ;; fun mute(o, from, action, param, rep, z) = let z ->[_ _ _ movie _ _] in if !strcmp param "1" then REALsetMute movie 1 else if !strcmp param "0" then REALsetMute movie 0 else REALsetMute movie !REALgetMute movie; 0 ;; /* fun pause(o,from,action,param,rep,z)= let z ->[_ _ _ movie _ _ _ _] in if !strcmp param "0" then REALplay movie else REALpause movie; 0;; */ fun cbcomm(ui, action, param, z) = let z->[o _ _ _ _ _] in if !strcmp action "url" then startplay o param z else if !strcmp action "registered" then ( UsendSrv this ui "url?" nil; 0 ) else nil; 0 ;; fun cbClickLink (o, obj, mat, button) = _DMSevent this strcat class ".click" strbuild ("instance"::(ObName o)::nil)::nil nil ;; /******************************************************************************* Defines the callbacks of the links in the anchor, and return the list of them <- [[H3d HMat3d S ObjCursor fun [Ob H3d HMat3d I] I fun [Ob H3d HMat3d I] I fun [Ob H3d HMat3d] I] r1] *******************************************************************************/ proto GetLinks = fun [[Anchor r1]] [[H3d HMat3d S ObjCursor fun [Ob H3d HMat3d I] I fun [Ob H3d HMat3d I] I fun [Ob H3d HMat3d] I] r1];; fun GetLinks(l)= if l==nil then nil else match hd l with (objAnchor [ah am name _] -> ([ah am nil HandCursor @cbClickLink nil nil]::(GetLinks tl l))) | (_->(GetLinks tl l)) ;; fun newOb(o) = M3load session avfile nil; let M3copyMaterialTexture session M3getMat session "snapmater" -> txt in let [o 0 nil nil txt nil] -> z in ( set myObs = [o z]::myObs; ObRegisterAction o strcat ObName o ".play" mkfun6 @play z; ObRegisterAction o strcat ObName o ".stop" mkfun6 @stop z; ObRegisterAction o strcat ObName o ".mute" mkfun6 @mute z; /*ObRegisterAction o strcat ObName o ".pause" mkfun6 @pause z;*/ UcbComm this ObUi o mkfun4 @cbcomm z; if strcmpi hd UgetParam ObUi o "registeredClientsOnly" "yes" then UsendSrv this ObUi o "url?" nil else nil; let hd UgetParam ObUi o "alias" -> alias in if alias == nil then /*instanciation statique*/ ( ObSetLinks o GetLinks ObAnchor o; 0 ) else /*instanciation dyn*/ match hd ObAnchor o with (objAnchor [ah am _ _] -> ( ObSetLinks o [ah am alias HandCursor nil nil nil]::nil; let M3textureFromMaterial session am -> oldTxt in let M3textureName session oldTxt -> textureName in mutate z <- [_ _ _ _ _ textureName]; 0 ) ); ObCbDestroy o mkfun2 @cbDestroyREAL z ); 0 ;; fun cbGlobalPlay (from, action, param, ulist, tag) = let strextr param -> l in let hd switchstr l "url" -> url in let hd switchstr l "instance" -> instance in let search_in_list myObs @myObByName instance -> e in if e == nil then nil else let e -> [o z] in startplay o url z; 0 ;; fun IniPlug(file) = set font = _CRfont _channel 14 0 FF_PIXEL "Courier New"; set class=getInfo strextr _getpack _checkpack file "name"; _DMSdefineActions this [strcat class ".play" @cbGlobalPlay]::nil; PLUGsetinfo thisplug PLUGIN_ONLINE_EDITING|PLUGIN_RESERVED|PLUGIN_MATERIAL; PLUGdefineEditor thisplug @dynamicedit; PlugRegister class @newOb nil; 0 ;;