www.webdeveloper.com
Results 1 to 5 of 5

Thread: Noob Help, easy question

  1. #1
    Join Date
    Dec 2013
    Posts
    2

    Noob Help, easy question

    All i want to do is when i click an image i want a sound to play. Ive been looking all over trying everything on the internet and I literally cannot get anything to work i have no idea why. Ive uploaded my sounds and images to my server and ive used the correct directory. Can someone please give me a "for dummies" code and explanation to get this working. (P.S, I have advanced computer skills and ive taken programming in high school i have no idea why im struggling so hard)

    image name path on server under the root directory

    theproducerboard/image/lex.png

    sound name path on server under root

    theproducerboard/lex.wav

  2. #2
    Join Date
    Dec 2013
    Posts
    3
    It depends how you want the audio on your webpage (assuming this is for a website)
    the most up to date way (not compatible with legacy browsers) is to use an HTML5 audio tag, a good tutorial can be found here
    http://www.w3schools.com/tags/tag_audio.asp
    after including that somwhere in your could and rigging with a "display:hidden;" css attribute and not to start playing when its loading you can bind an event listening to the image: <img onclick="javascriptfunction()" />
    in the function you can play the audio using html5 media controls, I'm sorry I'd post a code but it's almost time for my next high school class :P
    I'll leave you with this to help you though

    Code:
    <audio id="demo" src="audio.mp3"></audio>
    <div>
      <button onclick="document.getElementById('demo').play()">Play the Audio</button>
      <button onclick="document.getElementById('demo').pause()">Pause the Audio</button>
      <button onclick="document.getElementById('demo').volume+=0.1">Increase Volume</button>
      <button onclick="document.getElementById('demo').volume-=0.1">Decrease Volume</button>
    </div>
    snagged from https://developer.mozilla.org/en-US/...udio_and_video
    hope that helps!

  3. #3
    Join Date
    Dec 2013
    Posts
    2
    ok thanks this helps but so far i have the player and the sound. I want the player invisible i tried inserting that display hidden but it didnt work. and then i want it to play when an image is clicked

  4. #4
    Join Date
    Dec 2013
    Posts
    3
    Quote Originally Posted by Thesystem3 View Post
    ok thanks this helps but so far i have the player and the sound. I want the player invisible i tried inserting that display hidden but it didnt work. and then i want it to play when an image is clicked
    Try adding a controls="none" attribute to the audio tag

  5. #5
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,216
    Browser has to support HTML5 otherwise you will need a FLASH fall back option.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles