2 Copyright © 2012, The AROS Development Team. All rights reserved.
9 /******************************************************************************
25 Play a sound file, using datatypes.library
29 FILE f -- Filename to play
33 Sound should play to the default audio device
47 ******************************************************************************/
50 #include <aros/debug.h>
52 #include <exec/memory.h>
53 #include <proto/exec.h>
54 #include <proto/dos.h>
55 #include <proto/alib.h>
56 #include <proto/datatypes.h>
58 #include <datatypes/datatypesclass.h>
59 #include <datatypes/soundclass.h>
61 #include <aros/shcommands.h>
63 static inline BOOL
isPlayable(struct Library
*DataTypesBase
, Object
*obj
)
67 for (dtm
= GetDTTriggerMethods(obj
); dtm
&& dtm
->dtm_Label
; dtm
++) {
68 if (dtm
->dtm_Method
== STM_PLAY
)
75 AROS_SH1H(Play
, 44.0, "Play a sound file using DataTypes\n",
76 AROS_SHAH(STRPTR
, ,FILE , ,NULL
, "File to play\n") )
80 struct Library
*DataTypesBase
;
81 STRPTR file
= SHArg(FILE);
83 SetIoErr(RETURN_FAIL
);
86 if ((DataTypesBase
= OpenLibrary("datatypes.library", 0))) {
88 if ((o
= NewDTObject(file
, TAG_END
))) {
89 if (isPlayable(DataTypesBase
, o
)) {
91 msg
.MethodID
= DTM_TRIGGER
;
93 msg
.dtt_Function
= STM_PLAY
;
95 if (0 == DoDTMethodA(o
, NULL
, NULL
, (Msg
)&msg
)) {
98 Printf("Can't play \"%s\"\n", file
);
99 SetIoErr(RETURN_FAIL
);
102 Printf("\"%s\" is not a DataType playable sound file\n", file
);
103 SetIoErr(RETURN_FAIL
);
107 Printf("Can't open %s as a DataType object\n", file
);
109 CloseLibrary(DataTypesBase
);
111 Printf("Can't open datatypes.library\n");
114 /* No file supplied - quiet success */