public void Update() { if (Status < StreamingVideoStatus.ReadyToPlay && IsReadyToPlay) { Status = StreamingVideoStatus.ReadyToPlay; } if (Status == StreamingVideoStatus.Playing && Math.Abs(Time - Duration) < 0.1f) { Status = StreamingVideoStatus.Done; } if (_videoTexture == null || !_videoTexture.isReadable) { return; } var width = WebGlStreamingVideoTextureWidth(_instance); var height = WebGlStreamingVideoTextureHeight(_instance); if (width != _videoTexture.width || height != _videoTexture.height) { _videoTexture.Resize(width, height, TextureFormat.RGBA32, false); _videoTexture.Apply(); } WebGlStreamingVideoTextureUpdate(_instance, _videoTexture.GetNativeTexturePtr().ToInt32()); }
public void Play() { if (!IsReadyToPlay) { return; } WebGlStreamingVideoTexturePlay(_instance); Status = StreamingVideoStatus.Playing; }
private void LoadUrl(string url) { m_url = url; m_status = StreamingVideoStatus.Unknown; var fullyQualifiedUrl = "file://" + Application.streamingAssetsPath + "/" + m_url; Debug.Log("Creating www object with url: " + fullyQualifiedUrl); m_www = new WWW(fullyQualifiedUrl); }
public void Play() { if (IsReadyToPlay) { m_movieTexture.Play(); m_audioSource.Play(); m_status = StreamingVideoStatus.Playing; } }
public void Stop() { if (IsReadyToPlay) { m_status = StreamingVideoStatus.Done; m_movieProgress = 0.0f; m_movieTexture.Stop(); m_audioSource.Stop(); } }
public void Pause() { if (IsPlaying) { m_status = StreamingVideoStatus.Paused; m_movieTexture.Pause(); m_audioSource.Pause(); } }
public void Update() { _movieTexture.Update(); if (_status < StreamingVideoStatus.ReadyToPlay && IsReadyToPlay) { _status = StreamingVideoStatus.ReadyToPlay; } if (_status == StreamingVideoStatus.Playing && _movieTexture.time == _movieTexture.duration) { _status = StreamingVideoStatus.Done; } }
public void Update() { _movieTexture.Update(); if (_status < StreamingVideoStatus.ReadyToPlay && IsReadyToPlay) { _status = StreamingVideoStatus.ReadyToPlay; } if (_status == StreamingVideoStatus.Playing && _movieTexture.time == _movieTexture.duration) { _status = StreamingVideoStatus.Done; } }
public NativeStreamingVideoPlugin(string url, GameObject gameObject) { DebugStatus = "Creating WWW for ogv"; _gameObject = gameObject; _status = StreamingVideoStatus.Unknown; _url = url; var fullyQualifiedUrl = _url.StartsWith("http://") ? _url : Application.streamingAssetsPath + "/" + _url; Debug.Log("Creating www object with url: " + fullyQualifiedUrl); _www = new WWW(fullyQualifiedUrl); _audioSource = _gameObject.GetComponent<AudioSource>(); if (_audioSource == null) { _audioSource = _gameObject.AddComponent<AudioSource>(); } }
public WebGlStreamingVideoPlugin(string url, GameObject gameObject) { Status = StreamingVideoStatus.Unknown; Url = url; _instance = WebGlStreamingVideoTextureCreate(url); _videoTexture = new Texture2D(1, 1, TextureFormat.RGBA32, false) { wrapMode = TextureWrapMode.Clamp }; _videoTexture.SetPixel(0, 0, Color.black); _videoTexture.Apply(); gameObject.GetComponent <Renderer>().material.mainTexture = _videoTexture; }
private void HandleLoading() { if (m_movieTexture) { if (m_movieTexture.isReadyToPlay) { if (m_audioClip != null) { if (m_audioClip.loadState == AudioDataLoadState.Loaded) { m_renderer.material.mainTexture = m_movieTexture; m_audioSource.clip = m_audioClip; m_status = StreamingVideoStatus.ReadyToPlay; } } else { DebugStatus = "Could not retrieve audio from url: " + Url; m_status = StreamingVideoStatus.Error; } } } else if (m_www.error != null) { Debug.Log("www.error: " + m_www.error); DebugStatus = m_www.error; m_status = StreamingVideoStatus.Error; } else if (m_www.isDone) { m_movieTexture = m_www.movie; if (m_movieTexture) { m_movieTexture = m_www.movie; m_audioClip = m_movieTexture.audioClip; } else { DebugStatus = "Could not retrieve video from url: " + Url; m_status = StreamingVideoStatus.Error; } } }
public void Update() { m_movieTexture.Update(); if (m_isStopping) { if (IsReadyToPlay) { Debug.Log("Update() stopping"); m_isStopping = false; Pause(); } } if (_status < StreamingVideoStatus.ReadyToPlay && IsReadyToPlay) { _status = StreamingVideoStatus.ReadyToPlay; } else if (_status == StreamingVideoStatus.Playing && m_movieTexture.hasEnded) { _status = StreamingVideoStatus.Done; } }
public void Pause() { WebGlStreamingVideoTexturePause(_instance); Status = StreamingVideoStatus.Paused; }
public void Update() { var prevStatus = _status; switch (prevStatus) { case StreamingVideoStatus.Unknown: case StreamingVideoStatus.Loading: if (_www != null) { if (_www.error != null) { DebugStatus = _www.error; _status = StreamingVideoStatus.Error; } bool movieReady = false; bool audioReady = true; if (_www.movie != null && _www.movie.isReadyToPlay) { Debug.Log("Movie ready"); movieReady = true; } //if (_www.movie.audioClip != null) //{ // Debug.Log("Audio Clip not null"); // audioReady = false; // if (_www.movie.audioClip.loadState == AudioDataLoadState.Loaded) // { // Debug.Log("Audio Clip Ready"); // audioReady = true; // } //} if (movieReady && audioReady) { Debug.Log("Ready To Play"); _status = StreamingVideoStatus.ReadyToPlay; _movieTexture = _www.movie; _audioClip = _movieTexture.audioClip; } else { _status = StreamingVideoStatus.Loading; } } break; case StreamingVideoStatus.ReadyToPlay: if (_movieTexture.isPlaying) { _status = StreamingVideoStatus.Playing; } break; case StreamingVideoStatus.Playing: if (!_movieTexture.isPlaying) { _status = StreamingVideoStatus.Done; } break; } }
public void Update() { var prevStatus = _status; switch (prevStatus) { case StreamingVideoStatus.Unknown: case StreamingVideoStatus.Loading: if (_www != null) { if (_www.error != null) { DebugStatus = _www.error; _status = StreamingVideoStatus.Error; } bool movieReady = false; bool audioReady = true; if (_www.movie != null && _www.movie.isReadyToPlay) { Debug.Log("Movie ready"); movieReady = true; } //if (_www.movie.audioClip != null) //{ // Debug.Log("Audio Clip not null"); // audioReady = false; // if (_www.movie.audioClip.loadState == AudioDataLoadState.Loaded) // { // Debug.Log("Audio Clip Ready"); // audioReady = true; // } //} if (movieReady && audioReady) { Debug.Log("Ready To Play"); _status = StreamingVideoStatus.ReadyToPlay; _movieTexture = _www.movie; _audioClip = _movieTexture.audioClip; } else { _status = StreamingVideoStatus.Loading; } } break; case StreamingVideoStatus.ReadyToPlay: if (_movieTexture.isPlaying) { _status = StreamingVideoStatus.Playing; } break; case StreamingVideoStatus.Playing: if (!_movieTexture.isPlaying) { _status = StreamingVideoStatus.Done; } break; } }