- Home /
Loading a movie at runtime and file location
Hey y'all.
I'm doing a project using movie textures, which is mostly done. However, one of the requirements is that the user must be able to have a folder to set his own videos to be loaded by the application.
I already managed to load videos at runtime using WWW class.
IEnumerator Start () {
//Debug.Log(Application.dataPath);
//Debug.Log(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments));
movie = renderer.material.mainTexture as MovieTexture;
string path = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments), "cat.ogv");
// www = new WWW ("file://c://cat.ogv"); <-- works
www = new WWW("file://c://Program Files (x86)/cat.ogv"); //<-- won't work
while(!www.movie.isReadyToPlay){
yield return www;
}
movie = www.movie;
renderer.material.mainTexture = movie;
}
Problem is that I tried setting manually a folder on My Documents. It won't work. Then I tried setting a folder on the built project. Won't work.
I've been searching for quite some time (hence the commented Application stuff) but couldn't quite figure out why it won't load the file. I imagine it is a permission thing(?), because it will load files on C: and public users folders, but not anything beyond.
*edited the code to better explain the issue
I also want to achieve the above function to load a video by its path at runtime. Have you got the solution?
Answer by JigneshKoradiya · Mar 19, 2015 at 10:51 PM
your video must be ".oggtheora" file if you dont have that convert it in it with "MiroConverterSetup"
using UnityEngine;
using System.Collections;
public class movies : MonoBehaviour {
public MovieTexture movTexture;// Use this for initialization
void Start ()
{
renderer.material.mainTexture = movTexture;
movTexture.Play();
movTexture.loop = true;
}
// Update is called once per frame
void Update ()
{
}
}
$$anonymous$$y video is .oggtheora. The question is not making the video play (it already does), but loading its path somewhere on disk and loading on the script.
Answer by zzd · Dec 20, 2016 at 08:19 AM
yes ,it is done ,while you check the loaded vedio www object .I get the same problem , and find a method to make it can play ,but that look like very unbelivivable , just Add a MovieTexture Tem value to save the movieTextrue ,like this: MoveTexture mt;
IEumarator xxxx() { www w = new ("xxx"); yield return w; mt = w.movie; yourPlayMaterial.texture = mt; mt.Play();
}