Пример #1
0
        /// <summary>
        /// Method to start streaming of media
        /// </summary>
        private void playStream()
        {
            try
            {
                if (playbackStatus == playbackStatusCodes.Stop)
                {
                    SetEnvironement(SearchVlcPath());

                    vlc.Initialize();
                    vlc.VideoOutput = pictureBox1;
                    vlc.PlaylistClear();
                    //Multicast address
                    string[] Options = new string[] { ":sout=#duplicate{dst=display,dst=std {access=udp,mux=ts,dst=224.100.0.1:1234}}" };

                    if (fileName == null)
                    {
                        MessageBox.Show("Please select a file by double clicking in the space for video");
                        return;
                    }
                    vlc.PlaylistClear();
                    vlc.AddTarget(fileName, Options);

                    playErrorCode = vlc.Play();
                    this.Text = "VirtualTheater - " + fileName;
                    if (playErrorCode == LibVlc.LibVlc.Error.Success)
                    {
                        //For the seekBar
                        seekBarThread = new Thread(new ThreadStart(this.seekBarThreadProc));
                        seekBarThread.Start();
                        playbackStatus = playbackStatusCodes.Play;
                        buttonPlay.Enabled = false;
                        buttonPause.Enabled = true;
                        buttonStop.Enabled = true;
                    }
                }
                else
                {
                    forceUpdateSessionInformation("Force Update@" + Dns.GetHostName() + " requests a play");
                }
            }
            catch (Exception e1)
            {
                System.Console.WriteLine("Exception occurred: {0}", e1);
            }
        }
Пример #2
0
        /// <summary>
        /// Method to start leeching of media
        /// </summary>
        private void receiveStream()
        {
            try
            {
                if (authenticationDone == false)
                {
                    MessageBox.Show("Please wait for authentication response");
                    return;
                }

                if (playbackStatus == playbackStatusCodes.Stop)
                {
                    SetEnvironement(SearchVlcPath());
                    vlc.Initialize();
                    vlc.VideoOutput = pictureBox1;
                    vlc.PlaylistClear();
                    string[] options = { ":sout=#duplicate{dst=display}" };

                    //Muticast address
                    vlc.AddTarget("udp://@224.100.0.1:1234", options);

                    playErrorCode = vlc.Play();

                    if (playErrorCode == LibVlc.LibVlc.Error.Success)
                    {
                        playbackStatus = playbackStatusCodes.Play;
                        buttonPlay.Enabled = false;
                        buttonPause.Enabled = true;
                        buttonStop.Enabled = true;
                    }
                }
                else
                {
                    forceUpdateSessionInformation("Force Update@" + Dns.GetHostName() + " requests a play");
                }
            }
            catch (Exception e1)
            {
                System.Console.WriteLine("Exception occurred: {0}", e1);
            }
        }
Пример #3
0
        /// <summary>
        /// Used to play or pause video. Invoked from within other event handlers
        /// </summary>
        /// <param name="playPause"> true = pause; false = play</param>
        /// 
        private void pause(bool playPause)
        {
            try
            {

                if (playPause == true)
                {
                    vlc.Pause();
                    if (streamFlag)
                        if (seekBarThread != null)
                            seekBarThread.Suspend();
                    playbackStatus = playbackStatusCodes.Pause;
                    buttonPause.Enabled = false;
                    buttonPlay.Enabled = true;
                }
                else
                {

                    vlc.Pause();
                    if (streamFlag)
                        if (seekBarThread != null)
                            seekBarThread.Resume();
                    playbackStatus = playbackStatusCodes.Play;
                    buttonPause.Enabled = true;
                    buttonPlay.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("Exception occurred: {0}", ex);
            }
        }
Пример #4
0
 /// <summary>
 /// Reset the application to starting conditions
 /// </summary>
 private void initConditions()
 {
     playbackStatus = playbackStatusCodes.Stop;
     buttonPlay.Enabled = false;
     buttonPause.Enabled = false;
     buttonStop.Enabled = false;
     remoteSession = false;
     localSession = false;
     streamFlag = false;
     authenticationDone = false;
     logBox.Clear();
 }
Пример #5
0
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            currTime = 0;
            if (seekBarThread != null)
                while (seekBarThread.ThreadState != ThreadState.Stopped)
                    seekBarThread.Abort(seekBarThread.ThreadState);
            vlc.Stop();
            playbackStatus = playbackStatusCodes.Stop;

            if (localSession == true && remoteSession == true)
            {
                forceUpdateSessionInformation("Force Update@" + Dns.GetHostName() + " is exiting. Session is closed ");
            }
            else
            if (remoteSession)
            {
                forceUpdateSessionInformation("Force Update@" + Dns.GetHostName() + " is exiting.");
            }

            performCleanup(false);
        }
Пример #6
0
        private void buttonStop_Click(object sender, EventArgs e)
        {
            try
            {
                if (seekBarThread != null)
                    while (seekBarThread.ThreadState != ThreadState.Stopped)
                        seekBarThread.Abort(seekBarThread.ThreadState);
                vlc.Stop();
                currTime = 0;
                seekBar.Value = 0;

                playErrorCode = LibVlc.LibVlc.Error.Exit;
                playbackStatus = playbackStatusCodes.Stop;
                vlc.PlaylistClear();

                fileName = null;

                if (localSession == true && remoteSession == true)
                {
                    forceUpdateSessionInformation("Force Update@" + Dns.GetHostName() + " is exiting. Session is closed ");
                    initClient.Close();
                    initClient = null;
                }
                else
                    if (remoteSession)
                    {
                        forceUpdateSessionInformation("Force Update@" + Dns.GetHostName() + " is exiting.");
                    }

                performCleanup(true);
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("Exception occurred: {0}", ex);
            }
        }
Пример #7
0
        /// <summary>
        /// Update the seekBar
        /// </summary>
        public void updateseekBar()
        {
            try
            {
                if (seekBar.InvokeRequired)
                {
                    updateSeekBarCallback d = new updateSeekBarCallback(updateseekBar);
                    if (this.IsDisposed == false)
                        Invoke(d);
                }
                else
                {
                    if (authenticationDone == false)
                        return;
                    if (vlc.LengthGet > 0)
                    {
                        seekBar.Maximum = vlc.LengthGet;
                        seekBar.LargeChange = 1;
                        if (vlc.TimeGet < vlc.LengthGet)
                        {
                            if (vlc.TimeGet > currTime)
                            {
                                currTime = vlc.TimeGet;
                                seekBar.Value = currTime;
                            }
                        }
                        else
                        {
                            currTime = 0;
                            seekBar.Value = currTime;
                            seekBarThread.Abort(seekBarThread.ThreadState);
                            playbackStatus = playbackStatusCodes.Stop;
                            vlc.PlaylistClear();
                            fileName = null;

                            if (localSession == true && remoteSession == true)
                            {
                                forceUpdateSessionInformation("Force Update@" + Dns.GetHostName() + " is exiting. Session is closed ");
                            }
                            else
                                if (remoteSession)
                                {
                                    forceUpdateSessionInformation("Force Update@" + Dns.GetHostName() + " is exiting.");
                                }

                            performCleanup(true);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("Exception occurred: {0}", ex);
            }
        }