Exemple #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);
            }
        }
Exemple #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);
            }
        }
Exemple #3
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);
            }
        }