title: Play audio file from Freeswitch after call is bridged
body: <p>I'm initiating a call from a WebRTC browser and SIP client and want to play a .wav file using endless_playback after a call is bridged to another party over the PTSN. I tried two things, neither of which works.</p>
  
  <p>a) Using the dialplan</p>
  
  <pre><code>&lt;action application="endless_playback" data="the path of wav file"/&gt; //option 1
  &lt;action application="bridge" data="the call info"/&gt;
  &lt;action application="endless_playback" data="the path of wav file"/&gt; //option 2
  </code></pre>
  
  <p>The problem is that in option 1 the file plays but the call is never bridged and in option 2 the file plays after the receiving call hangs up.</p>
  
  <p>b) Using a LUA script</p>
  
  <pre><code>local TheSound = "the path of the wav file"
  
  if (session:ready() == true) then
  
      session:execute("playback", TheSound)
  
  end
  </code></pre>
  
  <p>This seemed more likely to work but it didn't because I need to execute the playback after the bridge occured.</p>
  
  <p>I think I need to change the LUA script line to the following pseudocode</p>
  
  <pre><code>listen for call connected event and then
  
      session:execute("playback", TheSound)
  </code></pre>
  
  <p>How could I do this?</p>