# Class: YouTubePlayer

## YouTubePlayer

#### new YouTubePlayer(userOptions)

  Youtube Player loader

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `userOptions` | Object |

  ##### Properties:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `userOptions.height` | Number | <optional> |  |
  `userOptions.width` | Number | <optional> |  |
  `userOptions.videoId` | String | <optional> |  |
  `userOptions.$wrapper` | HTMLElement | <optional> |  |
  `userOptions.apiUrl` | String | <optional> | //www.youtube.com/iframe_api |
  `userOptions.onPlayerStateChange` | function | <optional> |  |

  `userOptions.playerVars`

  YTPlayer_PlayerVars

  <optional>

  Google API parameters. You can add all variable handle by the API.

  ###### Properties

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `autoplay` | Number | <optional> | 0 |
  `controls` | Number | <optional> | 2 |
  `autohide` | Number | <optional> | 1 |
  `modestbranding` | Number | <optional> | 1 |
  `showinfo` | Number | <optional> | 0 |
  `html5` | Number | <optional> | 1 |

  See:
    - extra/modules/youtube.md

  ##### Returns:

  Type
    Promise

  ##### Example

      let YouTubePlayer = new YouTubePlayer( {
              "height": 1920,
              "width": 1080,
              "videoId": 'youtube-video-id-here',
              "wrapper": $wrapper,
              "apiUrl": "//www.youtube.com/iframe_api",
              "onPlayerStateChange": ( newState ) => {
                  if ( newState.data === YT.PlayerState.ENDED ) {
                       // Code here for video ended
                  }
              },
              "playerVars": {
                  "autoplay": 0,
                  "controls": 2,
                  "autohide": 1,
                  "modestbranding": 1,
                  "showinfo": 0,
                  "html5": 1,
                  // ... All available youtube player options
              }
          }
      )
      .then( ytPlayerInstance => {} );

#### Search results