# Autoplay

The optional autoplay option automatically launches a show without a viewer having to actively click a library item. autoplay accepts either a boolean value or a callback function.

### Type definition

```typescript
type Autoplay =
  | boolean
  | ((sources: ComposedShow[], library: Library) => string | undefined);
```

### Automatic show selection

```javascript
window.LiSA.library.configs.push({
  autoplay: true,
});
```

If autoplay is set to true, LiSA Library selects the show to be launched automatically by applying the following checks in their order of priority as listed below:

The next upcoming show that is scheduled between T - 1 hour and T + 3 hours — with T being the current time.

&#x20;If 1. does not apply to any show, the most recent show that was scheduled T - 48 hours and T is selected — with T being the current time.

&#x20;If neither 1. or 2. apply, the next upcoming show is selected.&#x20;

If no upcoming show is available, the most recent show not matching Rule 2. is selected.&#x20;

If none of the above rules apply, LiSA Library will not launch any show automatically.

### Individual show selection

```
window.LiSA.library.configs.push({
  autoplay: (shows, library) => {
    return shows.find((show) => {
      /* your code goes here... */
    })
  },
});
```

You can also provide a callback function to select the desired show, applying custom logic. The callback function accepts an iterable collection of shows and the library instance. It's return value is either the desired show's identifier (id) or undefined, if the desired your requirements do not apply to any of the shows.

### Query parameter lisa\_autoplay

In addition to launching a show using the autoplay option, LiSA Library also checks your content page URL's query string for the lisa\_autoplay parameter.

**Example**: <https://your-storefront.com/live-shopping?lisa\\_autoplay=a0377e94-0f09-4cb7-a630-f5b2c3df74ed>

In this example LiSA Library automatically launches the show with the ID a0377e94-0f09-4cb7-a630-f5b2c3df74ed either in an overlay or an embedded player (stage) — irrelevant of that particular show being listed in the library or not.


---

# 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://docs.hello-lisa.com/developers/widgets/configuration-options/autoplay.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.
