Exemple #1
0
 public FrmAdd(ListStreams list, String caption, String url, String quality)
     : this(list)
 {
     txtCaption.Text = caption;
     txtURL.Text     = url;
     txtQuality.Text = quality;
 }
 public FrmAdd(ListStreams list, String caption, String url, String quality)
     : this(list)
 {
     txtCaption.Text = caption;
     txtURL.Text = url;
     txtQuality.Text = quality;
 }
        public FrmAdd(ListStreams list)
        {
            InitializeComponent();

            btnAdd.Enabled = false;

            listStreams = list;
        }
Exemple #4
0
        public FrmAdd(ListStreams list)
        {
            InitializeComponent();

            btnAdd.Enabled = false;

            listStreams = list;
        }
Exemple #5
0
        public FrmAdd(ListStreams list, int index, Boolean clone) : this(list)
        {
            txtCaption.Text = listStreams[index].Caption;
            txtURL.Text     = listStreams[index].StreamUrl;
            txtQuality.Text = listStreams[index].Quality;

            if (!clone)
            {
                modifyIndex = index;

                btnAdd.Visible    = false;
                btnModify.Visible = true;
            }
        }
        public FrmAdd(ListStreams list, int index, Boolean clone)
            : this(list)
        {
            txtCaption.Text = listStreams[index].Caption;
            txtURL.Text = listStreams[index].StreamUrl;
            txtQuality.Text = listStreams[index].Quality;

            if (!clone)
            {
                modifyIndex = index;

                btnAdd.Visible = false;
                btnModify.Visible = true;
            }
        }
Exemple #7
0
        public static void saveStreamListConfig(ListStreams list)
        {
            XmlTextWriter xw        = null;
            Stream        tmpStream = null;

            try
            {
                xw            = new XmlTextWriter(StreamXMLFile, Encoding.UTF8);
                xw.Formatting = Formatting.Indented;

                xw.WriteStartDocument(true);

                xw.WriteStartElement("DesktopLiveStreamer");

                // Le parametre de chemin du livestreamer
                xw.WriteElementString("LiveStreamerExecutable", LiveStreamerExecutable);

                // Le parametre de chemin de VLC
                xw.WriteElementString("VLCExecutable", VLCExecutable);

                // Le parametre de la qualité préferée
                xw.WriteElementString("PreferedQuality", PreferedQuality);

                for (int i = 0; i < list.getSize(); i++)
                {
                    tmpStream = list[i];

                    xw.WriteStartElement("Stream");
                    xw.WriteElementString("Caption", tmpStream.Caption);
                    xw.WriteElementString("URL", tmpStream.StreamUrl);
                    xw.WriteElementString("Quality", tmpStream.Quality);
                    xw.WriteEndElement();
                }

                xw.WriteEndElement();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (xw != null)
                {
                    xw.Close();
                }
            }
        }
        private void FrmStreams_Load(object sender, EventArgs e)
        {
            listGames = new ListGames();
            listFavoriteStreams = new ListStreams();
            listLiveStreams = new ListStreams();

            XMLPersist.StreamXMLFile = "streamlist.xml";
            XMLPersist.GameXMLFile = "gamelist.xml";

            try
            {
                XMLPersist.loadStreamListConfig(listFavoriteStreams);
            }
            catch (FileNotFoundException)
            {
                // critical problem, the file needs to exist
                MessageBox.Show(this, "Error: Unable to load configuration file 'streamlist.xml'. Check if it " +
                            "exists in the directory of the application and is readable.",
                            "Configuration file not found", MessageBoxButtons.OK, MessageBoxIcon.Error);

                this.Close();
            }

            try
            {

                XMLPersist.loadGameListConfig(listGames);
            }
            catch (FileNotFoundException)
            {
                // Not very serious, the config file will be created later
                Console.WriteLine("An XML configuration file wasn't found");
            }

            // Check if VLC executable is found
            if (XMLPersist.VLCExecutable != null && !File.Exists(XMLPersist.VLCExecutable.Replace("\\\" --file-caching=5000", "").Replace("\\\"", "")))
            {
                // Try to get VLC directory from registry
                String path = ReadVLCExecutable();
                if (path != null && File.Exists(path))
                {
                    XMLPersist.VLCExecutable = "\\\"" + path + "\\\" --file-caching=5000"; ;
                    try
                    {
                        XMLPersist.saveStreamListConfig(listFavoriteStreams);
                    }
                    catch (UnauthorizedAccessException)
                    {
                        MessageBox.Show(this, "Error: Unable to save the configuration. Check if you have write " +
                                    "permissions on the directory of the application.\n" +
                                    "Desktop Live Streamer may require administrative rights on some systems.", "Write permission required", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    DialogResult r = MessageBox.Show(this,
                        "VLC player doesn't appear to be installed or has been put in a different directory. Would you like to specify its path now ?",
                        "VLC Player not found",
                        MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    if (r == DialogResult.Yes)
                        btnChangeVLC_Click(this, EventArgs.Empty);
                }
            }

            // Check if LiveStreamer executable is found
            if (XMLPersist.LiveStreamerExecutable != null && !File.Exists(XMLPersist.LiveStreamerExecutable))
            {
                DialogResult r = MessageBox.Show(this,
                    "LiveStreamer doesn't appear to be installed or has been put in a different directory. Would you like to specify its path now ?",
                    "LiveStreamer not found",
                    MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                if (r == DialogResult.Yes)
                    btnChangeStreamer_Click(this, EventArgs.Empty);
            }

            updateComboGames();

            if (listGames.getSize() == 0)
            {
                btnChangeGame.Visible = false;
                btnValidateGame.Visible = true;

                loadAllGames = false;
                updateGamesThread = new Thread(new ThreadStart(updateGames));
                updateGamesThread.Start();
            }
            else
            {
                imgCmbGames.Enabled = false;
                btnUpdateGames.Enabled = false;
                btnUpdateGameMenu.Enabled = false;
                btnValidateGame.Visible = false;
                btnChangeGame.Visible = true;

                updateLiveStreamsThread = new Thread(new ThreadStart(updateLiveStreams));
                updateLiveStreamsThread.Start();
            }

            updateComboStreams();

            playing = false;
            btnStop.Enabled = false;
            btnPlay.Enabled = false;
            btnOpenBrowser.Enabled = false;

            radioList2.Checked = true;

            groupFavorites.Enabled = false;
            groupLive.Enabled = true;

            cmbQualities.Enabled = false;
            btnAddLiveStream.Enabled = false;

            imgCmbStreams_SelectedIndexChanged(this, EventArgs.Empty);
        }
        public static void loadStreamListConfig(ListStreams list)
        {
            XmlTextReader xr = null;
            int attributs_lus;
            Stream tmpStream = null;
            try
            {
                xr = new XmlTextReader(StreamXMLFile);

                while (xr.Read())
                {
                    if (xr.NodeType == XmlNodeType.Element && xr.Name == "Stream")
                    {
                        tmpStream = new Stream();
                        attributs_lus = 0;
                        while (xr.Read())
                        {
                            // Lecture des attributs de personne
                            if (xr.NodeType == XmlNodeType.Element && xr.Name == "Caption")
                            {
                                xr.Read();
                                tmpStream.Caption = xr.Value.Trim();
                                attributs_lus++;
                            }
                            else if (xr.NodeType == XmlNodeType.Element && xr.Name == "URL")
                            {
                                xr.Read();
                                tmpStream.StreamUrl = xr.Value.Trim();
                                attributs_lus++;
                            }
                            else if (xr.NodeType == XmlNodeType.Element && xr.Name == "Quality")
                            {
                                xr.Read();
                                tmpStream.Quality = xr.Value.Trim();
                                attributs_lus++;
                            }

                            // Sortie de while quand tous les attributs on été lu
                            if (attributs_lus == 3)
                            {
                                list.add(tmpStream);
                                break;
                            }

                        }
                    }
                    else if (xr.NodeType == XmlNodeType.Element && xr.Name == "LiveStreamerExecutable")
                    {
                        xr.Read();
                        LiveStreamerExecutable = xr.Value.Trim();
                    }
                    else if (xr.NodeType == XmlNodeType.Element && xr.Name == "VLCExecutable")
                    {
                        xr.Read();
                        VLCExecutable = xr.Value.Trim();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (xr != null)
                    xr.Close();
            }
        }
        public static void saveStreamListConfig(ListStreams list)
        {
            XmlTextWriter xw = null;
            Stream tmpStream = null;
            try
            {
                xw = new XmlTextWriter(StreamXMLFile, Encoding.UTF8);
                xw.Formatting = Formatting.Indented;

                xw.WriteStartDocument(true);

                xw.WriteStartElement("DesktopLiveStreamer");

                // Le parametre de chemin du livestreamer
                xw.WriteElementString("LiveStreamerExecutable", LiveStreamerExecutable);

                // Le parametre de chemin de VLC
                xw.WriteElementString("VLCExecutable", VLCExecutable);

                for (int i = 0; i < list.getSize(); i++)
                {
                    tmpStream = list[i];

                    xw.WriteStartElement("Stream");
                    xw.WriteElementString("Caption", tmpStream.Caption);
                    xw.WriteElementString("URL", tmpStream.StreamUrl);
                    xw.WriteElementString("Quality", tmpStream.Quality);
                    xw.WriteEndElement();
                }

                xw.WriteEndElement();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (xw != null)
                    xw.Close();
            }
        }
Exemple #11
0
        public static void loadStreamListConfig(ListStreams list)
        {
            XmlTextReader xr = null;
            int           attributs_lus;
            Stream        tmpStream = null;

            try
            {
                xr = new XmlTextReader(StreamXMLFile);

                while (xr.Read())
                {
                    if (xr.NodeType == XmlNodeType.Element && xr.Name == "Stream")
                    {
                        tmpStream     = new Stream();
                        attributs_lus = 0;
                        while (xr.Read())
                        {
                            // Lecture des attributs de personne
                            if (xr.NodeType == XmlNodeType.Element && xr.Name == "Caption")
                            {
                                xr.Read();
                                tmpStream.Caption = xr.Value.Trim();
                                attributs_lus++;
                            }
                            else if (xr.NodeType == XmlNodeType.Element && xr.Name == "URL")
                            {
                                xr.Read();
                                tmpStream.StreamUrl = xr.Value.Trim();
                                attributs_lus++;
                            }
                            else if (xr.NodeType == XmlNodeType.Element && xr.Name == "Quality")
                            {
                                xr.Read();
                                tmpStream.Quality = xr.Value.Trim();
                                attributs_lus++;
                            }

                            // Sortie de while quand tous les attributs on été lu
                            if (attributs_lus == 3)
                            {
                                list.add(tmpStream);
                                break;
                            }
                        }
                    }
                    else if (xr.NodeType == XmlNodeType.Element && xr.Name == "LiveStreamerExecutable")
                    {
                        xr.Read();
                        LiveStreamerExecutable = xr.Value.Trim();
                    }
                    else if (xr.NodeType == XmlNodeType.Element && xr.Name == "VLCExecutable")
                    {
                        xr.Read();
                        VLCExecutable = xr.Value.Trim();
                    }
                    else if (xr.NodeType == XmlNodeType.Element && xr.Name == "PreferedQuality")
                    {
                        xr.Read();
                        PreferedQuality = xr.Value.Trim();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (xr != null)
                {
                    xr.Close();
                }
            }
        }