public Boolean IsInFav(Channel ch) { foreach (Channel c in favList) { if (c.id == ch.id) { return true; } } return false; }
public void AddFavorite(Channel ch) { InitFav(); LoadFavorite(); foreach (Channel c in favList) { if (c.id == ch.id) return; } favList.Add(ch); SaveFav(); }
public void DeleteFavorite(Channel ch) { InitFav(); LoadFavorite(); for (int i = 0; i < favList.Count; i++) { if (ch.id == favList[i].id) { favList.RemoveAt(i); SaveFav(); return; } } }
public static Channel ParseChannel(GeneralBlock c) { try { Channel ch = new Channel(); ch.id = Utility.URLDecode(ParserLib.GetBlockSingle(c.innerHtml, "channel", "", "", "", "", "", "id").value); ch.name = Utility.URLDecode(ParserLib.GetBlockSingle(c.innerHtml, "channel", "", "", "", "", "", "name").value); ch.description = Utility.URLDecode(ParserLib.GetBlockSingle(c.innerHtml, "channel", "", "", "", "", "", "channel_description").value); ch.web = Utility.URLDecode(ParserLib.GetBlockSingle(c.innerHtml, "channel", "", "", "", "", "", "link").value); ch.country = Utility.URLDecode(ParserLib.GetBlockSingle(c.innerHtml, "channel", "", "", "", "", "", "country").value); ch.is_stream = Utility.URLDecode(ParserLib.GetBlockSingle(c.innerHtml, "channel", "", "", "", "", "", "stream_type").value); ch.stream = Utility.URLDecode(ParserLib.GetBlockSingle(c.innerHtml, "channel", "", "", "", "", "", "channel_link").value); ch.channel_type = Utility.URLDecode(ParserLib.GetBlockSingle(c.innerHtml, "channel", "", "", "", "", "", "video_type").value); ch.image_url = Utility.URLDecode(ParserLib.GetBlockSingle(c.innerHtml, "channel", "", "", "", "", "", "logo_path").value); if (ParserLib.GetBlockSingle(c.innerHtml, "channel", "", "", "", "", "", "rating").value != "") ch.rating = double.Parse(ParserLib.GetBlockSingle(c.innerHtml, "channel", "", "", "", "", "", "rating").value); return ch; } catch (Exception ex) { Console.WriteLine(ex.Message); } return null; }
private void AddChannel(Channel ch) { if (this.InvokeRequired == true) { this.Invoke(new DeCallbackChannel(AddChannel), ch); return; } string local_image = ch.image_url; string icon_key = ch.country.ToUpper(); bool isShowLogo = true; if (Utility.ReadAppRegistry("TVKing2", "show_logo") == "0") isShowLogo = false; if (server_config_showlogo == false) { isShowLogo = false; } if (local_image != "" && isShowLogo == true) { string image_ext = local_image.Split('.')[local_image.Split('.').Length - 1]; local_image = Utility.md5String(local_image); local_image = local_image + "." + image_ext; bool isDownloadable = true; if (File.Exists("logos\\" + local_image) == false && local_image != "") { isDownloadable = Utility.DownloadFile(ch.image_url, "logos\\" + local_image); if (isDownloadable == false && File.Exists("logos\\" + local_image) == true) { FileInfo f = new FileInfo("logos\\" + local_image); long filesize = f.Length; if (filesize == 0) { File.Delete("logos\\" + local_image); } } } if (isDownloadable == true) icon_key = local_image; if (!flagList.Images.ContainsKey(icon_key) && icon_key != "") { try { Image flag_image = Image.FromFile("logos\\" + icon_key); flagList.Images.Add(icon_key, flag_image); lvStream.SetImageList(flagList); lvWeb.SetImageList(flagList); } catch (Exception ex) { File.Delete("logos\\" + icon_key); } } } string chName = ch.name; if (chName.Length > 20) chName = chName.Substring(0, 20); if (ch.is_stream == "1") lvStream.AddItem(ch.id.ToString(), chName, icon_key, ch.rating); else lvWeb.AddItem(ch.id.ToString(), chName, icon_key, ch.rating); lbCountStream.Text = streamList.Count.ToString(); lbCountWeb.Text = webList.Count.ToString(); }
private void tmAutoPlay_Tick(object sender, EventArgs e) { try { if (lvStream.CountItems() > 0) { tmAutoPlay.Enabled = false; Channel def = new Channel(); def.name = Utility.ReadAppRegistry("TVKing2", "def_name"); def.stream = Utility.ReadAppRegistry("TVKing2", "def_stream"); def.channel_type = Utility.ReadAppRegistry("TVKing2", "def_type"); lvStream.DefaultItem = Utility.ReadAppRegistry("TVKing2", "def_id"); currentPlayingChannel = def; player_flash.Visible = false; //player.Visible = false; player_wmp.Visible = false; if (def.stream == "" || def.stream == null) { lvStream.SelectedItem(0); string selectedId = lvStream.SelectedId(); foreach (Channel ch in streamList) { if (ch.id == selectedId) { PlaySelectedStream(ch); break; } } } else { txtTitle.Text = def.name; PlayCurrentChannel(); } } } catch (Exception ex) { Utility.WriteLog(ex.Message); Utility.WriteLog(ex.StackTrace); } }
private void PlaySelectedStream(Channel ch) { timerSeeking.Enabled = false; HideYoutubeControl(); playingYoutube = false; if (isStop == true) { tvkTrialScreen1.Visible = true; pbErrorBG.Visible = true; MessageBox.Show("Trial time is end. Please register to continue.", "Trial Version", MessageBoxButtons.OK); return; } currentPlayingChannel = ch; galleryControlYoutube.Visible = false; barText.Text = "Loading channel " + ch.name + " ..."; barText.Visible = true; barProgress.Visible = true; pnStatus.Visible = true; currentPlayingChannel = ch; isShownAds = false; pbFullScreen.Visible = true; pbErrorBG.Visible = false; lbErrorPlayer.Visible = false; Console.WriteLine("web: " + ch.web); Console.WriteLine("stream: " + ch.stream); StopPlaying(); player_wmp.Visible = false; player_flash.Visible = false; if (favList.IsInFav(ch) == true) { pbRevFav.Visible = true; pbAddFav.Visible = false; } else { pbRevFav.Visible = false; pbAddFav.Visible = true; } if (ch.channel_type == AppConst.STREAM_TYPE_FLASH) { player_flash.Visible = true; player_flash.Movie = ch.stream;//.Replace("[divider]", "#").Replace("[divider2]", ";"); player_flash.Play(); } else if (ch.channel_type == AppConst.STREAM_TYPE_WMP) { player_wmp.Visible = true; player_wmp.URL = ch.stream; } //else //{ // flash.Visible = false; // player.Visible = true; // wplayer.Visible = false; // wplayer.URL = ""; // flash.Movie = "http://"; // player.playlistClear(); // string url = ch.stream; // player.addTarget(url, null, AXVLC.VLCPlaylistMode.VLCPlayListReplace, 0); // player.play(); //} }
public void LoadFavorite() { InitFav(); string res = Utility.ReadFile(favoriteFile); List<string> ids = Utility.ReadAttribueXpath(res, "/fs/f", "id"); List<string> names = Utility.ReadAttribueXpath(res, "/fs/f", "name"); List<string> webs = Utility.ReadAttribueXpath(res, "/fs/f", "web"); List<string> streams = Utility.ReadAttribueXpath(res, "/fs/f", "stream"); List<string> countries = Utility.ReadAttribueXpath(res, "/fs/f", "country"); List<string> channel_types = Utility.ReadAttribueXpath(res, "/fs/f", "channel_type"); List<string> image_urls = Utility.ReadAttribueXpath(res, "/fs/f", "image_url"); List<string> descriptions = Utility.ReadAttribueXpath(res, "/fs/f", "description"); List<string> is_streams = Utility.ReadAttribueXpath(res, "/fs/f", "is_stream"); favList.Clear(); for (int i = 0; i < ids.Count; i++) { Channel ch = new Channel(); ch.id = Utility.URLDecode(ids[i]); ch.name = Utility.URLDecode(names[i]); ch.web = Utility.URLDecode(webs[i]); ch.stream = Utility.URLDecode(streams[i]); ch.country = Utility.URLDecode(countries[i]); ch.channel_type = Utility.URLDecode(channel_types[i]); ch.image_url = Utility.URLDecode(image_urls[i]); ch.description = Utility.URLDecode(descriptions[i]); ch.is_stream = Utility.URLDecode(is_streams[i]); favList.Add(ch); } }