> 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).

# 视频屏幕

在你的场景中播放视频

要在场景的屏幕上播放预录制视频或视频流，请使用视频播放器 [智能物品](https://docs.decentraland.org/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-4ffd58cadcc524a13cd567ca4d5ccdc70fc994f2%2Fvideo-player-item.webp?alt=media)

## 常规设置

无论是播放视频还是播放视频流，这些设置都适用。

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

您可以配置视频的音量。请注意，视频流的音频不具有位置性，在场景中的任何位置听到的音量都相同。

“ **默认媒体源** ”下拉菜单可让您选择两种不同的来源：

* **视频 URL**：从 URL 或本地视频文件获取视频或视频流
* **直播**：使用 Decentraland 的免费流媒体基础设施展示直播。要使用此功能，还必须在场景中添加一个 [管理工具](https://docs.decentraland.org/creator/content-creator-zh/chang-jing-bian-ji-qi/shi-shi-yun-ying/scene-admin.md) 智能物品。

## 播放视频

您可以从以下来源播放预录制视频：

* **本地文件**：将视频文件作为场景的一部分上传，然后在 *URL* 字段中填写该文件的路径。
* **从 URL 播放视频流**：指向网络上的直播或预录制视频流，例如由 Bunny 等提供商提供的视频流。请参阅 [流式传输视频](#streaming-from-other-sources)

视频播放器智能物品开始播放视频的时机可以由不同因素决定：

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

  ![](https://2460066822-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoPnXBby9S6MrsW83Y9qZ%2Fuploads%2Fgit-blob-e541aa1b70f1acbe5fa979cb3159a5997996d783%2Fvideo-automatic.webp?alt=media)
* **由管理员触发**：当前位于场景中的 [场景管理员](https://docs.decentraland.org/creator/content-creator-zh/chang-jing-bian-ji-qi/shi-shi-yun-ying/scene-admin.md) 可以使用管理界面粘贴视频 URL，并为当前场景中的所有玩家播放该视频。
* **根据玩家行为触发**：定义一个类型为“ **播放视频**”的操作。这样就可以在玩家与其他智能物品交互时触发视频播放，例如走进房间或按下按钮。请参阅 [智能物品——高级](https://docs.decentraland.org/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-7cc86ee3e3592207911f08a950a62534af287e21%2Fvideo-from-action.webp?alt=media)

在所有情况下，您都可以将视频配置为循环播放或播放一次。

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

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

我们还建议在玩家靠近或执行相应操作时才开始播放视频。如果场景还在远处地平线上加载时就开始播放视频，会在玩家访问相邻场景时对性能造成不必要的影响。
{% endhint %}

## 多个视频屏幕

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

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

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

1. 在场景中添加两个 Video Player 智能项目，每个屏幕各添加一个。
2. 按照 [播放视频](#play-videos) 部分中的说明，正常配置第一个播放器。
3. 在第二个视频播放器上，移除 **Video Player** 组件。

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

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

4. 仍在第二个视频播放器上，打开 **Material** 组件，展开 **Texture** 部分，然后选择 **Video Source Entity** 下拉菜单，将其指向第一个视频播放器。

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

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

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

{% hint style="info" %}
**💡 提示**：你也可以对带有 **Swap Material** 组件的项目重复上述步骤，将任意 3D 模型变成视频屏幕。配置 **Texture** 部分中的 **Swap Material** 组件，使其指向视频播放器实体。
{% endhint %}

## 关于视频文件

支持以下文件格式：

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

请注意，视频文件会增加场景的总大小，导致玩家进入场景时需要更长时间下载场景。视频文件的大小也可能导致你超出 [场景限制](https://docs.decentraland.org/creator/content-creator-zh/chang-jing-sdk7/you-hua/scene-limitations.md)，因为每个地块最多只能使用 15 MB。我们建议尽可能压缩视频，以减少其带来的影响。

## 直播

如需了解端到端直播，请参阅 [直播](https://docs.decentraland.org/creator/content-creator-zh/chang-jing-bian-ji-qi/shi-shi-yun-ying/live-streaming.md).

### 从其他来源进行流式传输

你也可以使用其他流媒体基础设施来播放视频。只需将 Video Player 智能项目配置为使用 **Video URL** 媒体源，然后将直播流 URL 粘贴到 **Video Path or .m3u8 URL** 字段中。

流媒体来源必须是 *https* URL（不支持*http* URL），并且来源应具有允许外部访问的 [CORS 策略（跨源资源共享）](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing) 。这意味着你无法从 YouTube 等类似网站播放视频，因为这些网站只允许通过其品牌化的 HTML 小组件显示内容。请参阅 [关于外部流媒体](https://docs.decentraland.org/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，确保流媒体播放顺畅](https://docs.decentraland.org/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.
