2 Copyright © 2012-2014, 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.1, "Play a sound file using DataTypes\n",
76 AROS_SHAH(STRPTR
, , FILE, /A
, NULL
, "File to play\n"))
80 LONG result
= RETURN_FAIL
;
81 struct Library
*DataTypesBase
;
82 STRPTR file
= SHArg(FILE);
84 if ((DataTypesBase
= OpenLibrary("datatypes.library", 0))) {
86 if ((o
= NewDTObject(file
, SDTA_SignalTask
, FindTask(NULL
),
87 SDTA_SignalBitNumber
, SIGB_SINGLE
, TAG_END
))) {
88 if (isPlayable(DataTypesBase
, o
)) {
90 msg
.MethodID
= DTM_TRIGGER
;
92 msg
.dtt_Function
= STM_PLAY
;
94 if (0 == DoDTMethodA(o
, NULL
, NULL
, (Msg
)&msg
)) {
95 Wait(SIGF_SINGLE
| SIGBREAKF_CTRL_C
);
98 Printf("Can't play \"%s\"\n", file
);
102 Printf("\"%s\" is not a DataType playable sound file\n", file
);
103 result
= 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");