0

i have nice iframe with simple js but my problem i want to play it in MUTE ,but i could not make ,so can help me to do , REMEMBER i do not want autoplay ,just i want to make it MUTE audio when click play ,,, here my code below

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">

    <script src="http://code.jquery.com/jquery-latest.min.js"></script>
    <script type="text/javascript" src="http://www.jqueryscript.net/demo/Easy-jQuery-Video-Controller-Plugin/dist/jquery.videoController.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function() {
        $('#my-video').videoController({
            videoReady: function() { displayEvent('ready'); },
            videoStart: function() { displayEvent('start'); },
            videoPlay: function() { displayEvent('play'); },
            videoPause: function() { displayEvent('pause'); },
            videoEnded: function() { displayEvent('ended'); }
        });
    });

    function playVideo() {
        $('#my-video').videoController('play');
    }

    function pauseVideo() {
        $('#my-video').videoController('pause');
    }

    function stopVideo() {
        $('#my-video').videoController('stop');
    }

    function displayEvent(eventType) {
        var textarea  = $('.events');

        textarea.val(textarea.val() + '\n' + eventType);
        textarea.scrollTop(textarea[0].scrollHeight);
    }
</script>

    </head>

    <body>

    <iframe id="my-video" src="http://www.youtube.com/embed/oaDkph9yQBs?enablejsapi=1" width="560" height="315" frameborder="0" allowfullscreen></iframe>
    <div class="controls"> <a href="#" onclick="playVideo();">Play</a> <a href="#" onclick="pauseVideo();">Pause</a> <a href="#" onclick="stopVideo();">Stop</a> </div>
    <textarea class="events" cols="50" rows="10">Events:</textarea>

    </body>
    </html>
k76
  • 11
  • 1
  • 9
  • seems this question is duplicated http://stackoverflow.com/questions/35044594/youtube-how-to-present-embed-video-with-sound-muted – ilmk Nov 27 '16 at 05:16
  • its not the same , its not api iframe even not autoplay , i just need the line which make it mute , – k76 Nov 27 '16 at 05:36

1 Answers1

0

It's a duplicate. In your example is nothing wich could mute the video. But here a copy of the correct answer.

<iframe id="my-video" src="http://www.youtube.com/embed/oaDkph9yQBs?enablejsapi=1" width="560" height="315" volume="0" frameborder="0" allowfullscreen></iframe>

it seems that the video-controller plugin don't have a method to mute the video. So...:

var myVideo =  iframe.getElementById('myVideo');
myVideo.mute();
MFGSparka
  • 145
  • 9