private void LoadEPG() { EPG_DB epg = EPG_DB.Get(); epg.epgEventFinish += FinishLoadEpg; DefaultEpgLabels(); logoEPG.Image = Image.FromFile("./resources/images/info.png"); if (File.Exists(Utils.CONF_PATH + "amiiptvepgCache.json")) { epg = EPG_DB.LoadFromJSON(); } DateTime creation = File.GetLastWriteTimeUtc(Utils.CONF_PATH + "amiiptvepgCache.json"); if (File.Exists(Utils.CONF_PATH + "amiiptvepgCache.json") && creation.Day < DateTime.Now.Day - 1) { DownloadEPGFile(epg, AmiConfiguration.Get().URL_EPG); } else { if (File.Exists(Utils.CONF_PATH + "amiiptvepgCache.json")) { epg = EPG_DB.LoadFromJSON(); } else if (File.Exists(Utils.CONF_PATH + "amiiptvepg.xml")) { lbProcessingEPG.Text = Strings.LOADING; epg.ParseDB(); } else { DownloadEPGFile(epg, "http://bit.ly/AVappEPG"); AmiConfiguration amiConf = AmiConfiguration.Get(); amiConf.URL_EPG = "http://bit.ly/AVappEPG"; using (StreamWriter file = File.CreateText(Utils.CONF_PATH + "amiIptvConf.json")) { JsonSerializer serializer = new JsonSerializer(); serializer.Serialize(file, amiConf); } } } }
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"); }