コード例 #1
0
    //-------------------------------------------------------------------------

    public bool StartVideo(string filename, bool loop, bool allowNativeFormat, bool useBT709)
    {
        Filename = filename;
        if (!string.IsNullOrEmpty(Filename))
        {
            if (_movieHandle < 0)
            {
                _movieHandle = AVProWindowsMediaPlugin.GetInstanceHandle();
            }

            // Note: we're marshaling the string to IntPtr as the pointer of type wchar_t
            System.IntPtr filenamePtr = Marshal.StringToHGlobalUni(Filename);
            if (AVProWindowsMediaPlugin.LoadMovie(_movieHandle, filenamePtr, loop, false, allowNativeFormat))
            {
                CompleteVideoLoad(useBT709);
            }
            else
            {
                Debug.LogWarning("[AVProWindowsMedia] Movie failed to load");
                Close();
            }
            Marshal.FreeHGlobal(filenamePtr);
        }
        else
        {
            Debug.LogWarning("[AVProWindowsMedia] No movie file specified");
            Close();
        }

        return(_movieHandle >= 0);
    }
コード例 #2
0
    //-------------------------------------------------------------------------

    public bool StartVideo(string filename, bool allowNativeFormat, bool useBT709, bool allowAudio, bool useAudioDelay, bool useAudioMixer, bool useDisplaySync, bool ignoreFlips, FilterMode textureFilterMode, TextureWrapMode textureWrapMode)
    {
        Filename = filename;
        if (!string.IsNullOrEmpty(Filename))
        {
            if (System.IO.File.Exists(filename))
            {
                if (_movieHandle < 0)
                {
                    _movieHandle = AVProWindowsMediaPlugin.GetInstanceHandle();
                }

                // Note: we're marshaling the string to IntPtr as the pointer of type wchar_t
                System.IntPtr filenamePtr = Marshal.StringToHGlobalUni(Filename);
                if (AVProWindowsMediaPlugin.LoadMovie(_movieHandle, filenamePtr, false, allowNativeFormat, allowAudio, useAudioDelay, useAudioMixer, useDisplaySync))
                {
                    CompleteVideoLoad(useBT709, ignoreFlips, textureFilterMode, textureWrapMode);
                }
                else
                {
                    Debug.LogError("[AVProWindowsMedia] Movie failed to load - do you have the required codecs installed?  See documentation for details.");
                    if (filename.ToLower().EndsWith(".mp4"))
                    {
                        Debug.LogError("[AVProWindowsMedia] For MP4 files you need an MP4 splitter such as Haali Media Splitter or GDCL.");
                        Debug.LogError("[AVProWindowsMedia] For HIGH profile H.264 videos you need to install an external H.264 decoder.  See documentation for details.");
                    }
                    Close();
                }
                Marshal.FreeHGlobal(filenamePtr);
            }
            else
            {
                Debug.LogError("[AVProWindowsMedia] File not found " + filename);
                Close();
            }
        }
        else
        {
            Debug.LogError("[AVProWindowsMedia] No movie file specified");
            Close();
        }

        return(_movieHandle >= 0);
    }
コード例 #3
0
    public bool StartAudio(string filename)
    {
        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.LoadMovie(_movieHandle, filenamePtr, false, false, true, false, false, false))
            {
                Volume          = _volume;
                DurationSeconds = AVProWindowsMediaPlugin.GetDurationSeconds(_movieHandle);

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

        return(_movieHandle >= 0);
    }