コード例 #1
0
ファイル: ServerRequest.cs プロジェクト: nghoang/settv
        public static List<Channel> GetListYoutubeVD(string content)
        {
            List<Channel> res = new List<Channel>();
            List<string> result_blocks = Utility.SimpleRegex(@"<li class=""yt-grid-box.*?(?=</li>)</li>", content, 0);
            foreach (string block in result_blocks)
            {
                Channel item = new Channel();
                item.channel_image = Utility.SimpleRegexSingle(@"<img src=""//([^""]*)"" alt=""Thumbnail""", block, 1);
                item.channel_image = item.channel_image.Replace("http://", "");
                item.description = Utility.SimpleRegexSingle(@"<p class=""description.*?(?=>)>(.*?)(?=</p>)</p>", block, 1);
                item.channel_url = Utility.SimpleRegexSingle(@"href=""(/watch\?v=[^""]*)""", block, 1);
                item.channel_name = Utility.SimpleRegexSingle(@">([^<]*)</a></h3>", block, 1);

                item.channel_id = item.channel_url;
                item.channel_type = "wmp";
                item.is_youtube = true;
                if (item.channel_name.Trim() == "")
                    continue;
                res.Add(item);
            }
            return res;
        }
コード例 #2
0
ファイル: ServerRequest.cs プロジェクト: nghoang/settv
        public void GetChannel()
        {
            List<Channel> list = new List<Channel>();

            WebClient client = new WebClient();
            string content = "";
            if (search_trial == true)
                content = client.DownloadString(AppConst.SERVER_ADDRESS + "/get_channel?search_trial=1");
            else
                content = client.DownloadString(AppConst.SERVER_ADDRESS + "/get_channel?session_id=" + Register.session_id + "&country=" + seaching_country + "&category=" + seaching_catagory + "&keyword=" + seaching_keyword);

            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(content);
            XmlNodeList nodeList = xmlDoc.GetElementsByTagName("channel");
            foreach (XmlNode node in nodeList)
            {
                Channel item = new Channel();
                item.channel_id = node.Attributes["channel_id"].Value;
                item.channel_name = Utility.URLDecode(node.Attributes["channel_name"].Value);
                item.channel_url = Utility.URLDecode(node.Attributes["channel_url"].Value);
                item.description = Utility.URLDecode(node.Attributes["description"].Value);
                item.channel_type = node.Attributes["channel_type"].Value;
                list.Add(item);
            }

            callback.FinishedLoadChannel(list);
        }
コード例 #3
0
ファイル: MainApp.cs プロジェクト: nghoang/settv
        private void PlayChannel(Channel c)
        {
            lastest_channel = c;
            labelChannelName.Text = c.channel_name;
            //we cannot add youtube as fav channel
            if (c.is_youtube == true)
            {
                buttonAddFavorite.Enabled = false;
            }
            else
            {
                buttonAddFavorite.Visible = true;
                //check to show fav button status
                if (FavoriteChannel.IsInFavList(c) == true)
                {
                    buttonAddFavorite.BackgroundImage = global::settv.Properties.Resources.add_to_fav_bttn_active;
                }
                else
                {
                    buttonAddFavorite.BackgroundImage = global::settv.Properties.Resources.add_to_fav_bttn1;
                }
            }

            //check video type to play
            Console.WriteLine("Play Channel: (" + c.channel_name + ") " + c.channel_url);
            player_flash.Visible = false;
            player_wmp.Visible = false;
            player_web.Visible = false;
            player_vlc.Visible = false;
            StopChannel();
            if (c.channel_type == "flash")
            {
                player_flash.Visible = true;
                player_flash.Movie = c.channel_url;
                player_flash.Play();
            }
            else if (c.channel_type == "web")
            {
                player_web.Visible = true;
                player_web.Url = new Uri(c.channel_url);
            }
            else if (c.channel_type == "vlc")
            {
                //player_vlc.playlist.items.clear();
                //string[] options = { ":vout-filter=deinterlace", ":deinterlace-mode=linear" };
                //player_vlc.playlist.add("http://www.mediacollege.com/video-gallery/testclips/barsandtone.flv", "", options);
                //player_vlc.playlist.playItem(0);
                player_vlc.Visible = true;
                player_vlc.addTarget(c.channel_url, null, AXVLC.VLCPlaylistMode.VLCPlayListReplace, 0);
                player_vlc.play();
            }
            else if (c.channel_type == "wmp")
            {
                //hide all control on windows media player
                player_wmp.Visible = true;
                if (c.is_youtube == true)
                {
                    string youtube_streaming = YoutubeObject.GetYoutubeStreamingURL(c.channel_url);
                    player_wmp.URL = youtube_streaming;
                }
                else
                {
                    player_wmp.URL = c.channel_url;
                }
                player_wmp.Ctlcontrols.play();
                player_wmp.uiMode = "none";
                player_wmp.stretchToFit = true;
            }
            buttonPlay.BackgroundImage = global::settv.Properties.Resources.play_bttn_active;
        }