title: PJSIP Call, Play Music and Hangup
body: <p>I am new to PJSIP. I want to make an app that makes a call, plays wave file and hangs up after that. When I use the following code, Call is made but I cannot hear any music that is supposed to play (message.wav) on my mobile. Is there anything wrong with the code ? If so, what is the correct way to write the code for the play wav music in python. This is the complete code link <a href="https://github.com/jrocharodrigues/sipamos/blob/master/sipamos.py" rel="nofollow">https://github.com/jrocharodrigues/sipamos/blob/master/sipamos.py</a></p>
  
  <pre><code>def on_state(self):
      global current_call
      global in_call
      print "Call with", self.call.info().remote_uri,
      print "is", self.call.info().state_text,
      print "last code =", self.call.info().last_code, 
      print "(" + self.call.info().last_reason + ")"
  
      if self.call.info().state == pjsua.CallState.DISCONNECTED:
          current_call = None
          print 'Current call is', current_call
  
          in_call = False
      elif self.call.info().state == pjsua.CallState.CONFIRMED:
          #Call is Answred
          print "Call Answred"
          wfile = wave.open("message.wav")
          time = (1.0 * wfile.getnframes ()) / wfile.getframerate ()
          print str(time) + "ms"
          wfile.close()
          call_slot = self.call.info().conf_slot
          self.wav_player_id=pjsua.Lib.instance().create_player('message.wav',loop=False)
          self.wav_slot=pjsua.Lib.instance().player_get_slot(self.wav_player_id)
          pjsua.Lib.instance().conf_connect(self.wav_slot, call_slot)
          sleep(time)
          pjsua.Lib.instance().player_destroy(self.wav_player_id)
          self.call.hangup()
          in_call = False
  
  # Notification when call's media state has changed.
  def on_media_state(self):
      if self.call.info().media_state == pjsua.MediaState.ACTIVE:
          print "Media is now active"
      else:
          print "Media is inactive"
  </code></pre>