Ejemplo n.º 1
0
 public void SetVideoDecodeCallback(VideoLockCallback lockCallback, VideoUnlockCallback unlockCallback, VideoDisplayCallback displayCallback, IntPtr userData)
 {
     _setVideoCallbackFunction.Delegate(InstancePointer, lockCallback, unlockCallback, displayCallback, userData);
 }
Ejemplo n.º 2
0
        public void Initialize(String libVlcPath, String[] libVlcOption)
        {
            if (ApiManager.IsInitialized)
                return;

            ApiManager.Initialize(libVlcPath, libVlcOption);
            VlcMediaPlayer = ApiManager.Vlc.CreateMediaPlayer();
            VlcMediaPlayer.PositionChanged += VlcMediaPlayerPositionChanged;
            VlcMediaPlayer.TimeChanged += VlcMediaPlayerTimeChanged;
            VlcMediaPlayer.Playing += VlcMediaPlayerStateChanged;
            VlcMediaPlayer.Paused += VlcMediaPlayerStateChanged;
            VlcMediaPlayer.Stoped += VlcMediaPlayerStateChanged;
            VlcMediaPlayer.Opening += VlcMediaPlayerStateChanged;
            VlcMediaPlayer.Buffering += VlcMediaPlayerStateChanged;
            VlcMediaPlayer.EndReached += VlcMediaPlayerStateChanged;
            VlcMediaPlayer.SeekableChanged += VlcMediaPlayerSeekableChanged;
            VlcMediaPlayer.LengthChanged += VlcMediaPlayerLengthChanged;

            _lockCallback = VideoLockCallback;
            _unlockCallback = VideoUnlockCallback;
            _displayCallback = VideoDisplayCallback;
            _formatCallback = VideoFormatCallback;
            _cleanupCallback = VideoCleanupCallback;

            _lockCallbackHandle = GCHandle.Alloc(_lockCallback);
            _unlockCallbackHandle = GCHandle.Alloc(_unlockCallback);
            _displayCallbackHandle = GCHandle.Alloc(_displayCallback);
            _formatCallbackHandle = GCHandle.Alloc(_formatCallback);
            _cleanupCallbackHandle = GCHandle.Alloc(_cleanupCallback);
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Initialize VLC player with path of LibVlc and options.
        /// </summary>
        /// <param name="libVlcPath"></param>
        /// <param name="libVlcOption"></param>
        public void Initialize(string libVlcPath, params string[] libVlcOption)
        {
            if (!ApiManager.IsInitialized)
            {
                ApiManager.Initialize(libVlcPath, libVlcOption);
            }

            if (VlcMediaPlayer != null)
            {
                throw new InvalidOperationException("VlcPlayer is been initialized.");
            }

            switch (CreateMode)
            {
            case PlayerCreateMode.NewVlcInstance:
                Vlc = new Vlc(libVlcOption);
                ApiManager.Vlcs.Add(Vlc);
                break;

            case PlayerCreateMode.Default:
            default:
                Vlc = ApiManager.DefaultVlc;
                break;
            }

            VlcMediaPlayer player = Vlc.CreateMediaPlayer();

            _lockCallback    = VideoLockCallback;
            _unlockCallback  = VideoUnlockCallback;
            _displayCallback = VideoDisplayCallback;
            _formatCallback  = VideoFormatCallback;
            _cleanupCallback = VideoCleanupCallback;
            //_audioSetupCallback = AudioFormatSetupCallback;
            //_audioCleanupCallback = AudioFormatCleanupCallback;
            //_audioPlayCallback = AudioPlayCallback;
            //_audioPauseCallback = AudioPauseCallback;
            //_audioResumeCallback = AudioResumeCallback;
            //_audioFlushCallback = AudioFlushCallback;
            //_audioDrainCallback = AudioDrainCallback;
            //_audioSetVolumeCallback = AudioSetVolumeCallback;

            _lockCallbackHandle    = GCHandle.Alloc(_lockCallback);
            _unlockCallbackHandle  = GCHandle.Alloc(_unlockCallback);
            _displayCallbackHandle = GCHandle.Alloc(_displayCallback);
            _formatCallbackHandle  = GCHandle.Alloc(_formatCallback);
            _cleanupCallbackHandle = GCHandle.Alloc(_cleanupCallback);
            //_audioSetupCallbackHandle = GCHandle.Alloc(_audioSetupCallback);
            //_audioCleanupCallbackHandle = GCHandle.Alloc(_audioCleanupCallback);
            //_audioPlayCallbackHandle = GCHandle.Alloc(_audioPlayCallback);
            //_audioPauseCallbackHandle = GCHandle.Alloc(_audioPauseCallback);
            //_audioResumeCallbackHandle = GCHandle.Alloc(_audioResumeCallback);
            //_audioFlushCallbackHandle = GCHandle.Alloc(_audioFlushCallback);
            //_audioDrainCallbackHandle = GCHandle.Alloc(_audioDrainCallback);
            //_audioSetVolumeCallbackHandle = GCHandle.Alloc(_audioSetVolumeCallback);

            if (player == null)
            {
                throw new Exception("Vlc media player initialize fail.");
            }

            AttachPlayer(player);
        }
Ejemplo n.º 4
0
        /// <summary>
        ///     Initialize VLC player with path of LibVlc and options.
        /// </summary>
        /// <param name="libVlcPath"></param>
        /// <param name="libVlcOption"></param>
        public void Initialize(String libVlcPath, params String[] libVlcOption)
        {
            if (!ApiManager.IsInitialized)
            {
                ApiManager.Initialize(libVlcPath, libVlcOption);
            }

            switch (CreateMode)
            {
            case PlayerCreateMode.NewVlcInstance:
                var vlc = new Vlc(libVlcOption);
                VlcMediaPlayer = vlc.CreateMediaPlayer();
                ApiManager.Vlcs.Add(vlc);
                break;

            case PlayerCreateMode.Default:
            default:
                VlcMediaPlayer = ApiManager.DefaultVlc.CreateMediaPlayer();
                break;
            }

            if (VlcMediaPlayer != null)
            {
                VlcMediaPlayer.PositionChanged += VlcMediaPlayerPositionChanged;
                VlcMediaPlayer.TimeChanged     += VlcMediaPlayerTimeChanged;
                VlcMediaPlayer.Playing         += VlcMediaPlayerStateChanged;
                VlcMediaPlayer.Paused          += VlcMediaPlayerStateChanged;
                VlcMediaPlayer.Stoped          += VlcMediaPlayerStateChanged;
                VlcMediaPlayer.Opening         += VlcMediaPlayerStateChanged;
                VlcMediaPlayer.Buffering       += VlcMediaPlayerStateChanged;
                VlcMediaPlayer.EndReached      += VlcMediaPlayerStateChanged;
                VlcMediaPlayer.SeekableChanged += VlcMediaPlayerSeekableChanged;
                VlcMediaPlayer.LengthChanged   += VlcMediaPlayerLengthChanged;

                _lockCallback    = VideoLockCallback;
                _unlockCallback  = VideoUnlockCallback;
                _displayCallback = VideoDisplayCallback;
                _formatCallback  = VideoFormatCallback;
                _cleanupCallback = VideoCleanupCallback;
                //_audioSetupCallback = AudioFormatSetupCallback;
                //_audioCleanupCallback = AudioFormatCleanupCallback;
                //_audioPlayCallback = AudioPlayCallback;
                //_audioPauseCallback = AudioPauseCallback;
                //_audioResumeCallback = AudioResumeCallback;
                //_audioFlushCallback = AudioFlushCallback;
                //_audioDrainCallback = AudioDrainCallback;
                //_audioSetVolumeCallback = AudioSetVolumeCallback;

                _lockCallbackHandle    = GCHandle.Alloc(_lockCallback);
                _unlockCallbackHandle  = GCHandle.Alloc(_unlockCallback);
                _displayCallbackHandle = GCHandle.Alloc(_displayCallback);
                _formatCallbackHandle  = GCHandle.Alloc(_formatCallback);
                _cleanupCallbackHandle = GCHandle.Alloc(_cleanupCallback);
                //_audioSetupCallbackHandle = GCHandle.Alloc(_audioSetupCallback);
                //_audioCleanupCallbackHandle = GCHandle.Alloc(_audioCleanupCallback);
                //_audioPlayCallbackHandle = GCHandle.Alloc(_audioPlayCallback);
                //_audioPauseCallbackHandle = GCHandle.Alloc(_audioPauseCallback);
                //_audioResumeCallbackHandle = GCHandle.Alloc(_audioResumeCallback);
                //_audioFlushCallbackHandle = GCHandle.Alloc(_audioFlushCallback);
                //_audioDrainCallbackHandle = GCHandle.Alloc(_audioDrainCallback);
                //_audioSetVolumeCallbackHandle = GCHandle.Alloc(_audioSetVolumeCallback);

                VlcMediaPlayer.SetVideoDecodeCallback(_lockCallback, _unlockCallback, _displayCallback, IntPtr.Zero);
                VlcMediaPlayer.SetVideoFormatCallback(_formatCallback, _cleanupCallback);
                //VlcMediaPlayer.SetAudioCallback(_audioPlayCallback, _audioPauseCallback, _audioResumeCallback, _audioFlushCallback, _audioDrainCallback);
                //VlcMediaPlayer.SetAudioFormatCallback(_audioSetupCallback, _audioCleanupCallback);
                //VlcMediaPlayer.SetAudioVolumeCallback(_audioSetVolumeCallback);
            }
        }
Ejemplo n.º 5
0
 public void SetVideoDecodeCallback(VideoLockCallback lockCallback, VideoUnlockCallback unlockCallback, VideoDisplayCallback displayCallback, IntPtr userData)
 {
     SetVideoCallbackFunction.Delegate(InstancePointer, lockCallback, unlockCallback, displayCallback, userData);
 }