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

Justin Houghton
Justin Houghton
4,560 Points

I am trying to add a full screen event listener to an youtube iframe video.

My goal is:

  1. An embedded Youtube video is muted on auto play
  2. When full screen mode is active, video is un-muted

The developer who is working on this with me(I am just the designer), is unsure of how to un-mute the video when full screen mode is active. I've learned a lot of Javascript through TreeHouse so far and am able to understand what needs to happen but don't know exactly how to write it - still a newbie! I've been looking into 'fullScreenChange' and "onFullScreenChange"

Knowing how amazing the treehouse community is, and how it's helped me so much in my journey to understand programming, I thought I would ask here!

1 Answer

Steven Parker
Steven Parker
229,786 Points

I can't speak from experience, but I think you have the right idea. Create a listener for the "fullscreenchange" event and then inside it check document.fullscreenElement to see if you you just switched into the full screen mode, and then call player.unMute() on the YouTube API.

I'm sure the YouTube developer resources will come in handy for testing.