ga-wdi-exercises / project1

[project] GA- Project 1
3 stars 75 forks source link

Issue adding audio #223

Closed MaxKaye closed 8 years ago

MaxKaye commented 8 years ago

I am trying to add audio files so user can hear pronunciation of the word. I have tried the following things and haven't gotten to work yet:

inline to html:

<audio id="ni" src="niaudio.mp3" type="mpeg"></audio>
<div>
  <button onclick="document.getElementById('ni').play()">Play the Audio</button>
  <button onclick="document.getElementById('ni').volume+=0.1">Increase Volume</button>
  <button onclick="document.getElementById('ni').volume-=0.1">Decrease Volume</button>
</div>

and also added getElementByID. Any suggestions?

RobertAKARobin commented 8 years ago

Make sure you do your backtics on a new line by themselves.

Try changing the type to audio/mpeg.

http://www.w3schools.com/tags/tag_audio.asp#table2

MaxKaye commented 8 years ago

Thank you, I tried but still doesn't function `

`

RobertAKARobin commented 8 years ago

You changed other aspects of your HTML. Leave it the way it was and change just one thing at a time. Then, once you get it working, change the HTML to be as you want it. Otherwise there are too many things going on to tell what the problem is.

RobertAKARobin commented 8 years ago

Also, make sure you don't put spaces around the = in HTML attributes.

For example, this is fine:

<div class="hello"></div>

This could cause errors:

<div class = "hello"></div>
MaxKaye commented 8 years ago

Noted. here were the first two changes you suggested- is this accurate?

<audio id="ni" src="niaudio.mp3" type="audio/mpeg">
<div>
  <button onclick="document.getElementById('ni').play()">Play the Audio</button>
  <button onclick="document.getElementById('ni').volume+=0.1">Increase Volume</button>
  <button onclick="document.getElementById('ni').volume-=0.1">Decrease Volume</button>
</div>
</audio>
RobertAKARobin commented 8 years ago

Almost. <div> shouldn't go inside <audio>. The only thing allowed inside is <source>.

RobertAKARobin commented 8 years ago

If it's still not working, can you confirm whether the file plays when you load it in iTunes and/or Quicktime?

MaxKaye commented 8 years ago

still not working- and yes the mp3 files work when I play in ITunes

MaxKaye commented 8 years ago

Here is what it looks like rn:

screen shot 2016-02-23 at 1 38 34 pm
RobertAKARobin commented 8 years ago

Hm. Well, the crossed-out speaker means it's not loading the audio at all. I'll come take a look.

MaxKaye commented 8 years ago

Thank you!