How to Mute Embedded YouTube Videos

akim6794
akim6794 Community Member Posts: 7 ☆ Roadie ☆

I embedded YouTube Videos in Lectora.

I added a 'Mute' button. All sounds should be muted when the button is clicked. It works for imported audios and videos, but not for embedded YouTube videos. I've embedded a YouTube video using the iframe code and added it to an 'external HTML object'.

Do you know how to mute or adjust the volume of an embedded YouTube video?

Thank you!

Aenglan

Comments

  • wheels
    wheels Florida USACommunity Member, Administrator, Moderator, Rockstar Manager Posts: 665 eLearning ROCKSTAR Admin Team

    Hi @akim6794

    In Lectora Online it mutes fine.

    And in Lectora Desktop I see it doesn't, we will write a bug for that.

    In the meantime you should be able to add a Run JavaScript action to mute or unmute.

    The Javascript code would be as follows (if you just have one video on the page):

    to mute:

    getYouTubePlayers()[0].actionMute()

    to unmute:

    getYouTubePlayers()[0].actionUnmute()

  • wheels
    wheels Florida USACommunity Member, Administrator, Moderator, Rockstar Manager Posts: 665 eLearning ROCKSTAR Admin Team

    Hi again @akim6794,

    I misread your post, sorry. Is there a reason you cannot use the Insert -> Youtube option in Lectora Online?

    If you want/need to use the embedded iframe, there is a full API that includes a call for mute:


  • akim6794
    akim6794 Community Member Posts: 7 ☆ Roadie ☆

    Thank you for your response.

    I should make a mute button that can mute all audio and video sound.

    When I added one of the codes you sent me.

    Trigger: Mouse click

    Action : Run Javascript

    Target : getYouTubePlayers()[0].actionMute()

    However, there is an error.

    [OnMClkRunJS] TypeError: Cannot read properties of undefined (reading 'actionMute')

    Should I add properties of actionMute() and actionUnmute()

    Please check and let me know.


    Thank you!


    Aenglan

  • wheels
    wheels Florida USACommunity Member, Administrator, Moderator, Rockstar Manager Posts: 665 eLearning ROCKSTAR Admin Team

    Hi,

    Since you posted here I guess you are using Lectora Online. In Lectora Online why can't you use the Insert Youtube option to add your Youtube video? If you do that then mute works.

    If you are using desktop and are getting that error please upload a sample page with the code you added and I'll take a look.

    Joe

  • akim6794
    akim6794 Community Member Posts: 7 ☆ Roadie ☆

    Hi, Joe

    I am using desktop version.

    I uploaded zip folder.

    I added getYouTubePlayers()[0].actionMute() action to sound button.

    In page 1, there is External HTML Object which is embedded YouTube video.

    Please check and let me know if you have any question.


    Thank you!

    Aenglan

  • jholland
    jholland Administrator, Rockstar Manager Posts: 90 eLearning ROCKSTAR Admin Team

    Hello @akim6794. The problem with using an external HTML object in this fashion is the Lectora Mute/Unmute/Pause/Play actions cannot possibly control whatever code is running in the external HTML object. You have to know how to program the code in the HTML object, in this case, the player from YouTube

    Joe asked a few times in these discussions:

    Why are you not using the "Insert Youtube" option? If you do, then the Lectora mute function will work. 

  • wheels
    wheels Florida USACommunity Member, Administrator, Moderator, Rockstar Manager Posts: 665 eLearning ROCKSTAR Admin Team

    I used a Youtube object from the Insert Tab in the Add Media panel.

    Then added the mute and unmute Run Javascript actions and it seems to be working fine.


  • akim6794
    akim6794 Community Member Posts: 7 ☆ Roadie ☆

    I downloaded the zip folder and tested it.

    It works now. Great!!!

    When I tested it long time ago, HTML object was more flexible to customize YouTube control bar.

    That's why I did not use YouTube object.

    However, when I tested yesterday, YouTube object works great!

    Thank you so much!!!!!

    Thank you, @wheels and @jholland


    Aenglan