> For the complete documentation index, see [llms.txt](https://polyv.gitbook.io/document/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://polyv.gitbook.io/document/docs/live/js/live-player/function/play.md).

# 视频播放

## 直播/回放自动切换

设置isAutoChange:true参数可以实现，直播开始时播放直播流，直播结束后，播放视频库-直播暂存-首个暂存文件。（注意：暂存文件保留有时间期限）

```
const player = polyvLivePlayer({
    wrap: '#player',
    width: 800,
    height: 533,
    uid: 'uid',
    vid: 'vid',
    isAutoChange: true
});
```

![autoChange](/files/QusebJDITWaovNPd8efh)

## 直播间统计

设置统计相关信息。在POLYV-直播后台才会有直播/回放对应相关信息的记录。如目前支持传入观众ID - param1、观众昵称 - param2。

```
const player = polyvLivePlayer({
    wrap: '#player',
    width: 800,
    height: 533,
    uid: 'uid',
    vid: 'vid',
    param1: 'user_polyv',
    param2: '昵称POLYV'
});
```

## 网页全屏

直播播放器默认点击全屏按钮，是调用浏览器API requestFullscreen实现的系统全屏，全屏后一定会使用浏览器的默认控制栏皮肤。若在手机端H5播放，想实现类似APP的全屏+横屏效果。可以添加如下参数实现，实现方案是控制样式css处理页面旋转达到与APP类似效果。

```
const player = polyvLivePlayer({
    wrap: '#player',
    width: 800,
    height: 533,
    uid: 'uid',
    vid: 'vid',
    webPageFullScreen: true,
    fullScreenOrientation: 'landscape'
})
```

若fullScreenOrientation参数不为landscape，仅设置webPageFullScreen：true参数，则点击全屏按钮不进入系统全屏，需要搭配全屏进入/退出事件处理相关样式。

```
const player = polyvLivePlayer({
    wrap: '#player',
    width: 800,
    height: 533,
    uid: 'uid',
    vid: 'vid',
    webPageFullScreen: true,
    fullScreenOrientation: 'landscape'
})

player.on('s2j_onFullScreen', () => {
	console.info('点击进入全屏按钮，将播放器铺满当前网页');
})

player.on('s2j_onFullScreen', () => {
	console.info('点击退出全屏按钮，将播放器恢复原来大小');
})
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://polyv.gitbook.io/document/docs/live/js/live-player/function/play.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
