path | 电影文件的文件系统路径。 |
bgColor | 背景颜色。 |
controlMode | 播放控件的显示方式。 |
scalingMode | 如何缩放电影以适合屏幕。 |
播放全屏电影。
注意,播放器将直接从设备存储流式传输电影,
因此,您必须将电影作为单独的文件
而不是普通资源提供。您必须在 Unity 项目(在您的“Assets”文件夹中)中
创建一个名为 StreamingAssets
的
文件夹。将电影存储在该文件夹中。
Unity 会自动将该文件夹的内容复制到
应用程序捆绑包中。
在播放电影期间调用该函数将暂停 Unity。播放完成后,
Unity 将恢复。
第一个参数 path
可以是基于网络的 URL。该函数
将通过查找协议名称后跟“://”子串来
检测基于网络的 URL。
在 iOS 上,Handheld.PlayFullScreenMovie
内部使用 MPMoviePlayerController
对象来播放电影。因此,Unity 在 iOS 上播放电影的行为和支持的格式
与 MPMoviePlayerController 相同。MPMoviePlayerController 支持任何
可在 iPod 或 iPhone 上正常播放的电影或音频文件。
对于电影文件,这通常意味着扩展名为 .mov、
.mp4、.mpv 和 .3gp 并使用以下压缩标准之一的
文件:
H.264 Baseline Profile Level 3.0 视频,最高为 640 x 480、30 fps。
注意,Baseline Profile 不支持 B 帧。
MPEG-4 Part 2 视频 (Simple Profile)。
调用该函数将启动一个过渡 -
屏幕将从当前内容淡出并淡入到指定的
播放器背景颜色。播放完成后,播放器会使用另一个淡入淡出效果
过渡回您的内容。
您可以在
MPMoviePlayerController 类参考中找到 Apple 的 MPMoviePlayerController 文档。
在 Windows Phone 8 上,Handheld.PlayFullScreenMovie
内部使用 Microsoft Media
Foundation 进行电影播放。在该平台上,不支持使用完全或最小控制模式调用 Handheld.PlayFullScreenMovie
。
在 Windows 应用商店应用程序和 Windows Phone 8.1 上,Handheld.PlayFullScreenMovie
内部使用 XAML MediaElement 控件。
在 Windows Phone 和 Windows 应用商店应用程序中,通常没有电影分辨率
或比特率限制,但是,更高分辨率或比特率的电影
将使用更多的解码内存。在极高的分辨率下,
性能较弱的设备也更容易跳帧。例如,
Nokia Lumia 620 只能顺畅播放分辨率最高为 1920x1080 的视频。
对于这些平台,您可以在
Windows 应用商店支持的音频和视频格式中找到支持的格式的列表。
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Example : MonoBehaviour { void Start() { Handheld.PlayFullScreenMovie("StarWars.mp4", Color.black, FullScreenMovieControlMode.CancelOnInput); } }
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.