o function to play a file at the beginning of the playlist (interrupts current playing)

o optional option to place separator in front of the playlist



git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@1349 8eb893ce-cfd4-0310-b710-fb5ebe64c474
sayer/1.4-spce2.6
Stefan Sayer 18 years ago
parent 46a4b146ee
commit 2d4211cd1a

@ -49,6 +49,7 @@ DSMAction* DSMCoreModule::getAction(const string& from_str) {
DEF_CMD("playPrompt", SCPlayPromptAction);
DEF_CMD("playPromptLooped", SCPlayPromptLoopedAction);
DEF_CMD("playFile", SCPlayFileAction);
DEF_CMD("playFileFront", SCPlayFileFrontAction);
DEF_CMD("recordFile", SCRecordFileAction);
DEF_CMD("stopRecord", SCStopRecordAction);
DEF_CMD("getRecordLength", SCGetRecordLengthAction);
@ -154,8 +155,10 @@ EXEC_ACTION_START(SCSetPromptsAction) {
sc_sess->setPromptSet(resolveVars(arg, sess, sc_sess, event_params));
} EXEC_ACTION_END;
CONST_ACTION_2P(SCAddSeparatorAction, ',', true);
EXEC_ACTION_START(SCAddSeparatorAction){
sc_sess->addSeparator(resolveVars(arg, sess, sc_sess, event_params));
bool front = resolveVars(par2, sess, sc_sess, event_params) == "true";
sc_sess->addSeparator(resolveVars(par1, sess, sc_sess, event_params), front);
} EXEC_ACTION_END;
EXEC_ACTION_START(SCPlayPromptLoopedAction){
@ -181,6 +184,7 @@ EXEC_ACTION_START(SCPostEventAction){
sc_sess->SET_ERRNO(DSM_ERRNO_OK);
} EXEC_ACTION_END;
CONST_ACTION_2P(SCPlayFileAction, ',', true);
EXEC_ACTION_START(SCPlayFileAction) {
bool loop =
resolveVars(par2, sess, sc_sess, event_params) == "true";
@ -189,6 +193,15 @@ EXEC_ACTION_START(SCPlayFileAction) {
loop);
} EXEC_ACTION_END;
CONST_ACTION_2P(SCPlayFileFrontAction, ',', true);
EXEC_ACTION_START(SCPlayFileFrontAction) {
bool loop =
resolveVars(par2, sess, sc_sess, event_params) == "true";
DBG("par1 = '%s', par2 = %s\n", par1.c_str(), par2.c_str());
sc_sess->playFile(resolveVars(par1, sess, sc_sess, event_params),
loop, true);
} EXEC_ACTION_END;
EXEC_ACTION_START(SCRecordFileAction) {
sc_sess->recordFile(resolveVars(arg, sess, sc_sess, event_params));
} EXEC_ACTION_END;
@ -282,9 +295,6 @@ DSMAction::SEAction SCReturnFSMAction::getSEAction(string& param) {
#undef DEF_SCModActionExec
CONST_ACTION_2P(SCPlayFileAction, ',', true);
CONST_ACTION_2P(SCLogAction, ',', false);
EXEC_ACTION_START(SCLogAction) {

@ -63,7 +63,7 @@ DEF_ACTION_1P(SCEnableDTMFDetection);
DEF_ACTION_1P(SCDisableDTMFDetection);
DEF_ACTION_1P(SCSetPromptsAction);
DEF_ACTION_1P(SCAddSeparatorAction);
DEF_ACTION_2P(SCAddSeparatorAction);
DEF_SCModSEStrArgAction(SCRepostAction);
DEF_SCModSEStrArgAction(SCJumpFSMAction);
@ -80,6 +80,7 @@ DEF_ACTION_2P(SCSetTimerAction);
DEF_ACTION_2P(SCLogAction);
DEF_ACTION_1P(SCLogVarsAction);
DEF_ACTION_2P(SCPlayFileAction);
DEF_ACTION_2P(SCPlayFileFrontAction);
DEF_ACTION_2P(SCPostEventAction);
DEF_ACTION_2P(SCB2BConnectCalleeAction);

@ -238,7 +238,7 @@ void DSMDialog::addToPlaylist(AmPlaylistItem* item) {
playlist.addToPlaylist(item);
}
void DSMDialog::playFile(const string& name, bool loop) {
void DSMDialog::playFile(const string& name, bool loop, bool front) {
AmAudioFile* af = new AmAudioFile();
if(af->open(name,AmAudioFile::Read)) {
ERROR("audio file '%s' could not be opened for reading.\n",
@ -250,7 +250,11 @@ void DSMDialog::playFile(const string& name, bool loop) {
if (loop)
af->loop.set(true);
playlist.addToPlaylist(new AmPlaylistItem(af, NULL));
if (front)
playlist.addToPlayListFront(new AmPlaylistItem(af, NULL));
else
playlist.addToPlaylist(new AmPlaylistItem(af, NULL));
audiofiles.push_back(af);
SET_ERRNO(DSM_ERRNO_OK);
}
@ -337,7 +341,7 @@ void DSMDialog::setPromptSet(const string& name) {
}
void DSMDialog::addSeparator(const string& name) {
void DSMDialog::addSeparator(const string& name, bool front) {
unsigned int id = 0;
if (str2i(name, id)) {
SET_ERRNO(DSM_ERRNO_UNKNOWN_ARG);
@ -345,7 +349,10 @@ void DSMDialog::addSeparator(const string& name) {
}
AmPlaylistSeparator* sep = new AmPlaylistSeparator(this, id);
playlist.addToPlaylist(new AmPlaylistItem(sep, sep));
if (front)
playlist.addToPlayListFront(new AmPlaylistItem(sep, sep));
else
playlist.addToPlaylist(new AmPlaylistItem(sep, sep));
// for garbage collector
audiofiles.push_back(sep);
SET_ERRNO(DSM_ERRNO_OK);

@ -88,14 +88,14 @@ public:
void closePlaylist(bool notify);
void addToPlaylist(AmPlaylistItem* item);
void playFile(const string& name, bool loop);
void playFile(const string& name, bool loop, bool front=false);
void recordFile(const string& name);
unsigned int getRecordLength();
unsigned int getRecordDataSize();
void stopRecord();
void setPromptSet(const string& name);
void addSeparator(const string& name);
void addSeparator(const string& name, bool front = false);
void connectMedia();
void disconnectMedia();
void mute();

@ -64,7 +64,7 @@ class DSMSession {
virtual ~DSMSession();
virtual void playPrompt(const string& name, bool loop = false) = 0;
virtual void playFile(const string& name, bool loop) = 0;
virtual void playFile(const string& name, bool loop, bool front = false) = 0;
virtual void recordFile(const string& name) = 0;
virtual unsigned int getRecordLength() = 0;
virtual unsigned int getRecordDataSize() = 0;
@ -72,7 +72,7 @@ class DSMSession {
virtual void addToPlaylist(AmPlaylistItem* item) = 0;
virtual void closePlaylist(bool notify) = 0;
virtual void setPromptSet(const string& name) = 0;
virtual void addSeparator(const string& name) = 0;
virtual void addSeparator(const string& name, bool front = false) = 0;
virtual void connectMedia() = 0;
virtual void disconnectMedia() = 0;
virtual void mute() = 0;

@ -42,13 +42,14 @@ actions:
prompt not found in current prompt set
playPromptLooped(param)
playFile(filename)
playFileFront(filename)
recordFile(filename)
stopRecord()
getRecordLength([dst_varname]) -- only while recording! default dst var: record_length
getRecordDataSize([dst_varname]) -- only while recording! default dst var: record_data_size
closePlaylist()
addSeparator(id)
fires event when playlist hits it
addSeparator(id [, bool front])
fires event when playlist hits it ; front=[true|false]
connectMedia()
set playlist as input and output of session, and connect to mediaprocessor
disconnectMedia()

Loading…
Cancel
Save