- Home /
WWW in Editor getting request with null attributes
I'm trying to write an editor-only script that will take a link to a streaming OGG video, download it, get the height/width and video name, then use that to build a screen and RenderTexture of the same size as the video.
I've gotten every part of it seemingly working, it spends about 10-15 seconds downloading a movie, but if I check the returned movie, it's name is null and it's size is 16 by 16. I've checked the video streams I've been using for this, and they work fine, so it must be something with the code.
Here is the actual download IEnumerator (C#), it takes the actual address from a function elsewhere in the class (the URL comes through fine).
IEnumerator DownloadVideo(string videoURL)
{
Debug.Log("Loading " + videoURL + " ...");
request = new WWW(videoURL);
while (!request.isDone)
{
EditorUtility.DisplayProgressBar("Downloading video " + (currentNum + 1), "Downloading " + request.progress.ToString("#0%") + "...", request.progress);
yield return null;
}
EditorUtility.ClearProgressBar();
if (request.error != null)
{
Debug.LogError(request.error);
yield break;
}
Debug.Log("Adding downloaded movie by name of \"" + request.movie.name + "\", with a file size of = " + request.size + ", and a Height:Width of = " + request.movie.height + ":" + request.movie.width);
GameObject screen = CreateScreen(request.movie, currentNum * 2);
Debug.Log("curretNum = " + currentNum);
SetupScreen(screen, streamingVideos[currentNum]);
currentNum += 1;
if (currentNum < streamingVideos.Count)
{
currentURL = streamingVideos[currentNum];
en = null;
}
else
run = false;
}
The long Debug Log will return: "Adding downloaded movie by name of "", with a file size of = 2864977, and a Height:Width of = 16:16" So it's getting an actual file with a size, and it takes about 10-15 seconds to download the movie usually, but the name shouldn't be "" nor should the height be 16:16, trying with another stream gets the same results (though a different file size).
I use a sort of manual Coroutine in the update to work the downloading with a GUI button setting run = true;
void Update()
{
if (!run)
{
if (en != null)
en = null;
return;
}
else
{
if (en == null && !string.IsNullOrEmpty(currentURL))
{
en = DownloadVideo(currentURL);
}
if (!en.MoveNext())
run = false;
}
}
Are there any obvious problems that stick out here or any ideas on what might be causing the null values to come through? I'm really stumped by this.
Answer by Zeno · Nov 30, 2011 at 11:12 PM
Turns out all I had to do was assign it to a MovieTexture variable then do movie.Play() and it worked.
Your answer
Follow this Question
Related Questions
Splash videos on android and iOS? 0 Answers
WWW.movie never get ready to play ? 0 Answers
Problem playing audio for streaming video 0 Answers
Black MovieTexture with Audio streaming on Mac? -1 Answers
Yielding with WWW in Editor 9 Answers