Пример #1
0
        protected override System.Collections.IEnumerator LoadTexture_YIELD(ResourceAsyncOperation asyncOperation, IImageComponent component, MovieItem movieItem, ResourceBase resource)
        {
            var filePath = resource.GetStreamPath();

            var task = new WWW(filePath);

            while (task.isDone == false)
            {
                asyncOperation.SetValues(isDone: false, progress: task.progress, asset: null);
                yield return(0);
            }

                        #if UNITY_5_6_OR_NEWER
            var movie = task.GetMovieTexture();
                        #else
            var movie = task.movie;
                        #endif

            asyncOperation.SetValues(isDone: false, progress: 1f, asset: movie);

            task.Dispose();
            task = null;
            System.GC.Collect();

            //Debug.LogWarning("GetTexture_YIELD: " + filePath + " :: " + movie.isReadyToPlay);

            while (movie.isReadyToPlay == false)
            {
                yield return(0);
            }

            asyncOperation.SetValues(isDone: true, progress: 1f, asset: movie);
        }
        protected override System.Collections.IEnumerator LoadTexture_YIELD(ResourceAsyncOperation asyncOperation, IImageComponent component, MovieItem movieItem, ResourceBase resource)
        {
            var  resourceId = resource.GetId();
            Item item;

            if (this.itemsByResourceId.TryGetValue(resourceId, out item) == false)
            {
                asyncOperation.SetValues(isDone: false, progress: 0.0f, asset: null);

                var resourcePath = resource.GetStreamPath(withFile: true);
                item = new Item(resourcePath);
                this.itemsByResourceId[resourceId] = item;
            }

            while (item.IsReady() == false)
            {
                if (item.IsError() == true)
                {
                    asyncOperation.SetValues(isDone: true, progress: 1f, asset: null);
                    yield break;
                }

                yield return(0);
            }

            asyncOperation.SetValues(isDone: true, progress: 1f, asset: item.GetMaterial());
        }
Пример #3
0
        protected override IEnumerator LoadTexture_YIELD(ResourceAsyncOperation asyncOperation, IImageComponent component, MovieItem movieItem, ResourceBase resource)
        {
            var streamPath = resource.GetStreamPath(withFile: false);

            var item = this.FindInstance(resource);

            if (item != null)
            {
                Debug.LogError("[MediaMovieModule] Already playing " + streamPath);
            }
            else
            {
                item = this.CreatePlayerInstance(movieItem);
                this.playingInstances.Add(streamPath, item);
                this.counter = this.playingInstances.Count;
            }

            yield return(false);

            if (item.Load(streamPath) == false)
            {
                asyncOperation.SetValues(isDone: true, progress: 1f, asset: null);
            }
            else
            {
                while (item.IsReady() == false)
                {
                    yield return(false);
                }

                asyncOperation.SetValues(isDone: true, progress: 1f, asset: item.GetTexture());
            }
        }
		protected override IEnumerator LoadTexture_YIELD(ResourceAsyncOperation asyncOperation, IImageComponent component, ResourceBase resource) {

			var filePath = resource.GetStreamPath();

			var task = new WWW(filePath);
			while (task.isDone == false) {

				asyncOperation.SetValues(isDone: false, progress: task.progress, asset: null);
				yield return false;

			}

			var movie = task.movie;

			asyncOperation.SetValues(isDone: false, progress: 1f, asset: movie);

			task.Dispose();
			task = null;
			System.GC.Collect();

			//Debug.LogWarning("GetTexture_YIELD: " + filePath + " :: " + movie.isReadyToPlay);

			while (movie.isReadyToPlay == false) {

				yield return false;

			}

			asyncOperation.SetValues(isDone: true, progress: 1f, asset: movie);

		}
Пример #5
0
        protected override IEnumerator LoadTexture_YIELD(ResourceAsyncOperation asyncOperation, IImageComponent component, ResourceBase resource)
        {
            var filePath = resource.GetStreamPath();

            if (filePath.Contains("://") == false)
            {
                filePath = "file:///" + filePath;
            }

            var task = new WWW(filePath);

            while (task.isDone == false)
            {
                asyncOperation.SetValues(isDone: false, progress: task.progress, asset: null);
                yield return(false);
            }

            var movie = task.movie;

            asyncOperation.SetValues(isDone: false, progress: 1f, asset: movie);

            task.Dispose();
            task = null;
            System.GC.Collect();

            //Debug.LogWarning("GetTexture_YIELD: " + filePath + " :: " + movie.isReadyToPlay);

            while (movie.isReadyToPlay == false)
            {
                yield return(false);
            }

            asyncOperation.SetValues(isDone: true, progress: 1f, asset: movie);
        }
Пример #6
0
        protected override System.Collections.IEnumerator LoadTexture_YIELD(ResourceAsyncOperation asyncOperation, IImageComponent component, MovieItem movieItem, ResourceBase resource)
        {
            var streamPath = resource.GetStreamPath(withFile: false);

            var instance = this.FindInstance(resource);

            if (instance != null)
            {
                if (UnityEngine.UI.Windows.Constants.LOGS_ENABLED == true)
                {
                    UnityEngine.Debug.LogError("[MediaMovieModule] Already playing " + streamPath);
                }
            }
            else
            {
                instance = new Item(streamPath);
                this.playingInstances.Add(streamPath, instance);
                this.counter = this.playingInstances.Count;
            }

            yield return(0);

            while (true)
            {
                if (instance.IsFailed() == true)
                {
                    asyncOperation.SetValues(isDone: true, progress: 1f, asset: null);
                    break;
                }
                else if (instance.IsReady() == true)
                {
                    asyncOperation.SetValues(isDone: true, progress: 1f, asset: instance.GetTexture());
                    break;
                }
                else
                {
                    yield return(0);
                }
            }
        }
    public void Load(ResourceAsyncOperation asyncOperation, string filepath)
    {
        if (this.videoReady == true)
        {
            asyncOperation.SetValues(isDone: true, progress: 1f, asset: this.videoTexture);
            //callback.Invoke();
            return;
        }

        Debug.Log("LOAD VideoPlayerInterface: " + this.filepath);
        this.filepath        = filepath;
        this.waitingForLoad += () => {
            asyncOperation.SetValues(isDone: true, progress: 1f, asset: this.videoTexture);
            //if (callback != null) callback.Invoke();
        };

        if (VideoPlayer_Load(this.filepath) == true)
        {
            asyncOperation.SetValues(isDone: true, progress: 1f, asset: null);
            Debug.Log("Failed to load: " + this.filepath);
        }
    }
Пример #8
0
        protected override System.Collections.IEnumerator LoadTexture_YIELD(ResourceAsyncOperation asyncOperation, IImageComponent component, MovieItem movieItem, ResourceBase resource)
        {
            var resourceId = resource.GetId();
            //if (UnityEngine.UI.Windows.Constants.LOGS_ENABLED == true) UnityEngine.Debug.Log("LoadTexture_YIELD: " + resourceId);
            Item item;

            if (this.itemsByResourceId.TryGetValue(resourceId, out item) == false)
            {
                asyncOperation.SetValues(isDone: false, progress: 0.0f, asset: null);

                bool withFile = true;
#if UNITY_STANDALONE_WIN || UNITY_STANDALONE_LINUX
                withFile = false;
#endif
                var resourcePath = resource.GetStreamPath(withFile);
                //if (UnityEngine.UI.Windows.Constants.LOGS_ENABLED == true) UnityEngine.Debug.Log("NEW LoadTexture_YIELD PATH: " + resourcePath);
                item = new Item(this.videoPlayerProto, resourcePath);
                this.itemsByResourceId[resourceId] = item;
            }

            while (item.IsReady() == false)
            {
                if (item.IsError() == true)
                {
                    //if (UnityEngine.UI.Windows.Constants.LOGS_ENABLED == true) UnityEngine.Debug.Log("NEW LoadTexture_YIELD ERROR: " + item.GetTexture());
                    asyncOperation.SetValues(isDone: true, progress: 1f, asset: null);
                    yield break;
                }

                yield return(0);
            }

            yield return(0);

            //if (UnityEngine.UI.Windows.Constants.LOGS_ENABLED == true) UnityEngine.Debug.Log("NEW LoadTexture_YIELD LOAD: " + item.IsError() + " :: " + item.GetTexture());
            asyncOperation.SetValues(isDone: true, progress: 1f, asset: item.GetTexture());
        }
Пример #9
0
        protected override System.Collections.Generic.IEnumerator <byte> LoadTexture_YIELD(ResourceAsyncOperation asyncOperation, IImageComponent component, ResourceBase resource)
        {
            var filePath = resource.GetStreamPath();

            //if (UnityEngine.UI.Windows.Constants.LOGS_ENABLED == true) UnityEngine.Debug.Log("LOADING: " + filePath);

            Item item     = null;
            var  instance = this.FindInstance(resource);

            if (instance != null)
            {
                item = instance;
            }
            else
            {
                item = this.CreatePlayerInstance();
                this.playingInstances.Add(filePath, item);
            }

            //if (UnityEngine.UI.Windows.Constants.LOGS_ENABLED == true) UnityEngine.Debug.Log ("DONE: " + item.material);
            asyncOperation.SetValues(isDone: true, progress: 1f, asset: item.material);

            yield return(0);
        }
Пример #10
0
        protected override IEnumerator LoadTexture_YIELD(ResourceAsyncOperation asyncOperation, IImageComponent component, ResourceBase resource)
        {
            var filePath = resource.GetStreamPath();

            //Debug.Log("LOADING: " + filePath);

            Item item     = null;
            var  instance = this.FindInstance(resource);

            if (instance != null)
            {
                item = instance;
            }
            else
            {
                item = this.CreatePlayerInstance();
                this.playingInstances.Add(filePath, item);
            }

            //Debug.Log ("DONE: " + item.material);
            asyncOperation.SetValues(isDone: true, progress: 1f, asset: item.material);

            yield return(false);
        }
	public void Load(ResourceAsyncOperation asyncOperation, string filepath) {
		
		if (this.videoReady == true) {

			asyncOperation.SetValues(isDone: true, progress: 1f, asset: this.videoTexture);
			//callback.Invoke();
			return;

		}

		this.filepath = filepath;

		Debug.Log("LOAD VideoPlayerInterface: " + this.filepath);
		this.waitingForLoad += () => {

			Debug.Log("VideoPlayerInterface: waitingForLoad" + this.filepath);
			asyncOperation.SetValues(isDone: true, progress: 1f, asset: this.videoTexture);
			//if (callback != null) callback.Invoke();

		};

		if (VideoPlayer_Load(this.filepath) == false) {

			asyncOperation.SetValues(isDone: true, progress: 1f, asset: null);
			Debug.Log("Failed to load: " + this.filepath);

		}

	}