<p dir="ltr">You might be able to set the &quot;ringback&quot; variable on the inbound leg then call the bridge application on the outbound leg dial string.  If you insist to do it manually in lua, you need to set ringback on inbound leg and supply the inbound session object to the constructor for the outbound leg which is over complicated. </p>

<p dir="ltr">Based on what you are doing, I suggest that you consult one of the FS books or some of the wiki to properly understand the way the software works because you have several false assumptions going on.<br><br><br>
<br></p>
<p dir="ltr">On Aug 12, 2014 10:21 PM, &quot;Michael Jerris&quot; &lt;<a href="mailto:mike@jerris.com">mike@jerris.com</a>&gt; wrote:<br>
&gt;<br>
&gt; only if its before you try calling the other party.<br>
&gt;<br>
&gt; On Aug 12, 2014, at 9:44 PM, Leo Lau &lt;<a href="mailto:ningliuxd@gmail.com">ningliuxd@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt;&gt; In the original mail,<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Assume that Bob calls Alice, before Bob here the ringtone of Alice,may be a clip of music. When bob use voip phone, after he dials,<br>
&gt;&gt;&gt; maybe there will be a bit longer time before he receives the ringtone. I want to play some music in this period. <br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; ——— the ringtone means the color ring of Alice. So, is there any way I can play my own music before the color ring?<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; 发件人: Michael Jerris &lt;<a href="mailto:mike@jerris.com">mike@jerris.com</a>&gt;<br>
&gt;&gt; 答复: FreeSWITCH Users Help &lt;<a href="mailto:freeswitch-users@lists.freeswitch.org">freeswitch-users@lists.freeswitch.org</a>&gt;<br>
&gt;&gt; 日期: 2014年8月13日 星期三 5:01<br>
&gt;&gt; 至: FreeSWITCH Users Help &lt;<a href="mailto:freeswitch-users@lists.freeswitch.org">freeswitch-users@lists.freeswitch.org</a>&gt;<br>
&gt;&gt; 主题: Re: [Freeswitch-users] play back and moh<br>
&gt;&gt;<br>
&gt;&gt; I don&#39;t think we have any way to do this, you can use color ring back and you can ignore progress and play it right away, but you can not then have real ring indication take over.  I&#39;m not sure the feature makes any sense as it should never be more than a few seconds, in practice it would be a very strange effect to call someone and immediately get music, then a couple seconds later get ringing.<br>

&gt;&gt;<br>
&gt;&gt; On Aug 12, 2014, at 12:11 PM, 刘宁 &lt;<a href="mailto:ningliuxd@gmail.com">ningliuxd@gmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt;&gt; Hi all<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Sorry to trouble you ,but I really  came across a problem still remaining unsolved when using freeswitch to develop some features.<br>
&gt;&gt;&gt; Assume that Bob calls Alice, before Bob here the ringtone of Alice,may be a clip of music. When bob use voip phone, after he dials,<br>
&gt;&gt;&gt; maybe there will be a bit longer time before he receives the ringtone. I want to play some music in this period. <br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Here is the diaplan config <br>
&gt;&gt;&gt; The path is :/usr/local/freeswitch/conf/dialplan/default/call.xml<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Here is the content:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; &lt;/extension&gt;<br>
&gt;&gt;&gt; &lt;extension name=&quot;testlua&quot;&gt;<br>
&gt;&gt;&gt; &lt;condition field=&quot;destination_number&quot; expression=&quot;^(\d{4}\d+)$&quot;&gt;<br>
&gt;&gt;&gt; &lt;action application=&quot;playback&quot; data=&quot;voicemail/qav_video_incoming.wav&quot;/&gt; &lt;!-- just for test replace it later--&gt;<br>
&gt;&gt;&gt; &lt;action application=&quot;lua&quot; data=&quot;gen_dialplan_xml.lua&quot;/&gt;<br>
&gt;&gt;&gt; &lt;/condition&gt;<br>
&gt;&gt;&gt; &lt;/extension&gt;<br>
&gt;&gt;&gt; &lt;/include&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; The  lua scripts “gen_dialplan_xml.lua&quot;  have to set some arguments  for the session and finally  it calls  freeswitch.bridge(session,newsession)<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Assume that the time when entering the bridge function is t1, and the time when the ringtone of Alice arrives is t2, thus  a time of (t1— t2) exists.<br>
&gt;&gt;&gt; I want to play a music to Bob during this time. But the action of “playback” and “lua” seem to be applied sequentially, that means ,the music is not played during the (t1—t2)time.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I also tried<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; &lt;extension name=&quot;testlua&quot;&gt;<br>
&gt;&gt;&gt; &lt;condition field=&quot;destination_number&quot; expression=&quot;^(\d{4}\d+)$&quot;&gt;<br>
&gt;&gt;&gt; &lt;!--action application=&quot;playback&quot; data=&quot;voicemail/qav_video_incoming.wav&quot;/--&gt; &lt;!-- just for test replace it later--&gt;<br>
&gt;&gt;&gt; &lt;action application=&quot;set&quot; data=&quot;hold_music=${sound_prefix}/voicemail/qav_video_incoming.wav&quot;/&gt; &lt;!-- just for test replace it later--&gt;<br>
&gt;&gt;&gt; &lt;action application=&quot;set&quot; data=&quot;tmp_hold_music=${sound_prefix}/voicemail/qav_video_incoming.wav&quot;/&gt; &lt;!-- just for test replace it later--&gt;<br>
&gt;&gt;&gt; &lt;action application=&quot;lua&quot; data=&quot;gen_dialplan_xml.lua&quot;/&gt;<br>
&gt;&gt;&gt; &lt;/condition&gt;<br>
&gt;&gt;&gt; &lt;/extension&gt;<br>
&gt;&gt;&gt; &lt;/include&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; And the music file does exist, but it still did not work.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; How could I complete this feature?Do I have to complete this in the lua scripts?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Than you in advance,looking forward to your reply.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
&gt; _________________________________________________________________________<br>
&gt; Professional FreeSWITCH Consulting Services:<br>
&gt; <a href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</a><br>
&gt; <a href="http://www.freeswitchsolutions.com">http://www.freeswitchsolutions.com</a><br>
&gt;<br>
&gt; FreeSWITCH-powered IP PBX: The CudaTel Communication Server<br>
&gt; <a href="http://www.cudatel.com">http://www.cudatel.com</a><br>
&gt;<br>
&gt; Official FreeSWITCH Sites<br>
&gt; <a href="http://www.freeswitch.org">http://www.freeswitch.org</a><br>
&gt; <a href="http://wiki.freeswitch.org">http://wiki.freeswitch.org</a><br>
&gt; <a href="http://www.cluecon.com">http://www.cluecon.com</a><br>
&gt;<br>
&gt; FreeSWITCH-users mailing list<br>
&gt; <a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
&gt; <a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
&gt; UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
&gt; <a href="http://www.freeswitch.org">http://www.freeswitch.org</a><br>
&gt;<br>
</p>