一、unity编译器下使用UMP可以播放视频、使用exe打包后不播放
原因:ump插件版本太低 2019使用1.7版本会出现这个问题 使用2.0.3版本后问题解决 。
UMp2.0版本下载 https://pan.baidu.com/s/1nNNPm9TY_UWGfkInlDk8AA 提取码:syq1
二、打包的exe文件,在有工程的电脑下可以播放,其他电脑播放失败原因
[UMPSetting] Can't find LibVLC libraries, try to check the settings file in UMP 'Resources' folder.
(Filename: E:\unity\Runtime/Export/Debug/Debug.bindings.h Line: 35)
Debug错误:找不到LibVLC库,尝试检查UMP 'Resources'文件夹中的设置文件。
原因:导入Ump插件后,在UniversalMediaPlayer——>Resources文件夹下有一个UMPSettings
这个是用来配置VLC播放器的 可以看到它找的是工程绝对路径下的dll文件。
所以要想解决这个问题就要更改获取dll的文件路径
1.首先 我们取消勾选 Use installed VLC,貌似不勾选也可以,我们后面会用代码修改dll的获取路径
或者在 Windows选项卡下点击UMPSettings
两个方式都可以。。。。。
2.找到UMPPostBuilds.cs脚本
找到这个方法:
public static void BuildWindowsPlayer64(string path, UMPSettings settings)
{
string buildPath = Path.GetDirectoryName(path);
string dataPath = buildPath + "/" + Path.GetFileNameWithoutExtension(path) + "_Data";
if (!string.IsNullOrEmpty(buildPath))
{
if (!settings.UseExternalLibraries)
{
CopyPlugins(settings.AssetPath + "/Plugins/Win/x86_64/plugins/", dataPath + "/Plugins/plugins/");
//添加此处代码
string[] files = Directory.GetFiles(dataPath + "/Plugins/x86_64/");
foreach (string str in files)
{
string file = Path.GetFileName(str);
Debug.LogError(file);
File.Copy(str, dataPath + "/Plugins/" + file);
}
Directory.Delete(dataPath + "/Plugins/x86_64/", true);
}
else
{
if (File.Exists(dataPath + "/Plugins/" + UMPSettings.LIB_VLC_NAME + ".dll"))
File.Delete(dataPath + "/Plugins/" + UMPSettings.LIB_VLC_NAME + ".dll");
if (File.Exists(dataPath + "/Plugins/" + UMPSettings.LIB_VLC_CORE_NAME + ".dll"))
File.Delete(dataPath + "/Plugins/" + UMPSettings.LIB_VLC_CORE_NAME + ".dll");
}
}
Debug.Log("Standalone Windows (x86_x64) build is completed: " + path);
}
修改后打包 就可以了 。
这里有两个注意事项:
1.存放exe包的文件夹下不能存在中文名称
2.导入的UMP插件UniversalMediaPlayer一定要在Assets文件夹下