我正在使用Unity5个人版(免费)来播放Assets下Streaming Assets文件夹中的.ogv电影文件。代码是
Handheld.PlayFullScreenMovie("coc.ogv", Color.black, FullScreenMovieControlMode.Full, FullScreenMovieScalingMode.AspectFill);
其中coc.ogv是文件名。该函数在OnMouseDown()函数上调用。但当我在安卓设备上试用它时,它只会发出黑色的闪光,除此之外什么也不起作用。没有错误或警告。
请帮帮忙。
发布于 2016-03-21 15:34:51
好了,开始吧。如果你是为PC构建的,那么就使用MovieTexture和.ogv格式。如果是安卓系统,请选择.mp4 (h.264小于等于480p)。使用Application.StreamingAssetsPath获取jar文件中的assets文件夹。
发布于 2017-09-19 11:33:56
我找到的解决方案是将视频存储在Application.streamingAssetsPath文件夹中,然后在运行时将文件复制到Application.persistentDataPath文件夹中,然后从那里读取。
string arc = "core1280x800.mp4";
string defaultFilePath = Path.Combine(Application.streamingAssetsPath, arc);
string filePath = Path.Combine(Application.persistentDataPath, arc);
byte[] bytes = null;
if (!File.Exists(filePath))
{
if (Application.platform == RuntimePlatform.Android)
{
WWW archivo = new WWW(defaultFilePath);
while (!archivo.isDone)
{ } // c'mon, you can do better than this! ¬ ¬
bytes = archivo.bytes;
File.WriteAllBytes(filePath, bytes);
}
else
{
if (File.Exists(defaultFilePath))
{
bytes = File.ReadAllBytes(defaultFilePath);
File.Copy(defaultFilePath, filePath);
}
}
}
Handheld.PlayFullScreenMovie(filePath, Color.black, FullScreenMovieControlMode.Hidden);尽管文档只说明了将视频文件放在Application.streamingAssetsPath文件夹中就足够了,但几天来,我无法播放任何文件,无论其分辨率或格式如何。使用这段代码,我已经能够播放分辨率高于480p的全屏视频文件,我只测试了MP4和MOV文件,但只有MP4可以工作;MOV只是静默地失败了。
ps。我知道,while循环并不优雅,也不推荐使用,但就目前而言,它很简单,也很有效。
https://stackoverflow.com/questions/36113218
复制相似问题