Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Play a sound

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Play a sound

    I have a UX component which consists of a 10-key pad, I would like a sound to be played each time any button on the keypad is pressed, just a short beep sound. Whats the easiest way to go about this? Ideally, I would like to create apps in the future with specific sounds. Can I create and publish a folder that contains wav or mp3 files that can be called upon?

    This component serves as a time clock which tracks all employees punches, each employee punches in their unique numeric identifier to perform a punch operation, I though it would be nice to have some sound feedback when they use the Touch Screen monitor.

    #2
    Re: Play a sound

    Interesting question. You could do this with the <audio> tag. Here's a UX with a ViewBox numberpad (swiped from the Alpha Sample Tablet Form app). The sound file is a wav that I put into a folder named "sounds" in my project. Each button press calls the Javascript function playSound() found in the ViewBox control.

    You can just run this in a Browser LivePreview, but make sure you create the sounds folder under the LivePreview folder and your wav file is in the sounds folder.

    The <audio> tag is in a Static Text control. The wav file is also attached.

    ux_KeyPad_Feedback.a5wcmp

    beep-07.zip

    Comment


      #3
      Re: Play a sound

      Thank you for the quick reply, I didnt use the viewBox control, i just created 10 separate button controls, i wanted to create a javascript function that each one of these buttons would call to play the sound but did not know how to point to the sound file, nor how to write the javascript code to play the sound file. I added a folder in my webroot named sounds. Let me take a look at the component you uploaded and get back to you.

      Comment


        #4
        Re: Play a sound

        It's pretty much the same thing... the javascript function is...

        Code:
        function playSound(){
        
        	var sound = document.getElementById("audioBeep");
        	sound.play();
        	
        }
        The Static Text html is...

        Code:
        <audio id="audioBeep" src="sounds/beep-07.wav" autostart="false" ></audio>
        and you call playSound(); on each button click.

        Comment


          #5
          Re: Play a sound

          Eureka! I got it to work just as I wanted. I created three different static text objects with the following:
          Code:
          <audio id="audioBeep" src="../sounds/beep-07.wav" autostart="false" ></audio>
          Code:
          <audio id="PunchAccepted" src="../sounds/PunchSuccess.mp3" autostart="false" ></audio>
          Code:
          <audio id="ErrorUhOh" src="../sounds/ErrorUhOh.wav" autostart="false" ></audio>
          Then declared three javascript functions:
          Code:
          function playSound(){
          	var sound = document.getElementById("audioBeep");
          	sound.play();	
          }
          
          function punchSuccessSound(){
          	var sound = document.getElementById("PunchAccepted");
          	sound.play();	
          }
          
          function errorUhOh(){
          	var sound = document.getElementById("ErrorUhOh");
          	sound.play();	
          }
          Each button on my form calls the playSound() function, then depending on punch success or failure it will call the punchSuccessSound() or errorUhOh() sound.

          Then in the webRoot, I created a folder named Sounds and placed all of my sounds in there. Thank you David for showing that component.

          Comment


            #6
            Re: Play a sound

            That's great. The only change I might make is streamlining it a bit more...

            One Static Text control...

            Code:
            <audio id="audioBeep" src="sounds/beep-07.wav" autostart="false" ></audio>
            <audio id="PunchAccepted" src="sounds/Beep8.wav" autostart="false" ></audio>
            <audio id="ErrorUhOh" src="sounds/Distorted_Message2.wav" autostart="false" ></audio>
            And one Javascript function with a parameter... and a switch statement.

            Code:
            function playSound(sound){
            
            	switch(sound){
            		case 'audioBeep':
            			var sound = document.getElementById("audioBeep");
            			sound.play();
            			break;
            		case 'errorUhOh':
            			var sound = document.getElementById("ErrorUhOh");
            			sound.play();
            			break;
            		case 'punchAccepted':
            			var sound = document.getElementById("PunchAccepted");
            			sound.play();
            			break;
            	}		
            	
            }
            So... a regular button click would call this...

            Code:
            playSound('audioBeep');

            Comment


              #7
              Re: Play a sound

              Originally posted by Davidk View Post
              That's great. The only change I might make is streamlining it a bit more...

              One Static Text control...

              Code:
              <audio id="audioBeep" src="sounds/beep-07.wav" autostart="false" ></audio>
              <audio id="PunchAccepted" src="sounds/Beep8.wav" autostart="false" ></audio>
              <audio id="ErrorUhOh" src="sounds/Distorted_Message2.wav" autostart="false" ></audio>
              And one Javascript function with a parameter... and a switch statement.

              Code:
              function playSound(sound){
              
              	switch(sound){
              		case 'audioBeep':
              			var sound = document.getElementById("audioBeep");
              			sound.play();
              			break;
              		case 'errorUhOh':
              			var sound = document.getElementById("ErrorUhOh");
              			sound.play();
              			break;
              		case 'punchAccepted':
              			var sound = document.getElementById("PunchAccepted");
              			sound.play();
              			break;
              	}		
              	
              }
              So... a regular button click would call this...

              Code:
              playSound('audioBeep');
              Perfect, thank you David.

              Comment


                #8
                Re: Play a sound

                Thanks again DK for another great tip, especially the switch case statement as an added bonus on efficiency. I appreciate the extra thought!
                NWCOPRO: Nuisance Wildlife Control Software My Application: http://www.nwcopro.com "Without forgetting, we would have no memory at all...now what was I saying?"

                Comment


                  #9
                  Re: Play a sound

                  For a Phone Gap app, I based the sound features off of the Alpha example UX Template, 'PhoneGap - Sound Effects using Native Sounds'.

                  Once you copy the 2 small functions in the main Javascript pane, load the sounds up in the onPhoneGapReady event, you can then easily call any sound loaded (let's say a sound called 'snare') with a simple:

                  Code:
                  playsSound('snare');
                  The sounds are played without delay and are nice, loud and clear. Need to add the Low Latency Audio plugin (cordova-plunin-nativeaudio) because it relies one the native audio API, loading the sounds into memory versus the slower, poorer HTML5 audio. The sounds play so fast that you could build a little drum machine app with it!

                  In my particular situation, a have a bluetooth scanner connected to the device. The user can scan multiple times quite quickly and on the detection of the end of each scan (listening for keycode 13 / Enter), I call a search function to see if the barcode is recognized by our system, if yes, plays fast "success" beep. In not, plays fast negative sounding "buzzer". Without this plugin, the latency would be too high and the users would not understand which action caused which sound.

                  Comment


                    #10
                    Re: Play a sound

                    Interesting and thanks for the input. In my case, I am using noises for simple button clicks and panelsetactive noises which seems to add a nice flair. I just updated my app this morning and so far it works great.
                    NWCOPRO: Nuisance Wildlife Control Software My Application: http://www.nwcopro.com "Without forgetting, we would have no memory at all...now what was I saying?"

                    Comment

                    Working...
                    X