Example #1
0
    public bool Update(bool force)
    {
        bool updated = false;

        if (_movieHandle >= 0)
        {
            // Check for failing of asynchronous movie loading
            if (!AVProQuickTimePlugin.IsMovieLoadable(_movieHandle))
            {
                Debug.LogWarning("[AVProQuickTime] Unable to load movie: " + Filename);
                Close();
                return(false);
            }

            if (IsPrepared)
            {
                AVProQuickTimePlugin.Update(_movieHandle);

                if (IsVisual)
                {
                    updated = true;
                    if (_formatConverter != null)
                    {
                        updated = _formatConverter.Update();
                                                #if UNITY_EDITOR
                        if (updated)
                        {
                            UpdateFPS();
                        }
                                                #endif
                    }
                }
            }
            else
            {
                if (AVProQuickTimePlugin.IsMoviePropertiesLoaded(_movieHandle))
                {
                    PrepareMovie();
                }
            }

            // If we're streaming a video, the resolution could change
            if (_movieSource == AVProQuickTimePlugin.MovieSource.URL && _formatConverter != null)
            {
                int newWidth  = AVProQuickTimePlugin.GetWidth(_movieHandle);
                int newHeight = AVProQuickTimePlugin.GetHeight(_movieHandle);
                if (Width != newWidth || Height != newHeight)
                {
                    Width  = newWidth;
                    Height = newHeight;
                    _formatConverter.Resize(newWidth, newHeight);
                }
            }
        }

        return(updated);
    }
    public bool Update(bool force)
    {
        bool updated = false;

        if (_movieHandle >= 0)
        {
            // Check for failing of asynchronous movie loading
            if (!AVProQuickTimePlugin.IsMovieLoadable(_movieHandle))
            {
                Debug.LogWarning("[AVProQuickTime] Unable to load movie: " + Filename);
                Close();
                return(false);
            }

            if (IsPrepared)
            {
                AVProQuickTimePlugin.Update(_movieHandle);

                //if (!IsPaused)
                {
                    bool nextFrameReady = false;

                    if (AVProQuickTimeManager.Instance.TextureConversionMethod == AVProQuickTimeManager.ConversionMethod.Unity4 ||
                        AVProQuickTimeManager.Instance.TextureConversionMethod == AVProQuickTimeManager.ConversionMethod.Unity35_OpenGL)
                    {
                        nextFrameReady = true;
                    }
                    else
                    {
                        /*if (!force && IsVisual)
                         * {
                         *      //nextFrameReady = AVProQuickTimePlugin.IsNextFrameReadyForGrab(_movieHandle);
                         * }*/

                        uint qtFrame = AVProQuickTimePlugin.GetNumFramesDrawn(_movieHandle);
                        if (_lastFrameDrawn != qtFrame)
                        {
                            nextFrameReady  = true;
                            _lastFrameDrawn = qtFrame;
                        }
                    }
                    if (nextFrameReady && IsVisual)
                    {
                        updated = true;
                        if (_formatConverter != null)
                        {
                            updated = _formatConverter.Update();
                                                        #if UNITY_EDITOR
                            if (updated)
                            {
                                UpdateFPS();
                            }
                                                        #endif
                        }
                    }
                }
            }
            else
            {
                if (AVProQuickTimePlugin.IsMoviePropertiesLoaded(_movieHandle))
                {
                    PrepareMovie();
                }
            }
        }

        return(updated);
    }