Пример #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="commentId"></param>
        /// <param name="userId"></param>
        /// <param name="videoURL"></param>
        /// <returns></returns>
        public bool AddVideoInfo (string commentId, string userId, string videoURL)
        {

            string videoId;

            if (!anariseCommentURL(videoURL, out videoId))
            {
                return false;
            }

            // 動画情報取得
            string URLString = "http://www.nicovideo.jp/api/getthumbinfo/" + videoId;

            try
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(URLString);

                string tempTitle = "";
                string tempTime = "";
                string tempURL = "";
                string thumbnail = "";

                XmlNodeList node1 = doc.GetElementsByTagName("title");
                if (node1.Count >= 1) tempTitle = node1[0].InnerText;
                XmlNodeList node2 = doc.GetElementsByTagName("length");
                if (node2.Count >= 1) tempTime = node2[0].InnerText;
                XmlNodeList node3 = doc.GetElementsByTagName("watch_url");
                if (node3.Count >= 1) tempURL = node3[0].InnerText;
                XmlNodeList node4 = doc.GetElementsByTagName("thumbnail_url");
                if (node4.Count >= 1) thumbnail = node4[0].InnerText;

                // 動画情報パネル追加
                VideoInfoPanel tempVideoInfoPanel = new VideoInfoPanel();
                
                tempVideoInfoPanel.CommentNo = commentId;
                tempVideoInfoPanel.UserID = userId;
                tempVideoInfoPanel.VideoTitle = tempTitle;
                tempVideoInfoPanel.VideoTime = tempTime;
                tempVideoInfoPanel.VideoURL = tempURL;
                tempVideoInfoPanel.ThumbnailURL = thumbnail;

                // 合計時間 加算
                TimeSpan interval = new TimeSpan(0,Int32.Parse(tempTime.Split(':')[0]), Int32.Parse(tempTime.Split(':')[1]));
                timeSum += interval;
                this.labelTimeSum.Text = timeSum.ToString(@"mm\:ss");

                Point tempPoint = new Point(3, 10 + (tempVideoInfoPanel.Size.Height * videoInfoList.Count));
                tempPoint.Offset(panelVideoInfoList.AutoScrollPosition);
                tempVideoInfoPanel.Location = tempPoint;

                ShowReqInfo2BSP(userId, videoId);

                tempVideoInfoPanel.EventManageButtonClick += new VideoInfoEventHandler(ManageButtonsClick);

                videoInfoList.Add(tempVideoInfoPanel);

                panelVideoInfoList.Controls.Add(videoInfoList.Last());
                
            }
            catch (Exception ex)
            {
                return false;
            }
            
            return true;

        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="commentId"></param>
        /// <param name="userId"></param>
        /// <param name="videoURL"></param>
        /// <returns></returns>
        public bool AddVideoInfo(string commentId, string userId, string videoURL)
        {
            string videoId;

            if (!anariseCommentURL(videoURL, out videoId))
            {
                return(false);
            }

            // 動画情報取得
            string URLString = "http://www.nicovideo.jp/api/getthumbinfo/" + videoId;

            try
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(URLString);

                string tempTitle = "";
                string tempTime  = "";
                string tempURL   = "";
                string thumbnail = "";

                XmlNodeList node1 = doc.GetElementsByTagName("title");
                if (node1.Count >= 1)
                {
                    tempTitle = node1[0].InnerText;
                }
                XmlNodeList node2 = doc.GetElementsByTagName("length");
                if (node2.Count >= 1)
                {
                    tempTime = node2[0].InnerText;
                }
                XmlNodeList node3 = doc.GetElementsByTagName("watch_url");
                if (node3.Count >= 1)
                {
                    tempURL = node3[0].InnerText;
                }
                XmlNodeList node4 = doc.GetElementsByTagName("thumbnail_url");
                if (node4.Count >= 1)
                {
                    thumbnail = node4[0].InnerText;
                }

                // 動画情報パネル追加
                VideoInfoPanel tempVideoInfoPanel = new VideoInfoPanel();

                tempVideoInfoPanel.CommentNo    = commentId;
                tempVideoInfoPanel.UserID       = userId;
                tempVideoInfoPanel.VideoTitle   = tempTitle;
                tempVideoInfoPanel.VideoTime    = tempTime;
                tempVideoInfoPanel.VideoURL     = tempURL;
                tempVideoInfoPanel.ThumbnailURL = thumbnail;

                // 合計時間 加算
                TimeSpan interval = new TimeSpan(0, Int32.Parse(tempTime.Split(':')[0]), Int32.Parse(tempTime.Split(':')[1]));
                timeSum += interval;
                this.labelTimeSum.Text = timeSum.ToString(@"mm\:ss");

                Point tempPoint = new Point(3, 10 + (tempVideoInfoPanel.Size.Height * videoInfoList.Count));
                tempPoint.Offset(panelVideoInfoList.AutoScrollPosition);
                tempVideoInfoPanel.Location = tempPoint;

                ShowReqInfo2BSP(userId, videoId);

                tempVideoInfoPanel.EventManageButtonClick += new VideoInfoEventHandler(ManageButtonsClick);

                videoInfoList.Add(tempVideoInfoPanel);

                panelVideoInfoList.Controls.Add(videoInfoList.Last());
            }
            catch (Exception ex)
            {
                return(false);
            }

            return(true);
        }