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); }
private bool PrepareMovie() { if (_movieSource != AVProQuickTimePlugin.MovieSource.Memory) { if (!AVProQuickTimePlugin.LoadMovieProperties(_movieHandle)) { Debug.LogWarning("[AVProQuickTime] Failed loading movie properties"); Close(); return(false); } } AVProQuickTimePlugin.SetVolume(_movieHandle, _volume); AVProQuickTimePlugin.SetAudioBalance(_movieHandle, _audioBalance); Width = AVProQuickTimePlugin.GetWidth(_movieHandle); Height = AVProQuickTimePlugin.GetHeight(_movieHandle); FrameCount = (uint)(AVProQuickTimePlugin.GetFrameCount(_movieHandle)); DurationSeconds = AVProQuickTimePlugin.GetDurationSeconds(_movieHandle); FrameRate = AVProQuickTimePlugin.GetFrameRate(_movieHandle); PixelFormat = (AVProQuickTimePlugin.PixelFormat)AVProQuickTimePlugin.GetFramePixelFormat(_movieHandle); IsPrepared = true; PlayState = PlaybackState.Loaded; Debug.Log("[AVProQuickTime] loaded movie " + Filename + "[" + Width + "x" + Height + " @ " + FrameRate + "hz] " + PixelFormat.ToString() + " " + DurationSeconds + " sec " + FrameCount + " frames"); // Movie may not be visual, it could be audio so check width and height if (Width > 0 && Height > 0) { if (Width <= 4096 && Height <= 4096) { if (PixelFormat != AVProQuickTimePlugin.PixelFormat.Unknown) { IsVisual = true; if (_formatConverter == null) { _formatConverter = new AVProQuickTimeFormatConverter(); } if (!_formatConverter.Build(_movieHandle, Width, Height, PixelFormat, _yuvHD, false, true)) { Debug.LogWarning("[AVProQuickTime] unable to convert video format"); Width = Height = 0; if (_formatConverter != null) { _formatConverter.Dispose(); _formatConverter = null; } } } else { Debug.LogWarning("[AVProQuickTime] unknown video format"); Width = Height = 0; if (_formatConverter != null) { _formatConverter.Dispose(); _formatConverter = null; } } } else { Debug.LogError("[AVProQuickTime] Movie resolution is too large"); Width = Height = 0; if (_formatConverter != null) { _formatConverter.Dispose(); _formatConverter = null; } } } else { // No video frame found, must be audio? Width = Height = 0; if (_formatConverter != null) { _formatConverter.Dispose(); _formatConverter = null; } } return(true); }