Results 1 to 2 of 2

Thread: iOS click sound on every button tap

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Sencha User
    Join Date
    Sep 2011
    Posts
    46
    Answers
    1
    Vote Rating
    0
      0  

    Default Unanswered: iOS click sound on every button tap

    In our application we use PhoneGap to interact with the device. We've implemented a custom plugin in PhoneGap to play the default tick sound (fastest way to play sounds possible).

    As for the Sencha part, we've overriden the onTap function of Ext.Button to send a signal to PhoneGap to play the tick sound.

    Override buttons to play the default sound

    Code:
    // Adds a sound to button tap
    Ext.define('Enhancements.Button', {
        override: 'Ext.Button',
        onTap: function(e) {
            if (this.getDisabled()) {
                return false;
            }
    
    
            common.playAlertSound();
            this.fireAction('tap', [this, e], 'doTap');
        }
    });
    Objective C for playing the iOS default sound
    Code:
    - (void) playAlertSound:(NSMutableArray *)arguments withDict:(NSMutableDictionary *)options {
        AudioServicesPlayAlertSound(0x450);
    }
    Feel free to use the code above in your own projects.

    Two questions:
    1. Is this the proper way to add the common.playAlertSound invoke to all buttons?
    2. In some situations we have quite a lot of logic going on after you tap on a button. This causes load to the browser and therefore delaying the tick sound. How could I solve this? Perhaps delay the actual action that is called on button tap?

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,336
    Answers
    3885
    Vote Rating
    1296
      0  

    Default

    There really isn't a way you can get the audio to always sync up. The best you can do I guess is delay the button tap logic but that may seem sluggish to the user.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •