I'm using the code from this question to autoplay an iframe embedded Youtube video and to enable various external controls for the video (eg- mute, unmute) https://stackoverflow.com/a/7988536/262047
Is there any way to fire an event when the user toggles the mute button? Something similar to onStateChange
?
For background, this is what I'm trying to accomplish:
- I have videos on several pages, each of which start playing automatically. There is one video on each page.
- The videos start out muted, and then I have a button which toggles Enable/Disable Sound. When the button is clicked, it unmutes the Youtube video and sets a session cookie telling any other players that the user has enabled sound.
- Once the cookie is set to enable sound, if the user goes to another page with an auto-played video, the sound will be turned on. Likewise, if there is no cookie, or if the cookie is set to mute, then all auto-played videos will start out muted.
I have all of the above working, but with one problem: If someone uses the unmute button inside the video player, then the cookie does not get set, and the video will again be muted on the next page. I want to be able to catch the unmute event from the player, and set the cookie accordingly.