# Player Setup

Player setup requires the following steps to create a player instance:

### Step 1 - Load the Library

```html
<script src="//PATH/TO/PLAYER/LIB/FILENAME.js"></script>
```

### Step 2 - Create the Player Container

```html
<div id="player-container"></div>
```

### Step 3 - Define Your Configuration

```js
var config = {
  targetId: "player-container",
  playback: { ... }, // playback configuration
  sources: { ... }, // sources configuration
  plugins: { ... }, // plugins configuration
  session: { ... }, // session configuration
  provider: { // provider configuration
    ...
    partnerId: YOUR_PARTNER_ID
    ...
  },
  ui: { ... } // ui configuration
};
```

The following sections are examples of common (and important) configurations for the player setup.

#### Example: Using a Vidiun Session (VS)

If you need to use a VS for your media requests, configure it inside your provider configuration:

```js
var config = {
  ...
  provider: {
    ...
    partnerId: YOUR_PARTNER_ID,
    vs: 'YOUR_VS'
    ...
  }
  ...
};
```

See this [article](https://developer.vidiun.com/api-docs/VPaaS-API-Getting-Started/how-to-create-vidiun-session.html) to learn more about how to create a VS.

#### Example: Using Server Configuration

If you want to use a server configuration, you'll need to provide the `uiConfId` in your provider configuration:

```js
var config = {
  ...
  provider: {
    ...
    partnerId: YOUR_PARTNER_ID,
    uiConfId: YOUR_UI_CONF_ID
    ...
  }
  ...
};
```

#### Example: Using an Environment

If you want to refer to a specific backend URL, you can specify it in your provider configuration:

```js
var config = {
  ...
  provider: {
    ...
    partnerId: YOUR_PARTNER_ID,
    env: {
        serviceUrl: 'YOUR_SERVICE_URL'
      }
    ...
  }
  ...
};
```

> For full configuration details see [this]() document.

### Step 4 - Set Up the Player

To get your player instance, use the `setup` factory method and pass it your player configuration:

```js
var player = VidiunPlayer.setup(config);
```

## Next Step

You're now ready to start playing your video; see [Playing Your Video](./playing-your-video.md) for details.
