Hello,
I´m trying to play a video from a webpage. I tried to do it with a MovieTexture through creating a plane, giving a guiTexture to it and giving it the following script:
using UnityEngine;
using System.Collections;
public class ViewStream : MonoBehaviour {
GameObject myGameObject;
public WWW wwwData;
public string url = "http://www.youtube.com/watch?v=tkwwrTW7BQU&feature=g-vrec";
// Use this for initialization
void Start () {
wwwData = new WWW(url);
//guiTexture.texture = wwwData.movie;
renderer.material.mainTexture = wwwData.movie;
}
// Update is called once per frame
void Update () {
//MovieTexture m = guiTexture.texture as MovieTexture;
MovieTexture m = renderer.material.mainTexture as MovieTexture;
if(m.isReadyToPlay==true){
print ("ready to play");
}else{
print ("not ready to play");
}
if (!m.isPlaying && m.isReadyToPlay){
m.Play();
}
}
}
First I tried it with the guiTexture. After it didn´t work I tried to use the main material to play it. But this failed also.
In the log is written “not ready to play” all the time.
Can anyone tell me what I´m doing wrong? Does the video file need to have a special format, is my URL not correct or anything else?
Thank you in advance.