Пример #1
0
        private void LoadChannels()
        {
            UrlLists urls        = UrlLists.Get();
            Channels channels    = Channels.Get();
            bool     withoutUrls = false;
            bool     refreshList = false;

            if (urls.Lists.Count > 0)
            {
                channels.SetUrl(urls.Lists[urls.Selected]);
            }
            else
            {
                channels.SetUrl(new UrlObject()
                {
                    Name = "NONE", URL = "http://no_url"
                });
                withoutUrls = true;
            }
            if (!withoutUrls && File.Exists(Utils.CONF_PATH + "\\lists\\" + urls.Lists[urls.Selected].Name + "_cache.json"))
            {
                channels = Channels.LoadFromJSON();
                fillChannelList();
                DateTime creationCacheChannel = File.GetLastWriteTimeUtc(Utils.CONF_PATH + "\\lists\\" + urls.Lists[urls.Selected].Name + "_cache.json");
                if (File.Exists(Utils.CONF_PATH + "\\lists\\" + urls.Lists[urls.Selected].Name + "_cache.json") &&
                    creationCacheChannel.Day < DateTime.Now.Day - 1)
                {
                    refreshList = true;
                }
            }
            else
            {
                ChannelInfo ch = new ChannelInfo();
                ch.Title = Strings.DEFAULT_MSG_NO_LIST;
                ListViewItem i = new ListViewItem("0");
                i.SubItems.Add(Strings.DEFAULT_MSG_NO_LIST);
                chList.Invoke((System.Threading.ThreadStart) delegate
                {
                    chList.Items.Add(i);
                });
                var x = new ChannelListItem(ch.Title, ch.ChNumber);
                x.Seen   = ch.seen;
                x.Resume = ch.currentPostion != null;
                lstListsChannels[ALL_GROUP].Add(x);
                lstChannels.Add(x);
                if (urls.Lists.Count > 0 && !File.Exists(Utils.CONF_PATH + "\\lists\\" + urls.Lists[urls.Selected].Name + "_cache.json"))
                {
                    refreshList = true;
                }
            }

            FillGroups();

            if (refreshList)
            {
                RefreshChList(true);
            }
        }
Пример #2
0
        private void Ok()
        {
            string lastList = config.AppSettings.Settings["Url"].Value;

            if (lastList != txtURL.Text)
            {
                config.AppSettings.Settings["Url"].Value = txtURL.Text;
                Channels channels = Channels.Get();
                channels.SetUrl(txtURL.Text);
                channels.SetNeedRefresh(true);
                ConfigurationManager.RefreshSection("appSettings");
            }

            string lastEPG = config.AppSettings.Settings["Epg"].Value;

            if (lastEPG != txtEPG.Text)
            {
                config.AppSettings.Settings["Epg"].Value = txtEPG.Text;
                EPG_DB epgDB = EPG_DB.Get();
                epgDB.Refresh = true;
                ConfigurationManager.RefreshSection("appSettings");
            }
            config.AppSettings.Settings["audio"].Value = Utils.GetAudioConfName(audio.SelectedItem.ToString());
            config.AppSettings.Settings["sub"].Value   = Utils.GetSubConfName(sub.SelectedItem.ToString());
            config.Save(ConfigurationSaveMode.Modified);
            this.Close();
            this.Dispose();
        }
 public static Channels Get()
 {
     if (instance == null)
     {
         instance = new Channels();
         if (UrlLists.Get().Lists.Count > 0)
         {
             instance.SetUrl(UrlLists.Get().Lists[UrlLists.Get().Selected]);
         }
         else
         {
             instance.SetUrl(new UrlObject()
             {
                 Name = "NONE", URL = "http://no_url"
             });
         }
     }
     return(instance);
 }
Пример #4
0
        public static Channels Get()
        {
            if (instance == null)
            {
                instance = new Channels();

                instance.SetUrl(AmiConfiguration.Get().URL_IPTV);
            }
            return(instance);
        }
Пример #5
0
 public static Channels Get()
 {
     if (instance == null)
     {
         instance = new Channels();
         Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
         instance.SetUrl(config.AppSettings.Settings["Url"].Value);
     }
     return(instance);
 }
Пример #6
0
        private void LoadChannels()
        {
            Channels channels = Channels.Get();

            channels.SetUrl(AmiConfiguration.Get().URL_IPTV);
            if (File.Exists(Utils.CONF_PATH + "channelCache.json"))
            {
                channels = Channels.LoadFromJSON();
                fillChannelList();
            }
            else
            {
                ChannelInfo ch = new ChannelInfo();
                ch.Title = Strings.DEFAULT_MSG_NO_LIST;
                ListViewItem i = new ListViewItem("0");
                i.SubItems.Add(Strings.DEFAULT_MSG_NO_LIST);
                chList.Items.Add(i);
                var x = new ChannelListItem(ch.Title, ch.ChNumber);
                x.Seen   = ch.seen;
                x.Resume = ch.currentPostion != null;
                lstListsChannels[ALL_GROUP].Add(x);
                lstChannels.Add(x);
            }

            cmbGroups.Items.Clear();

            foreach (string group in lstListsChannels.Keys)
            {
                cmbGroups.Items.Add(group);
            }
            cmbGroups.SelectedIndex = 0;

            DateTime creationCacheChannel = File.GetLastWriteTimeUtc(Utils.CONF_PATH + "channelCache.json");

            if (File.Exists(Utils.CONF_PATH + "channelCache.json") &&
                creationCacheChannel.Day < DateTime.Now.Day - 1)
            {
                RefreshChList(false);
            }
        }
Пример #7
0
        private void Form1_Load(object sender, EventArgs e)
        {
            lbVersion.Text = ApplicationDeployment.IsNetworkDeployed
               ? ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString()
               : Assembly.GetExecutingAssembly().GetName().Version.ToString();

            config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            chList.FullRowSelect                = true;
            player.MediaUnloaded               += StopPlayEvent;
            player.MediaLoaded                 += MediaLoaded;
            player.Volume                       = 100;
            trVolumen.Value                     = Convert.ToInt32(player.Volume / 2);
            btnMuteUnmute.BackgroundImage       = Image.FromFile("./resources/images/unmute.png");
            btnMuteUnmute.BackgroundImageLayout = ImageLayout.Stretch;

            btnPlayPause.BackgroundImage       = Image.FromFile("./resources/images/play.png");
            btnPlayPause.BackgroundImageLayout = ImageLayout.Stretch;

            btnStop.BackgroundImage       = Image.FromFile("./resources/images/stop.png");
            btnStop.BackgroundImageLayout = ImageLayout.Stretch;

            EPG_DB epg = EPG_DB.Get();

            epg.epgEventFinish += FinishLoadEpg;
            DefaultEpgLabels();
            logoEPG.Image = Image.FromFile("./resources/images/info.png");
            Channels channels = Channels.Get();

            channels.SetUrl(config.AppSettings.Settings["Url"].Value);
            if (File.Exists(System.Environment.GetEnvironmentVariable("USERPROFILE") + "\\channelCache.json"))
            {
                channels = Channels.LoadFromJSON();
                fillChannelList();
            }
            else
            {
                ChannelInfo ch = new ChannelInfo();
                ch.Title = "Please load iptv list";
                ListViewItem i = new ListViewItem("0");
                i.SubItems.Add("Please load iptv list");
                chList.Items.Add(i);
                lstChannels.Add(ch);
            }

            DateTime creationCacheChannel = File.GetLastWriteTimeUtc(System.Environment.GetEnvironmentVariable("USERPROFILE") + "\\channelCache.json");

            if (File.Exists(System.Environment.GetEnvironmentVariable("USERPROFILE") + "\\channelCache.json") &&
                creationCacheChannel.Day < DateTime.Now.Day - 1)
            {
                RefreshChList(false);
            }


            if (File.Exists(System.Environment.GetEnvironmentVariable("USERPROFILE") + "\\amiiptvepgCache.json"))
            {
                epg = EPG_DB.LoadFromJSON();
            }

            DateTime creation = File.GetLastWriteTimeUtc(System.Environment.GetEnvironmentVariable("USERPROFILE") + "\\amiiptvepgCache.json");

            if (File.Exists(System.Environment.GetEnvironmentVariable("USERPROFILE") + "\\amiiptvepgCache.json") &&
                creation.Day < DateTime.Now.Day - 1)
            {
                //DownloadEPGFile(epg, config.AppSettings.Settings["Epg"].Value);
            }
            else
            {
                if (File.Exists(System.Environment.GetEnvironmentVariable("USERPROFILE") + "\\amiiptvepgCache.json"))
                {
                    epg = EPG_DB.LoadFromJSON();
                }
                else if (File.Exists(System.Environment.GetEnvironmentVariable("USERPROFILE") + "\\amiiptvepg.xml"))
                {
                    lbProcessingEPG.Text = "Loading...";
                    epg.ParseDB();
                }
                else
                {
                    DownloadEPGFile(epg, "http://bit.ly/AVappEPG");

                    config.AppSettings.Settings["Epg"].Value = "http://bit.ly/AVappEPG";
                    ConfigurationManager.RefreshSection("appSettings");
                    config.Save(ConfigurationSaveMode.Modified);
                }
            }
            player.API.SetPropertyString("deinterlace", "yes");
        }
Пример #8
0
        private void Ok()
        {
            AmiConfiguration amiconf = AmiConfiguration.Get();
            var encode = Utils.Base64Encode(txtParentalControl.Text);

            if (amiconf.PARENTAL_PASS != encode && !string.IsNullOrEmpty(txtParentalControl.Text))
            {
                if (!string.IsNullOrEmpty(amiconf.PARENTAL_PASS))
                {
                    using (var askForm = new AskPass())
                    {
                        var result = askForm.ShowDialog();
                        if (result == DialogResult.Cancel)
                        {
                            return;
                        }
                    }
                }
                amiconf.PARENTAL_PASS = encode;
            }
            if (string.IsNullOrEmpty(txtParentalControl.Text) && !string.IsNullOrEmpty(amiconf.PARENTAL_PASS))
            {
                if (!string.IsNullOrEmpty(amiconf.PARENTAL_PASS))
                {
                    using (var askForm = new AskPass())
                    {
                        var result = askForm.ShowDialog();
                        if (result == DialogResult.Cancel)
                        {
                            return;
                        }
                    }
                }

                amiconf.PARENTAL_PASS = "";
            }
            if (amiconf.URL_IPTV != txtURL.Text)
            {
                amiconf.URL_IPTV = txtURL.Text;
                Channels channels = Channels.Get();
                channels.SetUrl(txtURL.Text);
                channels.SetNeedRefresh(true);
            }
            else
            {
                Channels channels = Channels.Get();
                channels.SetNeedRefresh(false);
            }
            if (amiconf.REQ_EMAIL != txtRequestEmail.Text)
            {
                amiconf.REQ_EMAIL = txtRequestEmail.Text;
            }

            if (amiconf.URL_EPG != txtEPG.Text)
            {
                amiconf.URL_EPG = txtEPG.Text;
                EPG_DB epgDB = EPG_DB.Get();
                epgDB.Refresh = true;
            }
            if (!amiconf.ENABLE_LOG && chLog.Checked)
            {
                amiconf.ENABLE_LOG = true;
                PrincipalForm.RepaintLabels();
            }
            if (amiconf.ENABLE_LOG && !chLog.Checked)
            {
                amiconf.ENABLE_LOG = false;
                PrincipalForm.RepaintLabels();
            }
            amiconf.DEF_LANG = Utils.GetAudioConfName(audio.SelectedItem.ToString());
            amiconf.DEF_SUB  = Utils.GetSubConfName(sub.SelectedItem.ToString());

            using (StreamWriter file = File.CreateText(Utils.CONF_PATH + "amiIptvConf.json"))
            {
                JsonSerializer serializer = new JsonSerializer();
                serializer.Serialize(file, amiconf);
            }

            this.Close();
            this.Dispose();
        }