> 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\&token=a7478d28-02c6-407d-a7c3-e63d964f062e)

## 常规设置

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

![](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\&token=90dfae8f-8dff-4b02-9d29-e0542e02dbd5)

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

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

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

## 播放视频

你可以从以下任一方式播放预录制视频：

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

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

* **自动**：场景加载后视频会立即开始播放。为此，将默认媒体源下拉菜单设置为 **视频网址** 并将 URL 直接粘贴到 **视频路径或 .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\&token=90dfae8f-8dff-4b02-9d29-e0542e02dbd5)
* **由管理员触发**：一个 [场景管理员](/creator/content-creator-zh/chang-jing-bian-ji-qi/shi-shi-yun-ying/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\&token=26b270ee-2c1a-4095-a9ac-01bf62c879e9)

在所有情况下，你都要将视频配置为循环播放或仅播放一次。

{% 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\&token=290f2048-4437-4133-8da0-7fecc9302024)

{% 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\&token=732a10e7-da1e-4a2b-b038-0f438fd1fb8e)

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

在进行 [实时流传输](/creator/content-creator-zh/chang-jing-bian-ji-qi/shi-shi-yun-ying/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-ying/live-streaming.md).

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

你也可以使用其他流媒体基础设施来流式传输视频。为此，只需将 Video Player 智能物件配置为使用 **视频网址** 媒体源，并将流 URL 粘贴到 **视频路径或 .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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.decentraland.org/creator/content-creator-zh/chang-jing-bian-ji-qi/jiao-hu-xing/video-screen.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
