Hi I everyone, I follow this guideline to use AssetBundles and StreamingAssets. It work fine in StandaloneOSXUniversal but not in Android and WebGL.
In Android, Texture file load normally but Video has this error
04-19 16:44:16.700 22433 22459 W Unity : AndroidVideoMedia: Error opening extractor: -10000
04-19 16:44:16.700 22433 22459 W Unity :
04-19 16:44:16.700 22433 22459 W Unity : (Filename: Line: 427)
04-19 16:44:16.700 22433 22459 W Unity :
In WebGL not working both Texture file and Video
blob:http://localhost:54474/4387db25-76d0-4ba1-8949-b82fc597be9e:2 Unable to open archive file: http://localhost:54474/StreamingAssets/video
(Filename: Line: 483)
I’m using unity 5.6.0f3 on macOS Sierra and this is my code.
Create Bundle (Of course I change target to WebGL when build with WebGL)
[MenuItem ("Assets/Build Android Bundle")]
static void BuildAllAssetBundles () {
BuildPipeline.BuildAssetBundles ("Assets/StreamingAssets", BuildAssetBundleOptions.UncompressedAssetBundle, BuildTarget.Android);
}
Use it
void Start () {
AssetBundle bundle = AssetBundle.LoadFromFile (Path.Combine (Application.streamingAssetsPath, "video"));
player.clip = bundle.LoadAsset<VideoClip> ("Hall.mov");
plane.material.SetTexture ("_MainTex", bundle.LoadAsset<Texture> ("Image.jpg"));
}
After trying a lot of things, I’m not sure LoadFromFile method can use with WebGL so I try
IEnumerator Start () {
#if UNITY_WEBGL
WWW www = WWW.LoadFromCacheOrDownload ("http://localhost:8080/StreamingAssets/video", 5);
yield return www;
AssetBundle bundle = www.assetBundle;
#else
AssetBundle bundle = AssetBundle.LoadFromFile (Path.Combine (Application.streamingAssetsPath, "video"));
#endif
player.clip = bundle.LoadAsset<VideoClip> ("Hall.mov");
plane.material.SetTexture ("_MainTex", bundle.LoadAsset<Texture> ("Image.jpg"));
}
And yeah It seems Texture can load normally but Video still has some error (which I’m not sure its related but only this occurred)
Uncaught (in promise) DOMException: Failed to load because no supported source was found.
Other configurations
video (my bundle name) manifest
ManifestFileVersion: 0
...
Assets:
- Assets/Video.renderTexture
- Assets/Image.jpg
- Assets/Hall.mov
Dependencies: []
So my question is How to get video assets work in Android and WebGL? and ** Can’t LoadFromFile use with WebGL? or Its can but I missed something?**
Any suggestions would be appreciated. Thanks.
