Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

HTML HTML Video and Audio (Retired) Media Basics The Audio Element

Dongyun Cho
Dongyun Cho
2,256 Points

Why this code doesnt work?

       <h2>Video</h2>
      <video src="http://treehouse-code-samples.s3.amazonaws.com/html-video-and-audio/bridge.mp4" type="video/mp4" controls />

      <h2>Audio</h2>
      <audio src="http://treehouse-code-samples.s3.amazonaws.com/html-video-and-audio/bridge-audio.mp3" type="audio/mp3" controls />

Am I missing something?

1 Answer

Owa Aquino
Owa Aquino
19,277 Points

Hi Dongyun,

Maybe this can help.

<video> and <audio> should have closing tag name and sources should be in different element of <source>

<h2>Video</h2>
<video width="320" height="240" controls>
  <source src="http://treehouse-code-samples.s3.amazonaws.com/html-video-and-audio/bridge.mp4" type="video/mp4">
</video> 

<h2>Audio</h2>
<audio controls>
  <source src="http://treehouse-code-samples.s3.amazonaws.com/html-video-and-audio/bridge-audio.mp3" type="audio/mp3">
</audio>

Hope this help! Cheers!

Owa

Dongyun Cho
Dongyun Cho
2,256 Points

I know this but I've learn that I can use the short version of what you've written. In my code, video tag works well, but audio one doesnt work!

Owa Aquino
Owa Aquino
19,277 Points

Hmmm maybe there's something wrong with the sample audio maybe it has been remove/moved or even renamed. Have you try adding your own audio? Try your local audio as a sample.

Cheers!