> For the complete documentation index, see [llms.txt](https://docs.decentraland.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.decentraland.org/creator/content-creator-zh/chang-jing-bian-ji-qi/jiao-hu-xing/video-screen.md).

# 视频屏幕

在你的场景中播放视频

要在场景中的屏幕上播放预录视频或串流视频，请使用 Video Player [智能物品](/creator/content-creator-zh/chang-jing-bian-ji-qi/jiao-hu-xing/smart-items.md).

![](https://2460066822-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoPnXBby9S6MrsW83Y9qZ%2Fuploads%2Fgit-blob-01d7193f1148aa3fc6d53232dfb403cc815b6bce%2Fvideo-player-item.png?alt=media)

## 常规设置

这些设置适用于所有场景，无论你是在播放视频还是进行串流。

![](https://2460066822-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoPnXBby9S6MrsW83Y9qZ%2Fuploads%2Fgit-blob-d050af90f1b3bbb51c17f70ccdfd6ab0056b4057%2Fvideo-automatic.png?alt=media)

你可以配置视频音频的音量。请注意，串流音频不是定位音频，在整个场景中都会以相同音量播放。

该 **默认媒体来源** 下拉菜单可让你在两种不同类型的来源之间选择：

* **视频 URL**：从 URL 或本地视频文件获取视频或串流
* **直播串流**：使用 Decentraland 的免费串流基础设施来显示串流。要使用此功能，你还必须包含一个 [管理员工具](/creator/content-creator-zh/chang-jing-bian-ji-qi/shi-shi-yun-wei/scene-admin.md) 智能物件到你的场景中。

## 播放视频

你可以通过以下任一方式播放预录视频：

* **本地文件**：将视频文件作为场景的一部分上传，然后将 *URL* 字段指向该文件的路径。
* **从 URL 流式播放**：指向网上的直播或预录串流，例如来自 Bunny 等提供商。请参见 [串流视频](#streaming-videos)

Video Player 智能物件何时播放视频的时机可能取决于不同因素：

* **自动**：场景加载后视频立即开始播放。为此，请将默认媒体来源下拉菜单设置为 **视频 URL** 并将 URL 直接粘贴到 **Video Path 或 .m3u8 URL** 字段中。

  ![](https://2460066822-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoPnXBby9S6MrsW83Y9qZ%2Fuploads%2Fgit-blob-d050af90f1b3bbb51c17f70ccdfd6ab0056b4057%2Fvideo-automatic.png?alt=media)
* **由管理员触发**: 一个 [场景管理员](/creator/content-creator-zh/chang-jing-bian-ji-qi/shi-shi-yun-wei/scene-admin.md) 当前在场景中的人可以使用管理员界面粘贴视频 URL，并为当前场景中的所有玩家播放。
* **基于玩家操作**：定义一种类型为 **播放视频**的 Action。这让你可以在与其他智能物件交互时触发视频播放，例如走进房间或按下按钮。请参见 [智能物品 - 高级](/creator/content-creator-zh/chang-jing-bian-ji-qi/jiao-hu-xing/smart-items-advanced.md).

  ![](https://2460066822-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoPnXBby9S6MrsW83Y9qZ%2Fuploads%2Fgit-blob-4d3db4d32f746dc116b09884db7c74ba53dbef7a%2Fvideo-from-action.png?alt=media)

无论哪种情况，你都可以将视频配置为循环播放或仅播放一次。

{% hint style="warning" %}
**📔 注意**：如果你的场景中同时播放的视频太多，部分视频会被引擎暂停。优先级由与玩家的距离、摄像机方向以及屏幕大小决定。可同时播放视频的最大数量取决于玩家的画质设置。

* 低：1
* 中：5
* 高：10

我们还建议在玩家靠近或执行某个动作时再开始播放视频。若在地平线远处的场景加载时就开始播放视频，会在玩家访问相邻场景时不必要地影响性能。
{% endhint %}

## 多个视频屏幕

你可以在多个屏幕上同时播放同一个视频。为此，你必须编辑 Video Player 智能物件的高级属性。

{% hint style="warning" %}
**📔 注意**：避免同时播放多个不同视频，因为这会严重影响性能。

如果你只是将相同的 URL 粘贴到两个视频播放器中，引擎不会知道它们是同一个视频，并会分别播放。请按照以下步骤配置第二个视频播放器，使其播放与第一个相同的视频。
{% endhint %}

1. 向场景中添加两个 Video Player 智能物件，每个屏幕一个。
2. 像 [播放视频](#play-videos) 部分。
3. 在第二个视频播放器上，移除 **视频播放器** 组件。

![](https://2460066822-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoPnXBby9S6MrsW83Y9qZ%2Fuploads%2Fgit-blob-514512790126de29e5922a34a7bf9be49ffe4441%2Fdelete-video-player.png?alt=media)

{% hint style="warning" %}
**📔 注意**：这一步很重要，否则即使第二个视频播放器不可见，引擎也会对其进行处理。
{% endhint %}

4. 仍在第二个视频播放器上，打开 **材质** 组件，展开 **纹理** 部分，然后选择 **视频源实体** 下拉菜单，将其指向第一个视频播放器。

![](https://2460066822-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoPnXBby9S6MrsW83Y9qZ%2Fuploads%2Fgit-blob-5bf384e5fd6759644c26475e929af0696d3795b8%2Fpoint-to-video.png?alt=media)

只要你将每个都配置为指向同一个视频播放器，你就可以对任意数量的视频播放器执行相同操作。

在进行 [直播串流](/creator/content-creator-zh/chang-jing-bian-ji-qi/shi-shi-yun-wei/live-streaming.md)时，两个屏幕也会显示相同的串流。

{% hint style="info" %}
**💡 提示**：以上步骤也可以对带有 **交换材质** 组件的物件重复执行，以将任何 3D 模型变成视频屏幕。配置 **纹理** 中的 **交换材质** 组件部分，将其指向视频播放器实体。
{% endhint %}

## 关于视频文件

支持以下文件格式：

* *.mp4*
* *.ogg*
* *.webm*

请记住，视频文件会增加场景的总大小，这会使玩家进入你的场景时下载时间更长。视频大小也可能让你超过 [场景限制](/creator/content-creator-zh/chang-jing-sdk7/you-hua/scene-limitations.md)，因为每个地块可用的最大容量为 15 MB。我们建议尽可能压缩视频，这样问题会小一些。

## 直播串流

关于端到端直播串流，请参见 [直播](/creator/content-creator-zh/chang-jing-bian-ji-qi/shi-shi-yun-wei/live-streaming.md).

### 来自其他来源的流媒体

你也可以使用其他串流基础设施来传输视频。为此，只需将 Video Player 智能物件配置为使用 **视频 URL** 媒体来源，并将串流 URL 粘贴到 **Video Path 或 .m3u8 URL** 字段中。

串流来源必须是一个 *https* URL（*http* 不支持 URL），并且来源应具有 [CORS 策略（跨源资源共享）](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing) ，以允许外部访问。这意味着你不能从 YouTube 或类似网站串流视频，因为这些网站只允许通过其品牌化的 HTML 小部件显示内容。请参见 [关于外部直播](/creator/content-creator-zh/chang-jing-sdk7/mei-ti/video-playing.md#about-external-streaming) 以了解可选方案和提示。

视频串流有多种选择。最简单的方案是使用托管服务提供商，例如 [Vimeo](https://vimeo.com/), [Bunny](https://bunny.net), [Livepeer Studio](https://livepeer.studio/) 或 [Serraform](https://serraform.gitbook.io/streaming-docs/guides/decentraland-playback) ，你向提供商支付费用，由其管理所有串流基础设施。

阅读 [为成功直播配置 OBS](/creator/content-creator-zh/chang-jing-sdk7/mei-ti/video-playing.md#setting-up-obs-for-successful-streaming) 以获取如何最佳地将内容串流到 Decentraland 的提示。


---

# 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://docs.decentraland.org/creator/content-creator-zh/chang-jing-bian-ji-qi/jiao-hu-xing/video-screen.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.
