<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jun 16, 2014 at 11:21 AM, Maxim Litnitskiy <span dir="ltr"><<a href="mailto:litnimaxster@gmail.com" target="_blank">litnimaxster@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra">Matt!</div><div class="gmail_extra">Thank you so much for such a deep explanation.</div>
<div class="gmail_extra">But You still did not reveal your plans about accessing Asterisk builtin apps :-)</div>

<div class="gmail_extra">Once more example - a pause before playback.</div><div class="gmail_extra">In ARI you cannot use python time.sleep(1) as it blocks the whole async event loop.</div><div class="gmail_extra">How to tell a channel to wait?</div>


<div class="gmail_extra"><br clear="all"></div></div></blockquote></div><br></div><div class="gmail_extra">Since you mention an async event loop, I'm going to assume you are using twisted - although ari-py does not use that. If, however, you are using twisted, I would just do something like the following:<br>
<br></div><div class="gmail_extra">def play_something(chan):<br></div><div class="gmail_extra">    chan.play(media='sound:tt-monkeys')<br></div><div class="gmail_extra"><br></div><div class="gmail_extra"># Assume chan is a reference to my channel<br>
</div><div class="gmail_extra">reactor.callLater(1, play_something, chan)<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">If you aren't using twisted, you could use the threading.Timer module [1] to schedule a callback in a similar manner.<br>
</div><div class="gmail_extra"><br></div><div class="gmail_extra">Or you can make Asterisk perform the pause:<br><br></div><div class="gmail_extra">chan.play(media='sound:silence/1')<br><br></div><div class="gmail_extra">
Since ARI queues up sounds, that will automatically either (a) play 1 second of silence immediately, or (b) play 1 second of silence whenever the current media operation finishes.<br></div><div class="gmail_extra"><br>[1] <a href="https://docs.python.org/2/library/threading.html#timer-objects">https://docs.python.org/2/library/threading.html#timer-objects</a><br>
</div><div class="gmail_extra"><br>-- <br><div dir="ltr"><div>Matthew Jordan<br></div><div>Digium, Inc. | Engineering Manager</div><div>445 Jan Davis Drive NW - Huntsville, AL 35806 - USA</div><div>Check us out at: <a href="http://digium.com" target="_blank">http://digium.com</a> & <a href="http://asterisk.org" target="_blank">http://asterisk.org</a></div>
</div>
</div></div>