YouTube: How to present embed video with sound mut

2019-01-06 17:17发布

I'm trying to embed a video with the sound muted but I can not figure out how it make it work.

Currently I'm using this but doesn't work:

<iframe src="https://www.youtube.com/embed/uNRGWVJ10gQ?rel=0&amp;autoplay=1" width="560" height="315" frameborder="0" allowfullscreen></iframe>

Any of you knows how can I make this work ?

13条回答
我命由我不由天
2楼-- · 2019-01-06 17:18

This is easy. Just add mute=1 to the src parameter of iframe.

Example:

<iframe src="https://www.youtube.com/embed/uNRGWVJ10gQ?ecver=1?controls=0&mute=1&showinfo=0&rel=0&autoplay=1&loop=1&playlist=uNRGWVJ10gQ" frameborder="0" allowfullscreen></iframe>

查看更多
虎瘦雄心在
3楼-- · 2019-01-06 17:19

For me works using &autoplay=1&mute=1

查看更多
We Are One
4楼-- · 2019-01-06 17:22

I would like to thank the friend who posted the codes below in this area. I finally solved a problem that I had to deal with all day long.

<div id="muteYouTubeVideoPlayer"></div>
                            <script async src="https://www.youtube.com/iframe_api"></script>
                            <script>
                                function onYouTubeIframeAPIReady() {
                                    var player;
                                    player = new YT.Player('muteYouTubeVideoPlayer', {
                                        videoId: 'xCIBR8kpM6Q', // YouTube Video ID
                                        width: 1350, // Player width (in px)
                                        height: 500, // Player height (in px)
                                        playerVars: {
                                            autoplay: 1, // Auto-play the video on load
                                            controls: 0, // Show pause/play buttons in player
                                            showinfo: 0, // Hide the video title
                                            modestbranding: 0, // Hide the Youtube Logo
                                            loop: 1, // Run the video in a loop
                                            fs: 0, // Hide the full screen button
                                            cc_load_policy: 0, // Hide closed captions
                                            iv_load_policy: 3, // Hide the Video Annotations
                                            autohide: 0, // Hide video controls when playing
                                            rel: 0 
                                        },
                                        events: {
                                            onReady: function(e) {
                                                e.target.setVolume(5);
                                            }
                                        }
                                    });
                                }

                                // Written by @labnol

                            </script>

查看更多
劳资没心,怎么记你
5楼-- · 2019-01-06 17:28

was also looking for a solution to this but I wasn't including via iframe, mine was linked to images/video.mp4 - found this https://www.w3schools.com/tags/att_video_muted.asp - and I simply added < video controls muted > (CSS/HTML 5 solution), but no JS required for me...

查看更多
地球回转人心会变
6楼-- · 2019-01-06 17:30

Updated

Add &mute=1 to the end of your url.

Your new code would be:

<iframe src="https://www.youtube.com/embed/uNRGWVJ10gQ?rel=0&amp;autoplay=1&mute=1" width="560" height="315" frameborder="0" allowfullscreen></iframe>

Old Answer

You're going to have to add Javascript to mute the audio. Add an id to your iframe: Then retrieve the id with javascript: var myVideo = iframe.getElementById('myVideo'); myVideo.mute();

Also see the mute section in the Youtube API reference https://developers.google.com/youtube/js_api_reference?csw=1

And the question: How do I automatically play a Youtube video (IFrame API) muted?

查看更多
干净又极端
7楼-- · 2019-01-06 17:30

<iframe  src="https://www.youtube.com/embed/7cjVj1ZyzyE?autoplay=1&loop=1&playlist=7cjVj1ZyzyE&mute=1" frameborder="0"  allowfullscreen></iframe>

mute=1

查看更多
登录 后发表回答