/* Media Sequence Client v1.0 - DMS - jul '98 - by Marc BARILLEY */ defcom cStarted = started;; typedef MediaType = MovieMedia Multi |SoundMedia Multi |BitmapMedia ObjBitmap |TextMedia ObjText |UnknownMedia ;; struct Instance = [ winInstance : ObjWin, mediaInstance : MediaType ] mkInstance;; struct ObjMedia = [ aliasObjMedia : S, fileObjMedia : S, mbeginObjMedia : F, /* begining of media in file */ mendObjMedia : F, /* end of media in file */ sbeginObjMedia : F, /* begining of media in sequence */ sendObjMedia : F, /* end of media in sequence */ loopObjMedia : I, instanceObjMedia : Instance ] mkObjMedia;; typeof mediaList = [ObjMedia r1];; typeof startList = [ObjMedia r1];; typeof stopList = [ObjMedia r1];; typeof timer = Timer;; var STOP = 0;; var RUN = 1;; var PAUSE = 2;; var begintime = 0;; var cents = 0;; var oldtime = 0;; var sequenceInProgress = 0;; fun mediaByAlias (omedia, alias)= !strcmp omedia.aliasObjMedia alias;; fun getMinStart (l)= if l==nil then nil else if (tl l)==nil then hd l else let hd l -> omedia in let getMinStart tl l -> m in if m.sbeginObjMedia <. omedia.sbeginObjMedia then m else omedia;; fun getMinEnd (l)= if l==nil then nil else if (tl l)==nil then hd l else let hd l -> omedia in let getMinEnd tl l -> m in if m.sendObjMedia <. omedia.sendObjMedia then m else omedia;; fun clean (l)= if l==nil then 0 else let hd l -> omedia in { match omedia.instanceObjMedia.mediaInstance with (MovieMedia m -> _DSmulti m) |(SoundMedia m -> _DSmulti m) |(BitmapMedia m -> _DSbitmap m) |(TextMedia m -> _DStext m) |(_ -> nil); _DSwindow omedia.instanceObjMedia.winInstance; _DMSreleaseZone this omedia.aliasObjMedia; set omedia.instanceObjMedia = nil; clean tl l };; fun rflPaintBitmapWin (w, bitmap)= _BLTbitmap w bitmap 0 0;; fun rflMultiMedia (m, omedia, mode)= if mode == MEDIA_MODE_STOP then if omedia.loopObjMedia then { _PLAYmultiFromTo m ftoi ((itof 1000) *. omedia.mbeginObjMedia) ftoi ((itof 1000) *. omedia.mendObjMedia); 0 } else { _DSmulti m; _DSwindow omedia.instanceObjMedia.winInstance; _DMSreleaseZone this omedia.aliasObjMedia; set omedia.instanceObjMedia = nil; set stopList=remove_from_list stopList omedia; _DMSevent this strcat "stopped " omedia.aliasObjMedia nil nil; } else if mode==MEDIA_MODE_PAUSE then { _SETmultiHome m; 0 } else nil;; fun conflict (zone, omedia)= match omedia.instanceObjMedia.mediaInstance with (MovieMedia m -> {_DSmulti m;0}) |(SoundMedia m -> {_DSmulti m;0}) |(BitmapMedia m -> _DSbitmap m) |(TextMedia m -> _DStext m) |(_ -> nil); _DSwindow omedia.instanceObjMedia.winInstance; _DMSreleaseZone this omedia.aliasObjMedia; set omedia.instanceObjMedia = nil; 0;; fun resize (coord, zone, omedia)= let coord -> [wn x y w h] in { _SIZEwindow omedia.instanceObjMedia.winInstance 0 0 w h; match omedia.instanceObjMedia.mediaInstance with (MovieMedia media -> { _SETmultiXYdest media 0 0 w h; _SETmultiXYwin media 0 0 w h; 0 }) |(SoundMedia m -> nil) |(BitmapMedia media -> let _GETbitmapSize media -> [wmsource hmsource] in let _CRbitmap _channel w h -> newMedia in { _SCPbitmap newMedia 0 0 w h media 0 0 wmsource hmsource nil; _DSbitmap media; set omedia.instanceObjMedia.mediaInstance = BitmapMedia newMedia; 0 }) |(TextMedia m -> { _SIZEtext m 0 0 w h; 0 }) |(_ -> nil); }; 0;; fun destroy (zone, omedia)= match omedia.instanceObjMedia.mediaInstance with (MovieMedia m -> {_DSmulti m;0}) |(SoundMedia m -> {_DSmulti m;0}) |(BitmapMedia m -> _DSbitmap m) |(TextMedia m -> _DStext m) |(_ -> nil); _DSwindow omedia.instanceObjMedia.winInstance; _DMSreleaseZone this omedia.aliasObjMedia; set omedia.instanceObjMedia = nil; 0;; fun rflTimer (t, blurp) = if stopList==nil then { _deltimer t; clean mediaList; set oldtime = 0; set cents = 0; set sequenceInProgress = 0; _DMSevent this "stopped" nil nil; } else { let _tickcount - begintime -> newtime in let getMinStart startList -> omedia in if omedia.sbeginObjMedia <. ((itof newtime) /. (itof 1000)) then { let _checkpack omedia.fileObjMedia -> pack in let _DMSgetZone this omedia.aliasObjMedia (mkfun2 @conflict omedia) (mkfun3 @resize omedia) (mkfun2 @destroy omedia) -> [zwin x y w h] in { let if zwin == nil then DMSwin else zwin -> zwin in let _CRwindow _channel zwin x y w h WN_CHILD|WN_HIDDEN omedia.aliasObjMedia -> mediaWin in /*modif seb*/ let let _CRmulti _channel mediaWin 0 0 w h pack nil -> m in if m==nil then let _LDbitmap _channel pack -> p in if p==nil then let _LDjpeg _channel pack -> p in if p==nil then let _GETalphaBitmaps _LDalphaBitmap _channel pack -> [p _] in if p==nil then TextMedia _CRtext _channel mediaWin 0 0 w h ET_DOWN _getpack pack else BitmapMedia p else BitmapMedia p else BitmapMedia p else { _SETmultiUseTime m; let (itof (_GETmultiStart m))/.(itof 1000) -> start in let (itof (_GETmultiEnd m))/.(itof 1000) -> end in let _GETmultiXYsource m -> [xmsource ymsource wmsource hmsource] in if (xmsource==0) && (ymsource==0) && (wmsource==0) && (hmsource==0) then SoundMedia m else MovieMedia m } -> type in let mkInstance [mediaWin type] -> newInstance in { match type with (MovieMedia media -> { _SETmultiXYdest media 0 0 w h; _SETmultiXYwin media 0 0 w h; _PLAYmultiFromTo media ftoi ((itof 1000) *. omedia.mbeginObjMedia) ftoi ((itof 1000) *. omedia.mendObjMedia); _SETmultiReflexMode media @rflMultiMedia omedia; _SHOWwindow mediaWin WINDOW_UNHIDDEN; 0 }) |(SoundMedia media -> { _PLAYmultiFromTo media ftoi ((itof 1000) *. omedia.mbeginObjMedia) ftoi ((itof 1000) *. omedia.mendObjMedia); _SETmultiReflexMode media @rflMultiMedia omedia; 0; }) |(BitmapMedia media -> let _GETbitmapSize media -> [wmsource hmsource] in let _CRbitmap _channel w h -> newMedia in { _SCPbitmap newMedia 0 0 w h media 0 0 wmsource hmsource nil; _DSbitmap media; set omedia.instanceObjMedia.mediaInstance = BitmapMedia newMedia; _CBwinPaint mediaWin @rflPaintBitmapWin newMedia; _SHOWwindow mediaWin WINDOW_UNHIDDEN; 0 }) |(TextMedia media -> { _SHOWwindow mediaWin WINDOW_UNHIDDEN; 0 }) |(_ -> nil); set omedia.instanceObjMedia = newInstance }; }; _DMSevent this strcat "playing " omedia.aliasObjMedia nil nil; set startList=remove_from_list startList omedia; 0 } else 0; let _tickcount - begintime -> newtime in let getMinEnd stopList -> omedia in if omedia.sendObjMedia <. ((itof newtime) /. (itof 1000)) then { match omedia.instanceObjMedia.mediaInstance with (BitmapMedia m -> { _DSbitmap m; _DSwindow omedia.instanceObjMedia.winInstance; _DMSreleaseZone this omedia.aliasObjMedia; set omedia.instanceObjMedia = nil; _DMSevent this strcat "stopped " omedia.aliasObjMedia nil nil; }) |(TextMedia m -> { _DStext m; _DSwindow omedia.instanceObjMedia.winInstance; _DMSreleaseZone this omedia.aliasObjMedia; set omedia.instanceObjMedia = nil; _DMSevent this strcat "stopped " omedia.aliasObjMedia nil nil; }) |(_ -> 0); set stopList=remove_from_list stopList omedia; 0 } else 0 } ;; fun __playSequence ()= if sequenceInProgress then nil else { _DMSevent this "playing" nil nil; set startList = listcat mediaList nil; set stopList = listcat mediaList nil; set cents = -50; set oldtime = 0; set begintime = _tickcount; set sequenceInProgress = 1; set timer = _rfltimer _starttimer _channel 100 @rflTimer 0; };; fun __stopSequence ()= clean mediaList; set sequenceInProgress = 0; _DMSevent this "stopped" nil nil;; fun __stopMedia (alias)= if sequenceInProgress then nil else let search_in_list mediaList @mediaByAlias alias -> omedia in if omedia==nil then nil else { match omedia.instanceObjMedia.mediaInstance with (MovieMedia m -> _DSmulti m) |(SoundMedia m -> _DSmulti m) |(BitmapMedia m -> _DSbitmap m) |(TextMedia m -> _DStext m) |(_ -> nil); _DSwindow omedia.instanceObjMedia.winInstance; _DMSreleaseZone this omedia.aliasObjMedia; set omedia.instanceObjMedia = nil; _DMSevent this strcat "stopped " alias nil nil };; fun __playMedia (alias)= if sequenceInProgress then nil else ( __stopMedia alias; let search_in_list mediaList @mediaByAlias alias -> omedia in if omedia==nil then nil else { let _checkpack omedia.fileObjMedia -> pack in let _DMSgetZone this omedia.aliasObjMedia (mkfun2 @conflict omedia) (mkfun3 @resize omedia) (mkfun2 @destroy omedia) -> [zwin x y w h] in { let if zwin == nil then DMSwin else zwin -> zwin in let _CRwindow _channel zwin x y w h WN_CHILD|WN_HIDDEN omedia.aliasObjMedia -> mediaWin in /*modif seb*/ let let _CRmulti _channel mediaWin 0 0 w h pack nil -> m in if m==nil then let _LDbitmap _channel pack -> p in if p==nil then let _LDjpeg _channel pack -> p in if p==nil then let _GETalphaBitmaps _LDalphaBitmap _channel pack -> [p _] in if p==nil then TextMedia _CRtext _channel mediaWin 0 0 w h ET_DOWN _getpack pack else BitmapMedia p else BitmapMedia p else BitmapMedia p else { _SETmultiUseTime m; let (itof (_GETmultiStart m))/.(itof 1000) -> start in let (itof (_GETmultiEnd m))/.(itof 1000) -> end in let _GETmultiXYsource m -> [xmsource ymsource wmsource hmsource] in if (xmsource==0) && (ymsource==0) && (wmsource==0) && (hmsource==0) then SoundMedia m else MovieMedia m } -> type in let mkInstance [mediaWin type] -> newInstance in { match type with (MovieMedia media -> { _SETmultiXYdest media 0 0 w h; _SETmultiXYwin media 0 0 w h; _PLAYmultiFromTo media ftoi ((itof 1000) *. omedia.mbeginObjMedia) ftoi ((itof 1000) *. omedia.mendObjMedia); _SETmultiReflexMode media @rflMultiMedia omedia; _SHOWwindow mediaWin WINDOW_UNHIDDEN; 0 }) |(SoundMedia media -> { _PLAYmultiFromTo media ftoi ((itof 1000) *. omedia.mbeginObjMedia) ftoi ((itof 1000) *. omedia.mendObjMedia); _SETmultiReflexMode media @rflMultiMedia omedia; 0; }) |(BitmapMedia media -> let _GETbitmapSize media -> [wmsource hmsource] in let _CRbitmap _channel w h -> newMedia in { _SCPbitmap newMedia 0 0 w h media 0 0 wmsource hmsource nil; _DSbitmap media; set omedia.instanceObjMedia.mediaInstance = BitmapMedia newMedia; _CBwinPaint mediaWin @rflPaintBitmapWin newMedia; _SHOWwindow mediaWin WINDOW_UNHIDDEN; 0 }) |(TextMedia media -> { _SHOWwindow mediaWin WINDOW_UNHIDDEN; 0 }) |(_ -> nil); set omedia.instanceObjMedia = newInstance }; _DMSevent this strcat "playing " alias nil nil } } ) ;; fun endload (file, omedia)= if file==nil then { set mediaList = remove_from_list mediaList omedia; nil } else set omedia.fileObjMedia = file; 0;; fun __mediaIs (errorcode, alias, file, mbegin, mend, sbegin, send, loop)= if errorcode==0 then { clean mediaList; set mediaList=nil; errorcode } else if errorcode==1 then let mkObjMedia [alias nil atof mbegin atof mend atof sbegin atof send atoi loop nil] -> omedia in { _RSCdownloadP this file file (mkfun2 @endload omedia) 1 0; set mediaList = omedia::mediaList; errorcode } else { _DMSevent this "in" nil nil; errorcode };; fun IniDMI (param)= _DMSsend this cStarted[]; 0;;