This is a migrated thread and some comments may be shown as answers.

Delay playing audio

2 Answers 41 Views
Captcha
This is a migrated thread and some comments may be shown as answers.
Arie Taslim
Top achievements
Rank 1
Arie Taslim asked on 27 May 2010, 06:24 PM

Is it possible to delay playing the audio after users click on the "Get Audio Code" link? I would like to set a pause functionality on the link click. This is useful for accessibility usage.

Thanks.

2 Answers, 1 is accepted

Sort by
0
Pero
Telerik team
answered on 01 Jun 2010, 02:19 PM
Hi Arie,

There is no built-in functionality, that will enable the user to pause the audio playback. However if the <embed/> or <audio/> elements support pausing the audio you could achieve this functionality with some custom JavaScript. I tested the following code, and it works in Firefox, Safari and Opera, but not in IE and Chrome (they do not support HTML5 <audio/> element):

<%@ Page %>
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head runat="server">
    <title></title>
 
    <script type="text/javascript">
        var paused = true;
        function PlayPause(button)
        {
            var captcha = $find("RadCaptcha1");
 
            if (captcha._objectElement)
            {
                if (paused)
                {
                    captcha._objectElement.Play();
                    paused = false;
                    button.value = "Pause";
                }
                else
                {
                    captcha._objectElement.Pause();
                    paused = true;
                    button.value = "Play";
                }
            }
            else if (captcha._audioElement && captcha._audioElement.play)
            {
                captcha._audioElement.play();
 
                if (paused)
                {
                    captcha._audioElement.play();
                    paused = false;
                    button.value = "Pause";
                }
                else
                {
                    captcha._audioElement.pause();
                    paused = true;
                    button.value = "Play";
                }
            }
        }
    </script>
 
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
        <Scripts>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
        </Scripts>
    </asp:ScriptManager>
    <div>
        <telerik:RadCaptcha ID="RadCaptcha1" runat="server" ErrorMessage="Please enter the code shown correctly."
            CaptchaTextBoxLabel="ENTER CODE" CssClass="testClass" ForeColor="Brown">
            <CaptchaImage EnableCaptchaAudio="true" />
        </telerik:RadCaptcha>
        <input type="button" onclick="PlayPause(this); return false;" value="Play" />
        <asp:Button ID="Button1" runat="server" Text="Verify Code" />
    </div>
    </form>
</body>
</html>


Greetings,
Pero
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Arie Taslim
Top achievements
Rank 1
answered on 01 Jun 2010, 07:24 PM
That's too bad that IE and Chrome are not supported for the suggested workaround. 
Thanks a lot for your help Pero!
Tags
Captcha
Asked by
Arie Taslim
Top achievements
Rank 1
Answers by
Pero
Telerik team
Arie Taslim
Top achievements
Rank 1
Share this question
or