javascriptsipfreeswitchseekpbx

Freeswitch doesn't seek back


I'm trying to get rid of controlling audio played via session.streamFile() in Freeswitch. For this I tried the 3rd example of this documentation.

Almost everything here is working, but the DTMF 1 (seek:-500) doesn't seek back. It always starts from the beginning (like seek:0). What could be the reason here? I'm using exactly the example.

Code:

var exit = false;
 
function onInput( session, type, data, arg ) {
  if ( type == "dtmf" ) {
    console_log( "info", "Got digit " + data.digit + "\n" );
    if ( data.digit == "*" ) {
      exit = true;
      return( false );
 
    }
    else if ( data.digit == "0" ) {
      return( "seek:0" );
 
    }
    else if ( data.digit == "1" ) {
      return( "seek:-500" );
 
    }
    else if ( data.digit == "2" ) {
      return( "pause" );
 
    }
    else if ( data.digit == "3" ) {
      return( "seek:+500" );
 
    }
    return( true );
 
  }
 
}
 
if ( session.ready( ) ) {
  session.answer( );
  while ( session.ready( ) && ! exit ) {
    session.streamFile( "<path to WAV>", onInput );
 
  }
  if ( session.ready( ) ) {
    session.hangup( );
 
  }
 
}

Solution

  • Meanwhile I found the reason. It belongs to the samplerate. Freeswitch prefers wav's with a samplerate of 16000. Others are working too, but makeing trouble with seeking etc.