Example #1
0
        public ActionResult GetVideoList()
        {
            var     stream      = HttpContext.Request.InputStream;
            string  requestJson = new StreamReader(stream).ReadToEnd(); //json 字符串在此
            JObject jo          = (JObject)JsonConvert.DeserializeObject(requestJson);
            int     pageIndex   = Convert.ToInt32(jo["pageIndex"].ToString());
            List <VideoCollections> videoCollections = new List <VideoCollections>();
            List <VideoListData>    videoDataList    = new List <VideoListData>();

            if (pageIndex == 0)
            {
                videoCollections = db.VideoCollections.Where(item => item.IsPublished).OrderByDescending(item => item.Id).Take(10).ToList();
            }
            else
            {
                videoCollections = db.VideoCollections.Where(item => item.Id < pageIndex && item.IsPublished).OrderByDescending(item => item.Id).Take(10).ToList();
            }
            foreach (VideoCollections videoCollection in videoCollections)
            {
                int originalWidth  = 0;
                int originalHeight = 0;
                if (videoCollection.PicIndex != null)
                {
                    System.Drawing.Image imgOriginal = System.Drawing.Image.FromFile(Server.MapPath(HttpUtility.UrlDecode(videoCollection.PicIndex)));
                    originalWidth  = imgOriginal.Width;
                    originalHeight = imgOriginal.Height;
                }
                VideoListData videoData = new VideoListData();
                videoData.Id         = videoCollection.Id;
                videoData.Title      = videoCollection.Title;
                videoData.CreateTime = videoCollection.CreateTime.ToString("yyyy-MM-dd");
                if (videoCollection.PicIndex != null)
                {
                    videoData.PicAD = videoCollection.PicIndex;
                }
                else
                {
                    videoData.PicAD = "";
                }
                videoData.Tags      = videoCollection.Tags;
                videoData.Level     = videoCollection.Grade;
                videoData.PicWidth  = originalWidth;
                videoData.PicHeight = originalHeight;
                videoDataList.Add(videoData);
            }
            return(Json(new { data = videoDataList }));
        }
Example #2
0
        private void Button_Click(object sender, EventArgs e)
        {
            WindowsControl.Button button = sender as WindowsControl.Button;

            //Button click beforedownload started
            try
            {
                ButtonState = button.Content.ToString();
            }
            catch { }

            VideoListData selectedItem = ListOfVideos.SelectedItem as VideoListData;

            //"Actual" button click
            if (selectedItem != null && e != null)
            {
                SharedVariables.CurrentlyPlayed = selectedItem.Vid.ToString();
            }

            //Render all other button's content to Play (except in progress) whenever a new button pressed
            if (ButtonState == "Play")
            {
                foreach (WindowsControl.Button controlButton in FindVisualChildren <WindowsControl.Button>(ListOfVideos))
                {
                    try
                    {
                        if (controlButton.Content.ToString() == "Pause" || controlButton.Content.ToString() == "Resume")
                        {
                            controlButton.Content    = "Play";
                            controlButton.FontWeight = FontWeights.Normal;
                        }
                    }
                    catch { }
                }
            }
            switch (ButtonState)
            {
            case "Play":
                SharedVariables.VideoPlayerIsPlaying = true;
                button.Content    = "Pause";
                button.FontWeight = FontWeights.Bold;

                var FileList = Directory.GetFiles(SharedVariables.path).ToList();
                if (GetDirectoryList().Any(f => f.Contains(SharedVariables.CurrentlyPlayed)))
                {
                    SharedVariables.FullFileName = FileList.FirstOrDefault(s => s.Contains(SharedVariables.CurrentlyPlayed));
                    VideoPlayer.Source           = new Uri(SharedVariables.FullFileName);
                    VideoPlayer.Play();
                    posIndex = VideoList.FirstOrDefault(i => i.Vid == SharedVariables.CurrentlyPlayed).SeqPosition;
                    Title    = SharedVariables.CurrentlyPlayed;
                }
                break;

            case "Pause":
                button.Content = "Resume";
                VideoPlayer.Pause();
                break;

            case "Resume":
                button.Content = "Pause";
                VideoPlayer.Play();
                break;
            }
        }