/* WmpVideo Plugin - DMS - dec 99 - by Sylvain HUET */ /* rev April 00 - by Sebastien DENEUX */ /*to do - pause - mute */ var avfile="Dms/3d/Plugins/Wmp/x.m3d";; typeof class=S;; typeof font=ObjFont;; /*typeof pos=I;;*/ typeof mater=HMat3d;; fun destroyWMP(o,z)= let z->[_ f tx movie _] in (_DSbitmap tx; wmpDestroy movie); 0;; fun applytx(x,bmp)= match x with (objAnchor [_ m _ _] -> ( let M3textureFromMaterial session m -> txt in M3blitTexture16 session txt bmp;0;) ) |(_->nil);; fun cbwmp(x,z)= let z->[o _ bmp _ txt] in (wmpBlit bmp x; apply_on_list ObAnchor o @applytx bmp; 0); 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; apply_on_list ObAnchor o @applytx tx; 0;; fun cbstate(player,b,s)= let b -> [z pos] in let z->[o _ tx _ txt] in match s with (WMP_BUFFERING -> (_fooS "buff";disptxt o tx txt "buffering ")) |(WMP_CONTACTING ->(_fooS "contact";disptxt o tx txt "...contacting...")) |(WMP_ONOPENED -> (_fooS "opened";disptxt o tx txt "opened ")) |(WMP_ONBEGIN ->(_fooS "on begin";0)) |(WMP_ONPAUSE ->(_fooS "on pause";disptxt o tx txt "video paused")) |(WMP_ONCLOSED ->(_fooS "on close";disptxt o tx txt "End Of Streaming";0)); 0 ;; fun startplay(o,param,z)= _fooS "startplay1"; let z->[_ f tx movie txt] in ( let lineextr param -> [url[pos _]] in if (strlen url)<=0 then (_fooS "url nul"; nil) else let _CRbitmap _channel 256 256 -> textureBMP in ( let wmpCreate _channel url -> movie in ( if movie==nil then ( disptxt o textureBMP txt "cannot find WmpPlayer"; 0) else ( _fooS "startplay2"; mutate z<-[_ 1 textureBMP movie _]; wmpSetCbState wmpSetCbImage movie @cbwmp z @cbstate [z pos]; 0) ); 0));; fun play(o,from,action,param,rep,z)= let z->[o f _ movie _] in ( if (f==0) then ( if strcmpi hd UgetParam ObUi o "registeredClientsOnly" "yes" then UsendSrv this ObUi o "url?" nil else nil; startplay o param z; 0 ) else ( wmpPlay movie; mutate z<-[_ 1 _ _ _]; 0 ); 0 );; fun stop(o,from,action,param,rep,z)= let z->[_ f tx movie txt] in ( if f then ( disptxt o tx txt "video stopped"; _DSbitmap tx; wmpDestroy movie; mutate z<-[_ 0 nil nil _] ) else nil; 0);; fun pause(o,from,action,param,rep,z)= let z ->[_ f _ movie _] in ( if (f==1) then ( wmpPause movie; mutate z<-[_ 2 _ _ _] ) else if (f==2) then ( wmpPlay movie; mutate z<-[_ 1 _ _ _] ) else nil; 0);; fun mute(o,from,action,param,rep,z)= let z ->[_ f _ movie _] in ( if (f==1) then ( _fooS strcat "get mute :" itoa (wmpGetMute movie); _fooS strcat "set mute :" itoa !(wmpGetMute movie); wmpSetMute movie !(wmpGetMute movie); ) else nil; ); 0;; fun volumeup(o,from,action,param,rep,z)= let z ->[_ f _ movie _] in ( if (f==1) then ( _fooS strcat "get volume :" itoa (wmpGetVolume movie); _fooS strcat "set volume :" itoa ((wmpGetMute movie) + 10); wmpSetVolume movie ((wmpGetVolume movie) + 10);0 ) else nil; ); 0;; fun volumedown(o,from,action,param,rep,z)= let z ->[_ f _ movie _] in ( if (f==1) then ( _fooS strcat "get volume :" itoa (wmpGetVolume movie); _fooS strcat "set volume :" itoa ((wmpGetMute movie) - 10); wmpSetVolume movie ((wmpGetVolume movie) - 10);0 ) else nil; ); 0;; fun isseekable(o,from,action,param,rep,z)= let z->[_ _ _ movie _] in ( if ((wmpIsSeekable movie) ==1) then _DLGMessageBox _channel nil "is seekbale" "is seekable" 0 else if ((wmpIsSeekable movie)==0) then _DLGMessageBox _channel nil "is NOT seekbale" "is NOT seekable" 0 else nil; ); 0;; fun seekfor(o,from,action,param,rep,z)= let z->[_ _ _ movie _] in let wmpGetPosLength movie -> [mpos mlength] in let (mpos+3000) -> newpos in let newpos/1000->newposs in ( if ((wmpSeek movie newpos)==0) then (_fooS "SEEK OK";0) else (_fooS "SEEK KO"; 0); _fooS strcat "new pos : " itoa newposs; 0; );; /* seek of 1000 ms = 1 sec */ fun seekback(o,from,action,param,rep,z)= let z->[_ _ _ movie _] in let wmpGetPosLength movie -> [mpos mlength] in let mpos-2000 -> newpos in let newpos/1000->newposs in ( if ((wmpSeek movie newpos)==0) then (_fooS "SEEK OK"; 0) else (_fooS "SEEK KO"; 0); _fooS strcat "new pos : " itoa newposs; 0; );; /* seek of 100 ms */ fun getposlength(o,from,action,param,rep,z)= let z->[_ _ _ movie _] in let wmpGetPosLength movie -> [mypos mylength] in let mypos/1000 -> poss in let mylength/1000 -> mylengths in let mylengths/60->mylenghtm in let mylengths - 60*mylenghtm -> mylengthss in ( _DLGMessageBox _channel nil "pos in sec :" itoa poss 0; _DLGMessageBox _channel nil "length in min sec :" strcat strcat itoa mylenghtm "::" itoa mylengthss 0; ); 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 newOb(o)= let [o 0 nil nil nil] -> z in (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; ObRegisterAction o strcat ObName o ".up" mkfun6 @volumeup z; ObRegisterAction o strcat ObName o ".down" mkfun6 @volumedown z; ObRegisterAction o strcat ObName o ".isseekable" mkfun6 @isseekable z; ObRegisterAction o strcat ObName o ".seekfor" mkfun6 @seekfor z; ObRegisterAction o strcat ObName o ".seekback" mkfun6 @seekback z; ObRegisterAction o strcat ObName o ".getposlength" mkfun6 @getposlength z; UcbComm this ObUi o mkfun4 @cbcomm z; ObCbDestroy o mkfun2 @destroyWMP z; if strcmpi hd UgetParam ObUi o "registeredClientsOnly" "yes" then UsendSrv this ObUi o "url?" nil else nil); 0;; fun IniPlug(file)= set font = _CRfont _channel 14 0 FF_PIXEL "Courier New"; set class=getInfo strextr _getpack _checkpack file "name"; PlugRegister class @newOb nil; 0;;