Esempio n. 1
0
    private void CompleteVideoLoad(bool useBT709)
    {
        // Gather properties
        Volume          = _volume;
        Width           = AVProWindowsMediaPlugin.GetWidth(_movieHandle);
        Height          = AVProWindowsMediaPlugin.GetHeight(_movieHandle);
        FrameRate       = AVProWindowsMediaPlugin.GetFrameRate(_movieHandle);
        DurationSeconds = AVProWindowsMediaPlugin.GetDurationSeconds(_movieHandle);
        DurationFrames  = AVProWindowsMediaPlugin.GetDurationFrames(_movieHandle);

        AVProWindowsMediaPlugin.VideoFrameFormat sourceFormat = (AVProWindowsMediaPlugin.VideoFrameFormat)AVProWindowsMediaPlugin.GetFormat(_movieHandle);
        Debug.Log(string.Format("[AVProWindowsMedia] Loaded video '{0}' ({1}x{2} @ {3} fps) {4} frames, {5} seconds - format: {6}", Filename, Width, Height, FrameRate.ToString("F2"), DurationFrames, DurationSeconds.ToString("F2"), sourceFormat.ToString()));

        // Create format converter
        if (Width < 0 || Width > 4096 || Height < 0 || Height > 4096)
        {
            Debug.LogWarning("[AVProWindowsMedia] invalid width or height");
            Width = Height = 0;
            if (_formatConverter != null)
            {
                _formatConverter.Dispose();
                _formatConverter = null;
            }
        }
        else
        {
            bool isTopDown = AVProWindowsMediaPlugin.IsOrientedTopDown(_movieHandle);

            if (_formatConverter == null)
            {
                _formatConverter = new AVProWindowsMediaFormatConverter();
            }
            if (!_formatConverter.Build(_movieHandle, Width, Height, sourceFormat, useBT709, false, isTopDown))
            {
                Debug.LogWarning("[AVProWindowsMedia] unable to convert video format");
                Width = Height = 0;
                if (_formatConverter != null)
                {
                    _formatConverter.Dispose();
                    _formatConverter = null;
                }
                // TODO: close movie here?
            }
        }

        PreRoll();
    }
Esempio n. 2
0
    public bool StartAudio(string filename, bool loop)
    {
        Filename = filename;
        Width    = Height = 0;
        if (!string.IsNullOrEmpty(Filename))
        {
            if (_movieHandle < 0)
            {
                _movieHandle = AVProWindowsMediaPlugin.GetInstanceHandle();
            }

            if (_formatConverter != null)
            {
                _formatConverter.Dispose();
                _formatConverter = null;
            }

            // Note: we're marshaling the string to IntPtr as the pointer of type wchar_t
            System.IntPtr filenamePtr = Marshal.StringToHGlobalUni(Filename);
            if (AVProWindowsMediaPlugin.LoadAudio(_movieHandle, filenamePtr, loop))
            {
                Volume          = _volume;
                DurationSeconds = AVProWindowsMediaPlugin.GetDurationSeconds(_movieHandle);

                Debug.Log("[AVProWindowsMedia] Loaded audio " + Filename + " " + DurationSeconds.ToString("F2") + " sec");
            }
            else
            {
                Debug.LogWarning("[AVProWindowsMedia] Movie failed to load");
                Close();
            }
            Marshal.FreeHGlobal(filenamePtr);
        }
        else
        {
            Debug.LogWarning("[AVProWindowsMedia] No movie file specified");
            Close();
        }

        return(_movieHandle >= 0);
    }
Esempio n. 3
0
    private void CompleteVideoLoad(bool useBT709, bool ignoreFlips, FilterMode textureFilterMode, TextureWrapMode textureWrapMode)
    {
        RequiresFlipY = false;
        Loop          = false;
        Volume        = _volume;

        // Gather properties
        Width           = AVProWindowsMediaPlugin.GetWidth(_movieHandle);
        Height          = AVProWindowsMediaPlugin.GetHeight(_movieHandle);
        FrameRate       = AVProWindowsMediaPlugin.GetFrameRate(_movieHandle);
        DurationSeconds = AVProWindowsMediaPlugin.GetDurationSeconds(_movieHandle);
        DurationFrames  = AVProWindowsMediaPlugin.GetDurationFrames(_movieHandle);

        AVProWindowsMediaPlugin.VideoFrameFormat sourceFormat = (AVProWindowsMediaPlugin.VideoFrameFormat)AVProWindowsMediaPlugin.GetFormat(_movieHandle);

        if (AVProWindowsMediaManager.Instance._logVideoLoads)
        {
            Debug.Log(string.Format("[AVProWindowsMedia] Loaded video '{0}' ({1}x{2} @ {3} fps) {4} frames, {5} seconds - format: {6}", Filename, Width, Height, FrameRate.ToString("F2"), DurationFrames, DurationSeconds.ToString("F2"), sourceFormat.ToString()));
        }

        // Create format converter
        bool hasVideo = (Width > 0 && Width <= 8192 || Height > 0 && Height <= 8192);

        if (!hasVideo)
        {
            Width = Height = 0;
            if (_formatConverter != null)
            {
                _formatConverter.Dispose();
                _formatConverter = null;
            }
        }
        else
        {
            bool isTopDown = AVProWindowsMediaPlugin.IsOrientedTopDown(_movieHandle);

            if (_formatConverter == null)
            {
                _formatConverter = new AVProWindowsMediaFormatConverter();
            }

            bool flipX = false;
            bool flipY = isTopDown;
            if (ignoreFlips)
            {
                if (flipY)
                {
                    RequiresFlipY = true;
                }

                flipX = flipY = false;
            }
            if (!_formatConverter.Build(_movieHandle, Width, Height, sourceFormat, useBT709, flipX, flipY, textureFilterMode, textureWrapMode))
            {
                Debug.LogError("[AVProWindowsMedia] unable to convert video format");
                Width = Height = 0;
                if (_formatConverter != null)
                {
                    _formatConverter.Dispose();
                    _formatConverter = null;
                    Close();
                }
            }
        }

        PreRoll();
    }