Example #1
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            try
            {
                m_factory = new MediaPlayerFactory(true);
                m_sourcePlayer = m_factory.CreatePlayer<IVideoPlayer>();
                m_sourcePlayer.Mute = false;
                m_sourcePlayer.Volume = 100;

                m_renderPlayer = m_factory.CreatePlayer<IVideoPlayer>();
                m_renderPlayer.WindowHandle = panel1.Handle;

                m_inputMedia = m_factory.CreateMedia<ICompositeMemoryInputMedia>(MediaStrings.IMEM);
                SetupVideoSourceOutput(m_sourcePlayer.CustomRendererEx);
                SetupAudioSourceOutput(m_sourcePlayer.CustomAudioRenderer);

                Predicate<LogMessage> filter = p => p.Level == LogLevel.Warning || p.Level == LogLevel.Error;
                m_factory.SubscribeToLogMessages(log => Console.WriteLine(log.Message), filter);

                Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.RealTime;
            }
            catch(Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Example #2
0
File: Form1.cs Project: peerct/nVLC
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            m_factory      = new MediaPlayerFactory(true);
            m_sourcePlayer = m_factory.CreatePlayer <IVideoPlayer>();
            m_sourcePlayer.Events.PlayerPlaying += new EventHandler(Events_PlayerPlaying);
            m_sourcePlayer.Mute         = true;
            m_renderPlayer              = m_factory.CreatePlayer <IVideoPlayer>();
            m_renderPlayer.WindowHandle = panel1.Handle;
            m_inputMedia = m_factory.CreateMedia <IMemoryInputMedia>(MediaStrings.IMEM);
            SetupOutput(m_sourcePlayer.CustomRendererEx);
        }
Example #3
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            _mFactory = new MediaPlayerFactory(true);
            _mSourcePlayer = _mFactory.CreatePlayer<IVideoPlayer>();
            _mSourcePlayer.Events.PlayerPlaying += new EventHandler(Events_PlayerPlaying);
            _mSourcePlayer.Mute = true;
            _mRenderPlayer = _mFactory.CreatePlayer<IVideoPlayer>();
            _mRenderPlayer.WindowHandle = panel1.Handle;
            _mInputMedia = _mFactory.CreateMedia<IMemoryInputMedia>(MediaStrings.Imem);
            SetupOutput(_mSourcePlayer.CustomRendererEx);
        }
        public MainWindow()
        {
            InitializeComponent();
            this.Topmost = true;

            //MessageBox.Show("1");
            try
            {
                m_factory = new MediaPlayerFactory(true);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }

            m_player = m_factory.CreatePlayer <IVideoPlayer>();
            m_videoImage.Initialize(m_player.CustomRendererEx);

            m_player.Events.PlayerPositionChanged += new EventHandler <MediaPlayerPositionChanged>(Events_PlayerPositionChanged);
            m_player.Events.TimeChanged           += new EventHandler <MediaPlayerTimeChanged>(Events_TimeChanged);
            m_player.Events.MediaEnded            += new EventHandler(Events_MediaEnded);
            m_player.Events.PlayerStopped         += new EventHandler(Events_PlayerStopped);

            slider2.Value = m_player.Volume;

            DeleteFile.Click    += DeleteFile_Click;
            DeleteAllFile.Click += DeleteAllFile_Click;
            //MyListView.MouseDoubleClick += MyListView_MouseDoubleClick;
            MyListView.PreviewMouseLeftButtonUp += MyListView_PreviewMouseLeftButtonUp;

            UpdateListView();
        }
Example #5
0
        public PlayerVLC(string titleText, MainForm mf)
        {
            MF = mf;
            InitializeComponent();
            var arguments = new[] { "--file-caching=" + MainForm.Conf.VLCFileCache };

            _mFactory = new MediaPlayerFactory(arguments);
            _mPlayer  = _mFactory.CreatePlayer <IDiskPlayer>();

            _mPlayer.Events.PlayerPositionChanged += EventsPlayerPositionChanged;
            _mPlayer.Events.TimeChanged           += EventsTimeChanged;
            _mPlayer.Events.MediaEnded            += EventsMediaEnded;
            _mPlayer.Events.PlayerStopped         += EventsPlayerStopped;

            _mPlayer.WindowHandle = pnlMovie.Handle;

            if (_mPlayer.Volume >= trackBar2.Minimum && _mPlayer.Volume <= trackBar2.Maximum)
            {
                trackBar2.Value = _mPlayer.Volume;
            }

            RenderResources();
            _titleText           = titleText;
            chkRepeatAll.Checked = MainForm.VLCRepeatAll;
        }
        public Window1()
        {
            InitializeComponent();

            this.KeyDown += this.KeyPress;

            System.Windows.Forms.Panel p = new System.Windows.Forms.Panel();
            p.BackColor = System.Drawing.Color.Black;
            windowsFormsHost1.Child = p;

            m_factory = new MediaPlayerFactory(true);
            m_player = m_factory.CreatePlayer<IVideoPlayer>();

            this.DataContext = m_player;

            m_player.Events.PlayerPositionChanged += new EventHandler<MediaPlayerPositionChanged>(Events_PlayerPositionChanged);
            m_player.Events.TimeChanged += new EventHandler<MediaPlayerTimeChanged>(Events_TimeChanged);
            m_player.Events.MediaEnded += new EventHandler(Events_MediaEnded);
            m_player.Events.PlayerStopped += new EventHandler(Events_PlayerStopped);

            m_player.WindowHandle = p.Handle;
            slider2.Value = m_player.Volume;

            this.show = "Futurama";
            this.loadManager();
            this.playEpisode();
        }
Example #7
0
        public MainReceive(Form1 fork)
        {
            gs = new Class1(); // inainte de MainReceive::_mFactory->Init()



            //gs.GetBase().StateChanged += MainReceive_StateChanged;

            //++si;
            //gs.GetBase().TogglePlay(true, s[si]);

            form = fork;
            //g = form.panel1.CreateGraphics();

            _mFactory = new MediaPlayerFactory(opt,//new string[] { },
                                               @"C:\Program Files (x86)\VideoLAN\VLC", true, new CLogger());

            _mPlayer = _mFactory.CreatePlayer <IVideoPlayer>();
            _mPlayer.WindowHandle = form.panel1.Handle;

            // true: 00, 01
            // false:11, 10
            PlayStart(s[1]);
            //Thread.Sleep(5000);
            PlayStop(); // --> ev # s

            PlayStart(s[1]);


            //_mPlayer.CurrentMedia.Events.StateChanged += Events_StateChanged1;
        }
Example #8
0
        public VlcMediaPlayer(IMediaPlayerFactory factory = null, AudioEndpointVolume audioEndpointVolume = null)
        {
            // create the player using the injected factory
            _factory             = factory ?? new MediaPlayerFactory();
            _player              = _factory.CreatePlayer <IVideoPlayer>();
            _audioEndpointVolume = audioEndpointVolume;

            // set default values
            OpenTimeOut    = TimeSpan.FromSeconds(10);
            Async          = true;
            Error          = AudioError.NoError;
            AudioSelection = AudioSelection.Empty;

            // cached event handler to avoid leaks during add and remove
            _durationChanged = (s, e) => OnDurationChanged(e.NewDuration);
            _parsedChanged   = (s, e) => OnParsedChanged();

            // hook events
            _player.Events.MediaChanged           += (s, e) => OnMediaChanged();
            _player.Events.MediaEnded             += (s, e) => OnMediaEnded();
            _player.Events.PlayerEncounteredError += (s, e) => OnEncounteredError();
            _player.Events.PlayerLengthChanged    += (s, e) => OnDurationChanged(e.NewLength);
            _player.Events.PlayerPaused           += (s, e) => OnPaused();
            _player.Events.PlayerPlaying          += (s, e) => OnPlaying();
            _player.Events.PlayerPositionChanged  += (s, e) => OnPositionChanged(e.NewPosition * Duration);
            _player.Events.PlayerPositionChanged  += (s, e) => OnPositionChangedLoop(e.NewPosition);
            _player.Events.PlayerStopped          += (s, e) => OnStopped();
        }
Example #9
0
        public PlayerVlcWpf()
        {
            InitializeComponent();


            timer          = new DispatcherTimer();
            timer.Interval = TimeSpan.FromSeconds(1);
            timer.Tick    += new EventHandler(timer_Tick);

            InitializePropertyValues();


            System.Windows.Forms.Panel p = new System.Windows.Forms.Panel();

            p.BackColor = System.Drawing.Color.Transparent;
            windowsFormsHost1.Opacity = 0.5;
            windowsFormsHost1.Child   = p;



            m_factory = new MediaPlayerFactory(true);
            m_player  = m_factory.CreatePlayer <IVideoPlayer>();
            m_player.Events.PlayerPositionChanged += new EventHandler <MediaPlayerPositionChanged>(Events_PlayerPositionChanged);
            m_player.Events.TimeChanged           += new EventHandler <MediaPlayerTimeChanged>(Events_TimeChanged);
            m_player.Events.MediaEnded            += new EventHandler(Events_MediaEnded);
            m_player.Events.PlayerStopped         += new EventHandler(Events_PlayerStopped);


            m_player.WindowHandle = p.Handle;
        }
        public void Initialize(ILogger logger, Func <IVideoHost> getHost)
        {
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }
            if (getHost == null)
            {
                throw new ArgumentNullException("getHost");
            }

            this.logger  = logger;
            this.getHost = getHost;

            panel           = new System.Windows.Forms.Panel();
            panel.BackColor = System.Drawing.Color.Black;
            formHost.Child  = panel;

            playerFactory = new MediaPlayerFactory(logger);
            player        = playerFactory.CreatePlayer <IVlcVideoPlayer>();

            this.DataContext = player;

            player.Events.PlayerPositionChanged += new EventHandler <MediaPlayerPositionChanged>(Events_PlayerPositionChanged);
            player.Events.TimeChanged           += new EventHandler <MediaPlayerTimeChanged>(Events_TimeChanged);
            player.Events.MediaEnded            += new EventHandler(Events_MediaEnded);
            player.Events.PlayerStopped         += new EventHandler(Events_PlayerStopped);

            player.WindowHandle = panel.Handle;
            volumeSlider.Value  = player.Volume;
        }
Example #11
0
        public MediaPlayer()
        {
            InitializeComponent();

            this.btnMute.BackgroundImage  = UIHelper.LoadResourceImage("Resources.btn_volume_mute.png");
            this.btnPause.BackgroundImage = UIHelper.LoadResourceImage("Resources.btn_pause.png");
            this.btnPlay.BackgroundImage  = UIHelper.LoadResourceImage("Resources.btn_play.png");
            this.btnStop.BackgroundImage  = UIHelper.LoadResourceImage("Resources.btn_stop.png");
            this.pnlVideo.BackgroundImage = UIHelper.LoadResourceImage("Resources.pnl_video.png");

            fFactory = new MediaPlayerFactory(FIND_LIBVLC);
            fPlayer  = fFactory.CreatePlayer <IDiskPlayer>();

            fPlayer.Events.PlayerPositionChanged += Events_PlayerPositionChanged;
            fPlayer.Events.TimeChanged           += Events_TimeChanged;
            fPlayer.Events.MediaEnded            += Events_MediaEnded;
            fPlayer.Events.PlayerStopped         += Events_PlayerStopped;

            fPlayer.WindowHandle = pnlVideo.Handle;

            trkVolume.Value = Math.Max(0, fPlayer.Volume);
            trkVolume_Scroll(null, null);

            fMedia = null;

            UISync.Init(this);
        }
        public VLCVideoPlayer()
        {
            InitializeComponent();

            m_factory = new MediaPlayerFactory(true);
            m_player  = m_factory.CreatePlayer <IVideoPlayer>();
            Initialize(m_player.CustomRendererEx);
        }
Example #13
0
        //VideoDetectForm videoDetectform = new VideoDetectForm();

        public VideoPlayer()
        {
            InitializeComponent();

            m_factory             = new MediaPlayerFactory();
            m_player              = m_factory.CreatePlayer <IVideoPlayer>();
            m_player.WindowHandle = panel1.Handle;
        }
 public MainWindow()
 {
     InitializeComponent();
     m_factory             = new MediaPlayerFactory(true);
     m_player              = m_factory.CreatePlayer <IDiskPlayer>();
     m_player.WindowHandle = this.VideoCanvas.Handle;
     m_player.Events.PlayerPositionChanged += Events_PlayerPositionChanged;
     m_player.Events.PlayerStopped         += Events_PlayerStopped;
     m_player.Events.MediaEnded            += Events_MediaEnded;
 }
Example #15
0
        private bool _videoPlayState; // 当前播放的状态

        public HikFilePlayer()
        {
            _vlcplayer = Vlcfactory.CreatePlayer <IDiskPlayer>();
            _vlcplayer.Events.MediaEnded            += Events_MediaEnded;
            _vlcplayer.Events.PlayerStopped         += Events_PlayerStopped;
            _vlcplayer.Events.TimeChanged           += Events_TimeChanged;
            _vlcplayer.Events.PlayerPositionChanged += Events_PlayerPositionChanged;

            //// 调整为1.5倍速播放
            //_vlcplayer.PlaybackRate = 1.5F * _vlcplayer.PlaybackRate;
        }
Example #16
0
        void RTSPway()
        {
            string[] options = { "--video-filter=transform", "--transform-type=270", "--network-caching=200" };
            factory = new MediaPlayerFactory(options);
            player  = factory.CreatePlayer <IVideoPlayer>();
            this.Dispatcher.Invoke((Action)(() =>
            {
                player.WindowHandle = new WindowInteropHelper(this).Handle;
            }));

            playStream();
        }
        /// <summary>
        /// Initialize nVLC Component
        /// </summary>
        private void Init_nVLC()
        {
            m_factory = new MediaPlayerFactory(true);
            m_player  = m_factory.CreatePlayer <IDiskPlayer>();

            m_player.Events.PlayerPositionChanged += new EventHandler <MediaPlayerPositionChanged>(Events_PlayerPositionChanged);
            m_player.Events.TimeChanged           += new EventHandler <MediaPlayerTimeChanged>(Events_TimeChanged);
            m_player.Events.MediaEnded            += new EventHandler(Events_MediaEnded);
            m_player.Events.PlayerStopped         += new EventHandler(Events_PlayerStopped);

            m_player.WindowHandle = panel1.Handle;
        }
Example #18
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            m_factory             = new MediaPlayerFactory(new string[] { "--audio-visual=goom" }, true);
            m_player              = m_factory.CreatePlayer <IVideoPlayer>();
            m_player.WindowHandle = panel1.Handle;

            m_presets               = Equalizer.Presets.ToDictionary(key => key.Index);
            comboBox1.DataSource    = m_presets.Values.ToList();
            comboBox1.DisplayMember = "Name";
            comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
        }
Example #19
0
        /// <summary>
        /// Load the media file.
        /// </summary>
        /// <param name="mediaString">The media file to load.</param>
        /// <param name="mediaIndex">The media index type to load.</param>
        private void LoadMedia(string mediaString, int mediaIndex)
        {
            // If a media string has been selected.
            if (!String.IsNullOrEmpty(mediaString))
            {
                try
                {
                    // Create the player.
                    _player            = new MediaPlayerFactory(true);
                    _disk              = _player.CreatePlayer <IDiskPlayer>();
                    _disk.WindowHandle = this.panelMediaDisplay.Handle;

                    _disk.Events.PlayerPositionChanged += new EventHandler <MediaPlayerPositionChanged>(_disk_PlayerPositionChanged);
                    _disk.Events.TimeChanged           += new EventHandler <MediaPlayerTimeChanged>(_disk_TimeChanged);
                    _disk.Events.MediaEnded            += new EventHandler(_disk_MediaEnded);
                    _disk.Events.PlayerStopped         += new EventHandler(_disk_MediaEnded);

                    // The initialisation sync.
                    UISync.Init(this);

                    // Open the correct media type.
                    switch (mediaIndex)
                    {
                    case 0:
                    case 1:
                        // Open the media file.
                        _media = _player.CreateMedia <IMediaFromFile>(mediaString);
                        break;

                    case 2:
                    default:
                        // Open the media file.
                        _media = _player.CreateMedia <IMedia>(mediaString);
                        break;
                    }

                    // Get the duration changed event.
                    _media.Events.DurationChanged += new EventHandler <MediaDurationChange>(_media_DurationChanged);

                    // Open the media.
                    _disk.Open(_media);
                    _media.Parse(true);

                    // Enable controls.
                    EnabledControls(true);
                    _hasClosed     = false;
                    this.AllowDrop = false;
                }
                catch { }
            }
        }
Example #20
0
        /// <summary>
        /// Start audio source.
        /// </summary>
        ///
        /// <remarks>Starts audio source and return execution to caller. audio source
        /// object creates background thread and notifies about new frames with the
        /// help of <see cref="DataAvailable"/> event.</remarks>
        ///
        /// <exception cref="ArgumentException">audio source is not specified.</exception>
        ///
        public void Start()
        {
            if (!VlcHelper.VlcInstalled)
            {
                return;
            }
            if (!IsRunning)
            {
                // check source
                if (string.IsNullOrEmpty(_source))
                {
                    throw new ArgumentException("Audio source is not specified.");
                }

                DisposePlayer();

                _mFactory = new MediaPlayerFactory(false);

                _mPlayer = _mFactory.CreatePlayer <IVideoPlayer>();
                _mPlayer.Events.PlayerPlaying          += EventsPlayerPlaying;
                _mPlayer.Events.PlayerStopped          += EventsPlayerStopped;
                _mPlayer.Events.PlayerEncounteredError += EventsPlayerEncounteredError;

                string[] args = Arguments.Trim(',').Split(Environment.NewLine.ToCharArray(),
                                                          StringSplitOptions.RemoveEmptyEntries);
                List <String> inargs = args.ToList();
                inargs.Add(":sout=#transcode{vcodec=none}:Display");

                _mMedia = _mFactory.CreateMedia <IMedia>(_source, inargs.ToArray());

                _mPlayer.Open(_mMedia);

                GC.KeepAlive(_mFactory);
                GC.KeepAlive(_mPlayer);
                GC.KeepAlive(_mMedia);

                _needsSetup = true;
                var fc = new Func <SoundFormat, SoundFormat>(SoundFormatCallback);
                _mPlayer.CustomAudioRenderer.SetFormatCallback(fc);
                //.SetFormat(new SoundFormat(SoundType.S16N, RecordingFormat.SampleRate, RecordingFormat.Channels)));
                var ac = new AudioCallbacks {
                    SoundCallback = SoundCallback
                };
                _mPlayer.CustomAudioRenderer.SetCallbacks(ac);

                _mMedia.Parse(false);


                _mPlayer.Play();
            }
        }
Example #21
0
        /// <summary>
        /// Start video source.
        /// </summary>
        ///
        /// <remarks>Starts video source and return execution to caller. Video source
        /// object creates background thread and notifies about new frames with the
        /// help of <see cref="NewFrame"/> event.</remarks>
        ///
        /// <exception cref="ArgumentException">Video source is not specified.</exception>
        ///
        public void Start()
        {
            if (!VlcHelper.VlcInstalled)
            {
                return;
            }
            Isstopping = false;
            if (!IsRunning && !_starting)
            {
                _starting = true;
                // check source
                if (string.IsNullOrEmpty(_source))
                {
                    throw new ArgumentException("Video source is not specified.");
                }

                DisposePlayer();

                _mFactory = new MediaPlayerFactory(false);

                _mPlayer = _mFactory.CreatePlayer <IVideoPlayer>();
                _mPlayer.Events.PlayerPlaying          += EventsPlayerPlaying;
                _mPlayer.Events.PlayerStopped          += EventsPlayerStopped;
                _mPlayer.Events.PlayerEncounteredError += EventsPlayerEncounteredError;


                _mMedia = _mFactory.CreateMedia <IMedia>(_source, Arguments);
                _mPlayer.Open(_mMedia);
                GC.KeepAlive(_mFactory);
                GC.KeepAlive(_mPlayer);
                GC.KeepAlive(_mMedia);

                _needsSetup = true;
                var fc = new Func <SoundFormat, SoundFormat>(SoundFormatCallback);
                _mPlayer.CustomAudioRenderer.SetFormatCallback(fc);
                var ac = new AudioCallbacks {
                    SoundCallback = SoundCallback
                };
                _mPlayer.CustomAudioRenderer.SetCallbacks(ac);


                _mPlayer.CustomRenderer.SetFormat(new BitmapFormat(FormatWidth, FormatHeight, ChromaType.RV24));
                _mPlayer.CustomRenderer.SetCallback(FrameCallback);

                _mMedia.Parse(true);
                _framesReceived = 0;
                _mPlayer.Play();
            }
        }
Example #22
0
        public MainWindow()
        {
            InitializeComponent();

            m_factory = new MediaPlayerFactory();
            m_player  = m_factory.CreatePlayer <IVideoPlayer>();
            m_videoImage.Initialize(m_player.CustomRendererEx);

            m_player.Events.PlayerPositionChanged += new EventHandler <MediaPlayerPositionChanged>(Events_PlayerPositionChanged);
            m_player.Events.TimeChanged           += new EventHandler <MediaPlayerTimeChanged>(Events_TimeChanged);
            m_player.Events.MediaEnded            += new EventHandler(Events_MediaEnded);
            m_player.Events.PlayerStopped         += new EventHandler(Events_PlayerStopped);

            slider2.Value = m_player.Volume;
        }
Example #23
0
        public MainWindow()
        {
            InitializeComponent();

            m_factory = new MediaPlayerFactory();
            m_player = m_factory.CreatePlayer<IVideoPlayer>();
            m_videoImage.Initialize(m_player.CustomRendererEx);

            m_player.Events.PlayerPositionChanged += new EventHandler<MediaPlayerPositionChanged>(Events_PlayerPositionChanged);
            m_player.Events.TimeChanged += new EventHandler<MediaPlayerTimeChanged>(Events_TimeChanged);
            m_player.Events.MediaEnded += new EventHandler(Events_MediaEnded);
            m_player.Events.PlayerStopped += new EventHandler(Events_PlayerStopped);

            slider2.Value = m_player.Volume;
        }
Example #24
0
        public PlayerForm()
        {
            InitializeComponent();

            _mFactory = new MediaPlayerFactory();
            _mPlayer = _mFactory.CreatePlayer<IDiskPlayer>();

            _mPlayer.Events.PlayerPositionChanged += EventsPlayerPositionChanged;
            _mPlayer.Events.TimeChanged += EventsTimeChanged;
            _mPlayer.Events.MediaEnded += EventsMediaEnded;
            _mPlayer.Events.PlayerStopped += EventsPlayerStopped;

            _mPlayer.WindowHandle = pnlMovie.Handle;
            trackBar2.Value = _mPlayer.Volume;
            RenderResources();
        }
Example #25
0
        public Player()
        {
            InitializeComponent();

            m_factory = new MediaPlayerFactory(false);
            m_player  = m_factory.CreatePlayer <IDiskPlayer>();

            m_player.Events.PlayerPositionChanged += new EventHandler <MediaPlayerPositionChanged>(Events_PlayerPositionChanged);
            m_player.Events.TimeChanged           += new EventHandler <MediaPlayerTimeChanged>(Events_TimeChanged);
            m_player.Events.MediaEnded            += new EventHandler(Events_MediaEnded);
            m_player.Events.PlayerStopped         += new EventHandler(Events_PlayerStopped);

            m_player.WindowHandle = pnlMovie.Handle;
            trackBar2.Value       = m_player.Volume;
            RenderResources();
        }
Example #26
0
        public PlayerForm()
        {
            InitializeComponent();

            _mFactory = new MediaPlayerFactory();
            _mPlayer  = _mFactory.CreatePlayer <IDiskPlayer>();

            _mPlayer.Events.PlayerPositionChanged += EventsPlayerPositionChanged;
            _mPlayer.Events.TimeChanged           += EventsTimeChanged;
            _mPlayer.Events.MediaEnded            += EventsMediaEnded;
            _mPlayer.Events.PlayerStopped         += EventsPlayerStopped;

            _mPlayer.WindowHandle = pnlMovie.Handle;
            trackBar2.Value       = _mPlayer.Volume;
            RenderResources();
        }
Example #27
0
        public Subframe(JsonObject paramSchedule)
        {
            InitializeComponent();

            JsonObjectCollection col = (JsonObjectCollection)paramSchedule;
            frameInfoStrc frameInfo = new frameInfoStrc();

            frameInfo.xPos = int.Parse(col["xPos"].GetValue().ToString());
            frameInfo.yPos = int.Parse(col["yPos"].GetValue().ToString());
            frameInfo.width = int.Parse(col["width"].GetValue().ToString());
            frameInfo.height = int.Parse(col["height"].GetValue().ToString());
            frameInfo.contentsFileName = (string)col["fileName"].GetValue();
            frameInfo.mute = bool.Parse(col["mute"].GetValue().ToString());

            if (frameInfo.width == 0)
            {
                this.WindowState = FormWindowState.Maximized;
            }
            else
            {
                this.Width = frameInfo.width;
                this.Height = frameInfo.height;

            }
            this.Location = new System.Drawing.Point(frameInfo.xPos, frameInfo.yPos);

            # region ==== Create Player ====
            m_factory = new MediaPlayerFactory(true);
            m_player = m_factory.CreatePlayer<IDiskPlayer>();
            m_player.AspectRatio = AspectRatioMode.Default;
            m_player.Mute = frameInfo.mute;

            m_player.WindowHandle = this.pnlPlayerBack.Handle;

            UISync.Init(this);
            #endregion ======================

            #region ==== Contents play ====
            FileInfo contentsFileInfo = new FileInfo(@frameInfo.contentsFileName);
            m_media = m_factory.CreateMedia<IMediaFromFile>(contentsFileInfo.FullName);

            m_player.Open(m_media);
            m_media.Parse(true);

            m_player.Play();
            #endregion =====================
        }
Example #28
0
        public Form1()
        {
            InitializeComponent();

            _mFactory = new MediaPlayerFactory(true);
            _mPlayer = _mFactory.CreatePlayer<IDiskPlayer>();

            _mPlayer.Events.PlayerPositionChanged += new EventHandler<MediaPlayerPositionChanged>(Events_PlayerPositionChanged);
            _mPlayer.Events.TimeChanged += new EventHandler<MediaPlayerTimeChanged>(Events_TimeChanged);
            _mPlayer.Events.MediaEnded += new EventHandler(Events_MediaEnded);
            _mPlayer.Events.PlayerStopped += new EventHandler(Events_PlayerStopped);
            _mPlayer.AspectRatio = AspectRatioMode.Default;
            _mPlayer.WindowHandle = panel1.Handle;
            trackBar2.Value = _mPlayer.Volume > 0 ? _mPlayer.Volume : 0;

            UiSync.Init(this);
        }
Example #29
0
        public void GetDuration(string filePath)
        {
            IMedia       media  = m_factory.CreateMedia <IMediaFromFile>(filePath);
            IVideoPlayer player = m_factory.CreatePlayer <IVideoPlayer>();

            m_memRender = player.CustomRenderer;
            m_memRender.SetFormat(new BitmapFormat(1, 1, ChromaType.RV24));
            media.Events.DurationChanged += new EventHandler <MediaDurationChange>(Events_GetTimeDuration);
            media.Parse(true);
            player.Play();
            player.Stop();

            Thread.Sleep(100);
            player.Dispose();
            m_memRender.Dispose();
            media.Dispose();
        }
Example #30
0
        public Form1()
        {
            InitializeComponent();

            m_factory = new MediaPlayerFactory();
            m_player  = m_factory.CreatePlayer <IDiskPlayer>();

            m_player.Events.PlayerPositionChanged += new EventHandler <MediaPlayerPositionChanged>(Events_PlayerPositionChanged);
            m_player.Events.TimeChanged           += new EventHandler <MediaPlayerTimeChanged>(Events_TimeChanged);
            m_player.Events.MediaEnded            += new EventHandler(Events_MediaEnded);
            m_player.Events.PlayerStopped         += new EventHandler(Events_PlayerStopped);

            m_player.WindowHandle = panel1.Handle;
            trackBar2.Value       = m_player.Volume;

            UISync.Init(this);
        }
Example #31
0
        public Form1()
        {
            InitializeComponent();

            m_factory = new MediaPlayerFactory();
            m_player = m_factory.CreatePlayer<IDiskPlayer>();

            m_player.Events.PlayerPositionChanged += new EventHandler<MediaPlayerPositionChanged>(Events_PlayerPositionChanged);
            m_player.Events.TimeChanged += new EventHandler<MediaPlayerTimeChanged>(Events_TimeChanged);
            m_player.Events.MediaEnded += new EventHandler(Events_MediaEnded);
            m_player.Events.PlayerStopped += new EventHandler(Events_PlayerStopped);

            m_player.WindowHandle = panel1.Handle;
            trackBar2.Value = m_player.Volume;

            UISync.Init(this);
        }
Example #32
0
        public VideoPanel()
        {
            InitializeComponent();

            System.Windows.Forms.Panel p = new System.Windows.Forms.Panel();
            p.BackColor             = System.Drawing.Color.Black;
            windowsFormsHost1.Child = p;

            m_factory = new MediaPlayerFactory(true);
            m_player  = m_factory.CreatePlayer <IVideoPlayer>();

            this.DataContext = m_player;

            m_player.Events.PlayerPositionChanged += new EventHandler <MediaPlayerPositionChanged>(Events_PlayerPositionChanged);
            m_player.Events.TimeChanged           += new EventHandler <MediaPlayerTimeChanged>(Events_TimeChanged);
            m_player.Events.MediaEnded            += new EventHandler(Events_MediaEnded);
            m_player.Events.PlayerStopped         += new EventHandler(Events_PlayerStopped);

            m_player.WindowHandle = p.Handle;
            slider2.Value         = m_player.Volume;
        }
Example #33
0
        public MediaPlayer()
        {
            InitializeComponent();

            fFactory = new MediaPlayerFactory(FIND_LIBVLC);
            fPlayer  = fFactory.CreatePlayer <IDiskPlayer>();

            fPlayer.Events.PlayerPositionChanged += Events_PlayerPositionChanged;
            fPlayer.Events.TimeChanged           += Events_TimeChanged;
            fPlayer.Events.MediaEnded            += Events_MediaEnded;
            fPlayer.Events.PlayerStopped         += Events_PlayerStopped;

            fPlayer.WindowHandle = pnlVideo.Handle;

            trkVolume.Value = Math.Max(0, fPlayer.Volume);
            trkVolume_Scroll(null, null);

            fMedia = null;

            UISync.Init(this);
        }
Example #34
0
        public MainWindow()
        {
            InitializeComponent();

            System.Windows.Forms.Panel p = new System.Windows.Forms.Panel();
            p.BackColor = System.Drawing.Color.Black;
            windowsFormsHost1.Child = p;

            m_factory = new MediaPlayerFactory(true);
            m_player = m_factory.CreatePlayer<IVideoPlayer>();

            this.DataContext = m_player;

            m_player.Events.PlayerPositionChanged += new EventHandler<MediaPlayerPositionChanged>(Events_PlayerPositionChanged);
            m_player.Events.TimeChanged += new EventHandler<MediaPlayerTimeChanged>(Events_TimeChanged);
            m_player.Events.MediaEnded += new EventHandler(Events_MediaEnded);
            m_player.Events.PlayerStopped += new EventHandler(Events_PlayerStopped);

            m_player.WindowHandle = p.Handle;
            slider2.Value = m_player.Volume;
        }
Example #35
0
        public PlayerVLC(string titleText, MainForm mf)
        {
            MF = mf;
            InitializeComponent();
            var arguments = new[] { "--file-caching="+MainForm.Conf.VLCFileCache };
            _mFactory = new MediaPlayerFactory(arguments);
            _mPlayer = _mFactory.CreatePlayer<IDiskPlayer>();

            _mPlayer.Events.PlayerPositionChanged += EventsPlayerPositionChanged;
            _mPlayer.Events.TimeChanged += EventsTimeChanged;
            _mPlayer.Events.MediaEnded += EventsMediaEnded;
            _mPlayer.Events.PlayerStopped += EventsPlayerStopped;

            _mPlayer.WindowHandle = pnlMovie.Handle;

             if (_mPlayer.Volume>=trackBar2.Minimum && _mPlayer.Volume<=trackBar2.Maximum)
                trackBar2.Value = _mPlayer.Volume;

             RenderResources();
             _titleText = titleText;
             chkRepeatAll.Checked = MainForm.VLCRepeatAll;
        }
Example #36
0
        public VlcPlayer()
        {
            InitializeComponent();


            System.Windows.Forms.Panel p = new System.Windows.Forms.Panel();

            p.BackColor = System.Drawing.Color.Transparent;
            windowsFormsHost1.Opacity = 0.5;
            windowsFormsHost1.Child   = p;


            m_factory = new MediaPlayerFactory(true);
            m_player  = m_factory.CreatePlayer <IVideoPlayer>();

            m_media = m_factory.CreateMedia <IMediaFromFile>(@"E:\Render Library\Movie paths\Dance+SFS2.avi");
            // m_media.Events.DurationChanged += new EventHandler<MediaDurationChange>(Events_DurationChanged);
            //m_media.Events.StateChanged += new EventHandler<MediaStateChange>(Events_StateChanged);

            m_player.Open(m_media);
            m_media.Parse(true);
            m_player.Play();
        }
Example #37
0
        public MainSend()
        {
            _mFactory = new MediaPlayerFactory(opt,//new string[] { },
                                               @"C:\Program Files (x86)\VideoLAN\VLC", true, new CLogger());

            InputMedia = _mFactory.CreateMedia <IMemoryInputMedia>(MediaStrings.IMEM);

            Player = _mFactory.CreatePlayer <IVideoPlayer>();


            Player.Events.PlayerPlaying += new EventHandler(Events_PlayerPlaying);

            /*
             * //DateTime _dt;
             *
             * for (int i = 0; i < 2; i++)//while (true)
             * {
             * //_dt = DateTime.Now;
             *
             * if (started) ToggleRunningMedia(false);
             *
             * //_dt = DateTime.Now;
             * //Console.WriteLine(string.Format(" {0:00}:{1:00}:{2:00}.{3:000}    {4}",
             * //   _dt.Hour, _dt.Minute, _dt.Second, _dt.Millisecond, "Stop"));
             *
             *
             *
             *
             ++si;                if (si >= s.Length) si = 0;
             * //_dt = DateTime.Now;
             * //Console.WriteLine(string.Format(" {0:00}:{1:00}:{2:00}.{3:000}    {4}{5}",
             * //_dt.Hour, _dt.Minute, _dt.Second, _dt.Millisecond, "Start", Environment.NewLine));
             *
             * started = true;
             * }*/
        }
Example #38
0
        private void WorkerThread()
        {
            bool file = false;

            try
            {
                if (File.Exists(_source))
                {
                    file = true;
                }
            }
            catch
            {
            }



            if (_mFactory == null)
            {
                var args = new List <string>
                {
                    "-I",
                    "dumy",
                    "--ignore-config",
                    "--no-osd",
                    "--disable-screensaver",
                    "--plugin-path=./plugins"
                };
                if (file)
                {
                    args.Add("--file-caching=3000");
                }
                try
                {
                    var l2 = args.ToList();
                    l2.AddRange(_arguments);

                    l2        = l2.Distinct().ToList();
                    _mFactory = new MediaPlayerFactory(l2.ToArray());
                }
                catch (Exception ex)
                {
                    MainForm.LogExceptionToFile(ex);
                    MainForm.LogMessageToFile("VLC arguments are: " + String.Join(",", args.ToArray()));
                    MainForm.LogMessageToFile("Using default VLC configuration.");
                    _mFactory = new MediaPlayerFactory(args.ToArray());
                }
                GC.KeepAlive(_mFactory);
            }

            if (file)
            {
                _mMedia = _mFactory.CreateMedia <IMediaFromFile>(_source);
            }
            else
            {
                _mMedia = _mFactory.CreateMedia <IMedia>(_source);
            }

            _mMedia.Events.DurationChanged += EventsDurationChanged;
            _mMedia.Events.StateChanged    += EventsStateChanged;

            if (_mPlayer != null)
            {
                try
                {
                    _mPlayer.Dispose();
                }
                catch
                {
                }
                _mPlayer = null;
            }


            _mPlayer = _mFactory.CreatePlayer <IVideoPlayer>();
            _mPlayer.Events.TimeChanged += EventsTimeChanged;

            var fc = new Func <SoundFormat, SoundFormat>(SoundFormatCallback);

            _mPlayer.CustomAudioRenderer.SetFormatCallback(fc);
            var ac = new AudioCallbacks {
                SoundCallback = SoundCallback
            };

            _mPlayer.CustomAudioRenderer.SetCallbacks(ac);
            _mPlayer.CustomAudioRenderer.SetExceptionHandler(Handler);

            _mPlayer.CustomRenderer.SetCallback(FrameCallback);
            _mPlayer.CustomRenderer.SetExceptionHandler(Handler);
            GC.KeepAlive(_mPlayer);

            _needsSetup = true;
            _stopping   = false;
            _mPlayer.CustomRenderer.SetFormat(new BitmapFormat(FormatWidth, FormatHeight, ChromaType.RV24));
            _mPlayer.Open(_mMedia);
            _mMedia.Parse(true);

            _mPlayer.Delay = 0;

            _framesReceived = 0;
            Duration        = Time = 0;
            LastFrame       = DateTime.MinValue;


            //check if file source (isseekable in _mPlayer is not reliable)
            Seekable = false;
            try
            {
                var p = Path.GetFullPath(_mMedia.Input);
                Seekable = !String.IsNullOrEmpty(p);
            }
            catch (Exception)
            {
                Seekable = false;
            }
            _mPlayer.WindowHandle = IntPtr.Zero;
            _mPlayer.Play();



            _stopEvent.WaitOne();

            if (!Seekable && !_stopRequested)
            {
                if (PlayingFinished != null)
                {
                    PlayingFinished(this, ReasonToFinishPlaying.DeviceLost);
                }
                if (AudioFinished != null)
                {
                    AudioFinished(this, ReasonToFinishPlaying.DeviceLost);
                }
            }
            else
            {
                if (PlayingFinished != null)
                {
                    PlayingFinished(this, ReasonToFinishPlaying.StoppedByUser);
                }
                if (AudioFinished != null)
                {
                    AudioFinished(this, ReasonToFinishPlaying.StoppedByUser);
                }
            }

            DisposePlayer();
        }
Example #39
0
        /// <summary>
        /// Start video source.
        /// </summary>
        /// 
        /// <remarks>Starts video source and return execution to caller. Video source
        /// object creates background thread and notifies about new frames with the
        /// help of <see cref="NewFrame"/> event.</remarks>
        /// 
        /// <exception cref="ArgumentException">Video source is not specified.</exception>
        /// 
        public void Start()
        {
            if (!VlcHelper.VlcInstalled)
                return;
            Isstopping = false;
            if (!IsRunning && !_starting)
            {
                _starting = true;
                // check source
                if (string.IsNullOrEmpty(_source))
                    throw new ArgumentException("Video source is not specified.");

                DisposePlayer();

                _mFactory = new MediaPlayerFactory(false);

                _mPlayer = _mFactory.CreatePlayer<IVideoPlayer>();
                _mPlayer.Events.PlayerPlaying += EventsPlayerPlaying;
                _mPlayer.Events.PlayerStopped += EventsPlayerStopped;
                _mPlayer.Events.PlayerEncounteredError += EventsPlayerEncounteredError;

                _mMedia = _mFactory.CreateMedia<IMedia>(_source, Arguments);
                _mPlayer.Open(_mMedia);
                GC.KeepAlive(_mFactory);
                GC.KeepAlive(_mPlayer);
                GC.KeepAlive(_mMedia);

                _needsSetup = true;
                var fc = new Func<SoundFormat, SoundFormat>(SoundFormatCallback);
                _mPlayer.CustomAudioRenderer.SetFormatCallback(fc);
                var ac = new AudioCallbacks { SoundCallback = SoundCallback };
                _mPlayer.CustomAudioRenderer.SetCallbacks(ac);

                _mPlayer.CustomRenderer.SetFormat(new BitmapFormat(FormatWidth, FormatHeight, ChromaType.RV24));
                _mPlayer.CustomRenderer.SetCallback(FrameCallback);

                _mMedia.Parse(true);
                _framesReceived = 0;
                _mPlayer.Play();
            }
        }
Example #40
0
        //public VideoWindow()
        private VideoWindow(FileInfo imgSrc, FileInfo videoSrc)
        {
            InitializeComponent();

            this.Width = SystemParameters.PrimaryScreenWidth;
            this.Height = SystemParameters.PrimaryScreenHeight;
            this.Left = 0;
            this.Top = 0;
            // this.Topmost = true;
            //imgSrc = new FileInfo(@"C:\Users\Administrator\Videos\thumbnails\b.jpg");
            //videoSrc = new FileInfo(@"C:\Users\Administrator\Videos\b.mp4");

            img = new BitmapImage(new Uri(imgSrc.FullName));
            fileName = videoSrc.FullName;

            //根据分辨率不同,调整DetialWindow出现的位置
            if (this.Width > 1300)
            {
                size = SystemParameters.PrimaryScreenWidth*0.415;
            }
            else if (this.Width < 1300 && this.Width > 1000)
            {
                size = SystemParameters.PrimaryScreenWidth*0.415;
            }
            if (img.Width >= img.Height)
            {
                w = size;
                h = size/img.Width*img.Height;
            }
            else
            {
                h = size;
                w = size/img.Height*img.Width;
            }
            gd.Background = new ImageBrush(img);

            stdStart = (Storyboard) this.Resources["start"];
            stdEnd = (Storyboard) this.Resources["end"];
            stdEnd2 = (Storyboard) this.Resources["end_2"];
            stdVideoFinish = (Storyboard) Resources["VideoFinish"];

            stdStart.Completed += (a, b) =>
                {
                    //stdMiddle.Begin();
                    TimeSplit.Visibility = Visibility.Visible;
                    var datPrs = new DoubleAnimation(0, 600, new Duration(TimeSpan.FromMilliseconds(1000)));
                    process.BeginAnimation(ProgressBar.WidthProperty, datPrs);

                    ///播放视频
                    m_media = m_factory.CreateMedia<IMediaFromFile>(fileName);
                    m_media.Events.DurationChanged += Events_DurationChanged;
                    m_media.Events.StateChanged += Events_StateChanged;
                    m_player.Open(m_media);

                    m_media.Parse(true);
                    m_player.Play();
                    //System.Drawing.Size s = m_player.GetVideoSize(0);
                    //m_player.TakeSnapShot(0, @"C:\");
                    DispatcherTimer timer = new DispatcherTimer();
                    timer.Interval = TimeSpan.FromMilliseconds(1000);
                    timer.Tick += (c, d) =>
                        {
                            gd.Background = null;
                            timer.Stop();
                        };
                    timer.Start();
                };

            stdEnd.Completed += (c, d) =>
                {
                    CloseAnmit();
                    stdEnd2.Begin();
                };
            stdEnd2.Completed += (e, f) => { this.Close(); };
            this.Loaded += MainWindow_Loaded;

            m_factory = new MediaPlayerFactory();
            m_player = m_factory.CreatePlayer<IVideoPlayer>();
            m_videoImage.Initialize(m_player.CustomRendererEx);

            m_player.Events.PlayerPositionChanged +=
                new EventHandler<MediaPlayerPositionChanged>(Events_PlayerPositionChanged);
            m_player.Events.TimeChanged += new EventHandler<MediaPlayerTimeChanged>(Events_TimeChanged);
            m_player.Events.MediaEnded += new EventHandler(Events_MediaEnded);
            m_player.Events.PlayerStopped += new EventHandler(Events_PlayerStopped);
        }
Example #41
0
        /// <summary>
        /// Start audio source.
        /// </summary>
        /// 
        /// <remarks>Starts audio source and return execution to caller. audio source
        /// object creates background thread and notifies about new frames with the
        /// help of <see cref="DataAvailable"/> event.</remarks>
        /// 
        /// <exception cref="ArgumentException">audio source is not specified.</exception>
        /// 
        public void Start()
        {
            if (!VlcHelper.VlcInstalled)
                return;
            if (!IsRunning)
            {
                // check source
                if (string.IsNullOrEmpty(_source))
                    throw new ArgumentException("Audio source is not specified.");

                DisposePlayer();

                _mFactory = new MediaPlayerFactory(false);

                _mPlayer = _mFactory.CreatePlayer<IVideoPlayer>();
                _mPlayer.Events.PlayerPlaying += EventsPlayerPlaying;
                _mPlayer.Events.PlayerStopped += EventsPlayerStopped;
                _mPlayer.Events.PlayerEncounteredError += EventsPlayerEncounteredError;

                string[] args = Arguments.Trim(',').Split(Environment.NewLine.ToCharArray(),
                                                                                StringSplitOptions.RemoveEmptyEntries);
                List<String> inargs = args.ToList();
                inargs.Add(":sout=#transcode{vcodec=none}:Display");

                _mMedia = _mFactory.CreateMedia<IMedia>(_source, inargs.ToArray());

                _mPlayer.Open(_mMedia);

                GC.KeepAlive(_mFactory);
                GC.KeepAlive(_mPlayer);
                GC.KeepAlive(_mMedia);

                _needsSetup = true;
                var fc = new Func<SoundFormat, SoundFormat>(SoundFormatCallback);
                _mPlayer.CustomAudioRenderer.SetFormatCallback(fc);
                var ac = new AudioCallbacks {SoundCallback = SoundCallback};
                _mPlayer.CustomAudioRenderer.SetCallbacks(ac);
                _mMedia.Events.ParsedChanged += EventsParsedChanged;
                _mMedia.Parse(true);

                _mPlayer.Play();

            }
        }
Example #42
0
        /// <summary>
        /// Start video source.
        /// </summary>
        /// 
        /// <remarks>Starts video source and return execution to caller. Video source
        /// object creates background thread and notifies about new frames with the
        /// help of <see cref="NewFrame"/> event.</remarks>
        /// 
        /// <exception cref="ArgumentException">Video source is not specified.</exception>
        /// 
        public void Start()
        {
            lock (_lock)
            {
                if (!VlcHelper.VlcInstalled)
                    return;
                if (_stoprequested)
                    return;
                if (!IsRunning && !_starting)
                {
                    _starting = true;
                    // check source
                    if (string.IsNullOrEmpty(_source))
                        throw new ArgumentException("Audio source is not specified.");

                    bool init = _mFactory == null;
                    if (init)
                    {
                        _mFactory = new MediaPlayerFactory();
                        _mPlayer = _mFactory.CreatePlayer<IVideoPlayer>();
                        _mPlayer.Events.PlayerPlaying += EventsPlayerPlaying;
                        _mPlayer.Events.TimeChanged += EventsTimeChanged;
                        var fc = new Func<SoundFormat, SoundFormat>(SoundFormatCallback);
                        _mPlayer.CustomAudioRenderer.SetFormatCallback(fc);
                        var ac = new AudioCallbacks { SoundCallback = SoundCallback };
                        _mPlayer.CustomAudioRenderer.SetCallbacks(ac);
                        _mPlayer.CustomAudioRenderer.SetExceptionHandler(Handler);
                    }

                    bool file = false;
                    try
                    {
                        if (File.Exists(_source))
                        {
                            file = true;
                        }
                    }
                    catch
                    {

                    }
                    if (file)
                        _mMedia = _mFactory.CreateMedia<IMediaFromFile>(_source);
                    else
                        _mMedia = _mFactory.CreateMedia<IMedia>(_source);

                    _mMedia.AddOptions(_arguments);

                    _mMedia.Events.DurationChanged -= EventsDurationChanged;
                    _mMedia.Events.StateChanged -= EventsStateChanged;
                    _mMedia.Events.DurationChanged += EventsDurationChanged;
                    _mMedia.Events.StateChanged += EventsStateChanged;

                    _needsSetup = true;

                    _mPlayer.Open(_mMedia);
                    _mMedia.Parse(true);
                    _framesReceived = 0;
                    Duration = Time = 0;
                    LastFrame = DateTime.MinValue;
                    _mPlayer.Play();

                    //check if file source (isseekable in _mPlayer is not reliable)
                    Seekable = false;
                    try
                    {
                        var p = Path.GetFullPath(_mMedia.Input);
                        Seekable = !String.IsNullOrEmpty(p);
                    }
                    catch (Exception)
                    {
                        Seekable = false;
                    }
                }
            }
        }
Example #43
0
        public PlayerForm(Form ParentForm, List <string> PlayerSongInfoList)
        {
            InitializeComponent();

            this.Owner         = ParentForm;
            SongId             = PlayerSongInfoList[0];
            SongLang           = PlayerSongInfoList[1];
            SongSinger         = PlayerSongInfoList[2];
            SongSongName       = PlayerSongInfoList[3];
            SongTrack          = PlayerSongInfoList[4];
            SongFilePath       = PlayerSongInfoList[5];
            dvRowIndex         = PlayerSongInfoList[6];
            UpdateDataGridView = PlayerSongInfoList[7];

            this.Text = "【" + SongLang + "】" + SongSinger + " - " + SongSongName;

            m_factory             = new MediaPlayerFactory(true);
            m_player              = m_factory.CreatePlayer <IDiskPlayer>();
            m_player.WindowHandle = Player_Panel.Handle;

            Player_ProgressTrackBar.ProgressBarValue = 0;
            Player_ProgressTrackBar.TrackBarValue    = 0;

            m_media = m_factory.CreateMedia <IMediaFromFile>(SongFilePath);
            m_player.Open(m_media);
            m_media.Parse(true);
            m_player.Mute = true;
            m_player.Play();

            Thread.Sleep(1000);

            bool WaitTrackInfo = false;

            while (!WaitTrackInfo)
            {
                if (m_player.AudioTrackCount > 1)
                {
                    foreach (Declarations.TrackDescription TrackDesc in m_player.AudioTracksInfo)
                    {
                        if (TrackDesc.Id != -1)
                        {
                            WaitTrackInfo = true;
                        }
                    }
                }
            }

            List <int> TrackIdList = new List <int>();

            foreach (Declarations.TrackDescription TrackDesc in m_player.AudioTracksInfo)
            {
                TrackIdList.Add(TrackDesc.Id);
            }

            if (TrackIdList.Count > 2)
            {
                switch (SongTrack)
                {
                case "1":
                    if (m_player.AudioTrack != TrackIdList[1])
                    {
                        m_player.AudioTrack = TrackIdList[1];
                    }
                    break;

                case "2":
                    if (m_player.AudioTrack != TrackIdList[2])
                    {
                        m_player.AudioTrack = TrackIdList[2];
                    }
                    break;
                }
                Player_CurrentChannelValue_Label.Text = (TrackIdList.IndexOf(m_player.AudioTrack) == Convert.ToInt32(SongTrack)) ? "伴唱" : "人聲";
            }
            else
            {
                string ChannelValue = "";
                switch (SongTrack)
                {
                case "1":
                    if (m_player.Channel != AudioChannelType.Left)
                    {
                        m_player.Channel = AudioChannelType.Left;
                    }
                    ChannelValue = "1";
                    break;

                case "2":
                    if (m_player.Channel != AudioChannelType.Right)
                    {
                        m_player.Channel = AudioChannelType.Right;
                    }
                    ChannelValue = "2";
                    break;
                }
                Player_CurrentChannelValue_Label.Text = (ChannelValue == SongTrack) ? "伴唱" : "人聲";
            }

            m_player.Events.PlayerPositionChanged += new EventHandler <MediaPlayerPositionChanged>(Events_PlayerPositionChanged);

            m_player.Position = 0;
            m_player.Mute     = false;

            timer.Tick    += new EventHandler(timer_Tick);
            timer.Interval = 500;
            timer.Start();
        }
        public void Initialize(ILogger logger, Func<IVideoHost> getHost)
        {
            if (logger == null)
                throw new ArgumentNullException("logger");
            if (getHost == null)
                throw new ArgumentNullException("getHost");

            this.logger = logger;
            this.getHost = getHost;

            panel = new System.Windows.Forms.Panel();
            panel.BackColor = System.Drawing.Color.Black;
            formHost.Child = panel;

            playerFactory = new MediaPlayerFactory(logger);
            player = playerFactory.CreatePlayer<IVlcVideoPlayer>();

            this.DataContext = player;

            player.Events.PlayerPositionChanged += new EventHandler<MediaPlayerPositionChanged>(Events_PlayerPositionChanged);
            player.Events.TimeChanged += new EventHandler<MediaPlayerTimeChanged>(Events_TimeChanged);
            player.Events.MediaEnded += new EventHandler(Events_MediaEnded);
            player.Events.PlayerStopped += new EventHandler(Events_PlayerStopped);

            player.WindowHandle = panel.Handle;
            volumeSlider.Value = player.Volume;
        }
Example #45
0
        /// <summary>
        /// Start video source.
        /// </summary>
        /// 
        /// <remarks>Starts video source and return execution to caller. Video source
        /// object creates background thread and notifies about new frames with the
        /// help of <see cref="NewFrame"/> event.</remarks>
        /// 
        /// <exception cref="ArgumentException">Video source is not specified.</exception>
        /// 
        public void Start()
        {
            lock (_lock)
            {
                if (!VlcHelper.VlcInstalled)
                    return;
                if (_stoprequested)
                    return;

                if (!IsRunning && !_starting)
                {
                    _starting = true;
                    if (string.IsNullOrEmpty(_source))
                        throw new ArgumentException("Video source is not specified.");

                    bool init = _mFactory == null;

                    bool file = false;
                    try
                    {
                        if (File.Exists(_source))
                        {
                            file = true;
                        }
                    }
                    catch
                    {

                    }

                    if (init)
                    {
                        var args = new List<string>
                        {
                            "-I",
                            "dumy",
                            "--ignore-config",
                            "--no-osd",
                            "--disable-screensaver",
                            "--plugin-path=./plugins"
                        };
                        if (file)
                            args.Add("--file-caching=3000");

                        _mFactory = new MediaPlayerFactory(args.ToArray());
                        _mPlayer = _mFactory.CreatePlayer<IVideoPlayer>();
                        _mPlayer.Events.PlayerPlaying += EventsPlayerPlaying;
                        _mPlayer.Events.TimeChanged += EventsTimeChanged;
                        var fc = new Func<SoundFormat, SoundFormat>(SoundFormatCallback);
                        _mPlayer.CustomAudioRenderer.SetFormatCallback(fc);
                        var ac = new AudioCallbacks { SoundCallback = SoundCallback };
                        _mPlayer.CustomAudioRenderer.SetCallbacks(ac);
                        _mPlayer.CustomRenderer.SetCallback(FrameCallback);
                        _mPlayer.CustomRenderer.SetExceptionHandler(Handler);
                        _mPlayer.CustomAudioRenderer.SetExceptionHandler(Handler);
                    }

                    if (file)
                        _mMedia = _mFactory.CreateMedia<IMediaFromFile>(_source);
                    else
                        _mMedia = _mFactory.CreateMedia<IMedia>(_source);

                    _mMedia.AddOptions(_arguments);

                    _mMedia.Events.DurationChanged -= EventsDurationChanged;
                    _mMedia.Events.StateChanged -= EventsStateChanged;
                    _mMedia.Events.DurationChanged += EventsDurationChanged;
                    _mMedia.Events.StateChanged += EventsStateChanged;

                    _needsSetup = true;
                    _mPlayer.CustomRenderer.SetFormat(new BitmapFormat(FormatWidth, FormatHeight, ChromaType.RV24));

                    _mPlayer.Open(_mMedia);
                    _mMedia.Parse(true);

                    _framesReceived = 0;
                    Duration = Time = 0;
                    LastFrame = DateTime.MinValue;
                    _mPlayer.Play();

                    //check if file source (isseekable in _mPlayer is not reliable)
                    Seekable = false;
                    try
                    {
                        var p = Path.GetFullPath(_mMedia.Input);
                        Seekable = !String.IsNullOrEmpty(p);
                    }
                    catch (Exception)
                    {
                        Seekable = false;
                    }
                }
            }
        }