# Playback Control

The SDK also allows to control all Playback Mechanisms of the Player in every Moment. The **`_play.control.interact`** Namespace is used for these Functions.

There are two Ways to control a Player Instances Playback:

* it is possible to use the global **`_play.control.interact.*`** Method with the Use of a Container-ID Parameter.
* it is possible to call the Method directly on the Player Instance Object (returned by every **`_play.control.addPlayer*`** Method)

####

### General Playback

```javascript
_play.control.interact.play(CONTAINER-ID)
```

```javascript
_play.control.interact.pause(CONTAINER-ID,canBeResumed)
```

```javascript
//starts play, if paused and pauses if currently playing.
_play.control.interact.toggle(CONTAINER-ID)
```

```javascript
//is identical to play() on an Instance in "paused" State
_play.control.interact.resume(CONTAINER-ID)
```

```javascript
//only possible on a Player Instance, that has not been started yet, but is ready to start
_play.control.interact.startMuted(CONTAINER-ID)
```

```
_play.control.interact.mute(CONTAINER-ID)
```

```
_play.control.interact.unmute(CONTAINER-ID)
```

```
_play.control.interact.seekTo(CONTAINER-ID,time)
```

```
_play.control.interact.seekBy(CONTAINER-ID,time)
```

```
_play.control.interact.setVolume(CONTAINER-ID,[0.1-1])
```

```
_play.control.interact.setPlaybackSpeed(CONTAINER-ID,[-1:2])
```

```
_play.control.interact.setAudioTrack(CONTAINER-ID,lang,role)
```

```
_play.control.interact.setTextTrack(CONTAINER-ID,lang,role)
```

```
_play.control.interact.hideTextTrack(CONTAINER-ID)
```

### Playback of multiple Items within a Media Container

```javascript
//swap to the next Item in a Container Element (Playlist, Collection, AudioAlbum etc)
_play.control.interact.next(CONTAINER-ID)
```

```javascript
//swap to the previous Item in a Container Element (Playlist, Collection, AudioAlbum etc)
_play.control.interact.previous(CONTAINER-ID)
```

```javascript
//swap to exactly this Position of the Item List
_play.control.interact.swapToPosition(CONTAINER-ID,position)
```

### Playback Mode

```javascript
//this Command will fail under most conditions (as Fullscreen Enter needs a User Gesture by Browser Security)
_play.control.interact.enterFullscreen(CONTAINER-ID)
```

```
_play.control.interact.exitFullscreen(CONTAINER-ID)
```

```
_play.control.interact.enterPopout(CONTAINER-ID)
```

```
_play.control.interact.exitPopout(CONTAINER-ID,andContinuePlay)
```

####

### Changing the Media Object

```
_play.control.interact.swapToMediaItem(CONTAINER-ID,MEDIA-ID,STREAMTYPE,startPosition,delay,reason,showReturnButton)
```

```
_play.control.interact.swapToGlobalID(CONTAINER-ID,GLOBAL-ID,startPosition,delay,reason,showReturnButton)
```

```
_play.control.interact.swapToRemoteMedia(CONTAINER-ID,REMOTE-REFERENCE,STREAMTYPE,PROVIDER,delay,reason,showReturnButton)
```

####

### Interacting with connected Files and Downloads

```javascript
//start Downloading a connected File, indicated by its position in the current File List
_play.control.interact.startDownloadFile(CONTAINER-ID,position);
```

### Interacting with connected Polls

```javascript
//start Downloading a connected File, indicated by its position in the current File List
_play.control.interact.startPoll(CONTAINER-ID,POLL-ID);
```

{% hint style="info" %}
**POLL-ID** is the valid ID of a Poll. If **POLL-ID** is omitted, the Player will start the Poll, that has been connected to the current Media (if any).
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://play.docs.nexx.cloud/javascript-sdk/playback-control.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
