Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Treehouse Club: JavaScript Car Sounds HTML Comments and JavaScript

Can I use .mp3 files on workspaces?

<!--I'm trying to get the .mp3 files to sound but no matter what I do or change I still get no sound.-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=0.5, maximum-scale=0.5, minimal-ui">
    <title>Car Sounds</title>

    <!--Style Sheet link-->
    <link href="css/style.css" rel="stylesheet">
  </head>

<body>
  <!--Car image -->
  <img src="images/135i_vs_235i.png" class="car" alt="BMW WARS">


  <!--Buttons-->
  <a href="javascript:lion();"><img src="images/135i_logo.jpg" alt="135i"></a>
  <a href="javascript:kitten();"><img src="images/235i_logo.jpg" alt="235i"></a>



  <!--Audio Files-->
  <audio id="lion" src="sounds/lion.mp3" preload="135i"></audio>
  <audio id="kitten" src="sounds/kitten.mp3" preload="235i"></audio>



  <!--Javascript-->
  <script type="text/javascript">
    function lion() {
      document.getElementById('lion').play();
    }
    function kitten() {
      document.getElementById('kitten').play();

  </script>  
</body>
</html>

1 Answer

sarahd0183
PLUS
sarahd0183
Courses Plus Student 3,167 Points

Thank you for providing your code to address the issue! Yes, you can use .mp3 audio files in Workspaces. Under Your Audio Files tag, try changing the "135i" to "auto" and the same for the "235i". For example:

          <audio id="kitten" src="sounds/kitten.mp3" preload="auto"></audio>
          ```
 Hope this helps. :)