Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Feb 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy What is the code for auto-play at 0% volume for a YouTube video?

    Hello,

    I would like to embed my video to my website, but I'd like it to auto play with 0% volume or muted. I know how to auto play with an embed code, I just don't know how to change the volume. I read up on https://developers.google.com/youtube/js_api_reference that there is a javascript code to change volume (player.setVolume(volume:Number):Void) but I don't know how to use this.

    So basically I want to know the code for auto-play at 0% volume for a YouTube video.

    Any help is much appreciated,

    Jack

  • #2
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Location
    Splendora, Texas, United States of America
    Posts
    3,338
    Thanks
    29
    Thanked 282 Times in 276 Posts
    Quote Originally Posted by SucksAtCoding View Post
    I would like to embed my video to my website, but I'd like it to auto play with 0% volume or muted. I know how to auto play with an embed code, I just don't know how to change the volume. I read up on https://developers.google.com/youtube/js_api_reference that there is a javascript code to change volume (player.setVolume(volume:Number):Void) but I don't know how to use this.
    Per the reference you cited, you should use player.mute() where player is presumably a custom reference to a specific video.

    You can ignore the :Number and :Void stuff when writing your code. :Number means the argument volume should be a number, and :Void means the setVolume method returns no value. So, for example, var volume = player.setVolume(0) will mute the volume, but won't return anything useful.

    :Number and :Void originates from ECMAScript 4 (which one can think of as JavaScript 4) which was later abandoned in favor of ECMAScript 3.1 and 5. Adobe Flash's ActionScript 3 is based on ECMAScript 4 though and use that syntax. More typically, you'll see type info like this expressed in WebIDL format as seen, for example, in the HTML spec (where you can see that the corresponding volume property takes and returns a double (number) value).
    Last edited by Arbitrator; 02-16-2014 at 10:06 PM. Reason: I fixed a grammatical issue.
    For every complex problem, there is an answer that is clear, simple, and wrong.

  • #3
    New to the CF scene
    Join Date
    Feb 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Arbitrator View Post
    Per the reference you cited, you should use player.mute() where player is presumably a custom reference to a specific video.

    You can ignore the :Number and :Void stuff when writing your code. :Number means the argument volume should be a number, and :Void means the setVolume method returns no value. So, for example, var volume = player.setVolume(0) will mute the volume, but won't return anything useful.

    :Number and :Void originates from ECMAScript 4 (which one can think of as JavaScript 4) which was later abandoned in favor of ECMAScript 3.1 and 5. Adobe Flash's ActionScript 3 is based on ECMAScript 4 though and use that syntax. More typically, you'll see type info like this expressed in WebIDL format as seen, for example, in the HTML spec (where you can see that the corresponding volume property takes and returns a double (number) value).
    Ok. As my username suggests I suck at coding. I have done very little of it in my life. Could I use this in a HTML code? That's a stupid question, right? Could you possibly give me a code template and I fill in the required information like video id, volume etc.? This would really help. Hope it's not too much trouble.

    Jack


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •