コード例 #1
0
        private void MediaPlayerInit()
        {
            _vlcObj = _wrapper.ExpandedLibVLCNew(_arguments);

            if (_vlcObj == IntPtr.Zero)
            {
                throw new Exception("Can't create new libVLC object instance");
            }

            _playerObj = _wrapper.ExpandedMediaPlayerNew(_vlcObj);

            if (_playerObj == IntPtr.Zero)
            {
                throw new Exception("Can't create new media player object instance");
            }

            _eventManagerPtr = _wrapper.ExpandedEventManager(_playerObj);
            _eventHandlerPtr = _wrapper.NativeMediaPlayerEventCallback();
            EventsAttach(_eventManagerPtr, _eventHandlerPtr);

            _eventManager = new PlayerManagerEvents(_monoObject, this);
            _eventManager.PlayerPlayingListener += OnPlayerPlaying;
            _eventManager.PlayerPausedListener  += OnPlayerPaused;

            if (_logDetail != LogLevels.Disable)
            {
                _wrapper.ExpandedLogSet(_vlcObj, _wrapper.NativeGetLogMessageCallback(), new IntPtr(_wrapper.NativeIndex));
            }

            _logManager                     = new PlayerManagerLogs(_monoObject, this);
            _logManager.LogDetail           = _logDetail;
            _logManager.LogMessageListener += _logListener;

            _lockPtr        = _wrapper.NativeGetVideoLockCallback();
            _displayPtr     = _wrapper.NativeGetVideoDisplayCallback();
            _formatSetupPtr = _wrapper.NativeGetVideoFormatCallback();

            _audioFormatPtr = _wrapper.NativeGetAudioSetupCallback();
            _audioPlayPtr   = _wrapper.NativeGetAudioPlayCallback();

            _wrapper.ExpandedVideoSetCallbacks(_playerObj, _lockPtr, IntPtr.Zero, _displayPtr, new IntPtr(_wrapper.NativeIndex));

            if (_videoBuffer == null)
            {
                _wrapper.ExpandedVideoSetFormatCallbacks(_playerObj, _formatSetupPtr, IntPtr.Zero);
            }
            else
            {
                _wrapper.ExpandedVideoSetFormat(_playerObj, _videoBuffer.Chroma, (uint)_videoBuffer.Width, (uint)_videoBuffer.Height, (uint)_videoBuffer.Pitch);
            }

            if (_audioManager != null && _audioManager.IsValid)
            {
                _wrapper.ExpandedAudioSetFormatCallbacks(_playerObj, _audioFormatPtr, IntPtr.Zero);
                _wrapper.ExpandedAudioSetCallbacks(_playerObj, _audioPlayPtr, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, new IntPtr(_wrapper.NativeIndex));
                _wrapper.NativeSetAudioParams(2, AudioSettings.outputSampleRate);
            }

            _mediaStats = new MediaStats();
        }
コード例 #2
0
        private void MediaPlayerInit()
        {
            _vlcObj = _wrapper.ExpandedLibVLCNew(_arguments);

            if (_vlcObj == IntPtr.Zero)
            {
                throw new Exception("Can't create new libVLC object instance");
            }

            _playerObj = _wrapper.ExpandedMediaPlayerNew(_vlcObj);

            if (_playerObj == IntPtr.Zero)
            {
                throw new Exception("Can't create new media player object instance");
            }

            _eventManagerPtr = _wrapper.ExpandedEventManager(_playerObj);
            _eventHandlerPtr = _wrapper.NativeMediaPlayerEventCallback();
            EventsAttach(_eventManagerPtr, _eventHandlerPtr);

            _eventManager = new PlayerManagerEvents(_monoObject, this);
            _eventManager.PlayerPlayingListener += OnPlayerPlaying;
            _eventManager.PlayerPausedListener  += OnPlayerPaused;

            if (_logDetail != LogLevels.Disable)
            {
                _wrapper.ExpandedLogSet(_vlcObj, _wrapper.NativeGetLogMessageCallback(), new IntPtr(_wrapper.NativeIndex));
            }

            _logManager                     = new PlayerManagerLogs(_monoObject, this);
            _logManager.LogDetail           = _logDetail;
            _logManager.LogMessageListener += _logListener;

            _lockPtr        = _wrapper.NativeGetVideoLockCallback();
            _displayPtr     = _wrapper.NativeGetVideoDisplayCallback();
            _formatSetupPtr = _wrapper.NativeGetVideoFormatCallback();

            _audioFormatPtr = _wrapper.NativeGetAudioSetupCallback();
            _audioPlayPtr   = _wrapper.NativeGetAudioPlayCallback();

            _wrapper.ExpandedVideoSetCallbacks(_playerObj, _lockPtr, IntPtr.Zero, _displayPtr, new IntPtr(_wrapper.NativeIndex));

            if (_options.FixedVideoSize == Vector2.zero)
            {
                _wrapper.ExpandedVideoSetFormatCallbacks(_playerObj, _formatSetupPtr, IntPtr.Zero);
            }
            else
            {
                _wrapper.ExpandedVideoSetFormat(_playerObj, PlayerBufferVideo.Chroma, (int)_options.FixedVideoSize.x, (int)_options.FixedVideoSize.y, PlayerBufferVideo.CalculatePitch((int)_options.FixedVideoSize.x));
            }

            _manageBufferSizeCallback = InitBufferSize;
            _wrapper.NativeSetBufferSizeCallback(Marshal.GetFunctionPointerForDelegate(_manageBufferSizeCallback));

            if (_audioManager != null && _audioManager.IsValid)
            {
                _wrapper.ExpandedAudioSetFormatCallbacks(_playerObj, _audioFormatPtr, IntPtr.Zero);
                _wrapper.ExpandedAudioSetCallbacks(_playerObj, _audioPlayPtr, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, new IntPtr(_wrapper.NativeIndex));
                _wrapper.NativeSetAudioParams(2, AudioSettings.outputSampleRate);
            }

            _mediaStats = new MediaStats();
        }