I am trying to get YouTube videos embedded and auto playing (working) but to have the sound muted (not working).
I am using the YouTube IFrame API with the following code: -
<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: 'VIDEO_ID', // YouTube Video ID
width: 560, // Player width (in px)
height: 316, // Player height (in px)
playerVars: {
autoplay: 1, // Auto-play the video on load
controls: 1, // Show pause/play buttons in player
showinfo: 0, // Hide the video title
modestbranding: 1, // 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
},
events: {
onReady: function(e) {
e.target.mute();
}
}
});
}
// Written by @labnol
</script>
This works in the preview window in the layout designer, the video plays and the speaker control has a line through it as if it has been muted (Same in IE and Chrome)
How ever when it opens on the client, the video plays but the speaker is not crossed out and sound plays.
Any one have any idea of why the preview is working and the client is not.
Same results as muting, the alert was called in the preview but not in the client, so the function is not being called on the client but is in the preview.
I have opened the CMS on the client machine and it gets muted in the preview on there so i has to be something to do with the client and not the machine.
On the client, in the local library there will be a set of HTML files, unfortunately with long random names. One of these will be the local copy of your embedded items rendered content.
Can you try to find that file - and when you find it, open it in IE to see if mute works. I suspect it will - can you then pop the file online somewhere that we can download it (dropbox or similar?)
Any here’s where the problem gets worse, if I open it with chrome, it does get muted. I don’t get it. I can open the CMS with either chrome or IE and the preview gets muted?
That is not as unusual as you might think - they are different in that one is a local page and the other is being served by a web server.
I suspect it might be something to do with mixed content (https on the javascript reference). If we have the file we can look to confirm - or you could change it locally to see