예제 #1
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            live   = (Live)e.Parameter;
            isLive = true;
            Play(live.Url);
            InitListTapEvent();

            GetList(new Uri(String.Format("https://hdtv.neu6.edu.cn/{0}.review",
                                          live.GetSimpleName())));
        }
예제 #2
0
        private void InitListTapEvent()
        {
            if (listTapHandler == null)
            {
                listTapHandler = new TappedEventHandler((sender, e) =>
                {
                    var o = ((One)((TextBlock)((ListBox)sender).SelectedItem).Tag);

                    playing = o; isLive = false;

                    Play("http://media2.neu6.edu.cn/review/program-"
                         + o.start.ToString() + "-"
                         + o.end.ToString() + "-" + live.GetSimpleName() + ".m3u8");
                });
                see_back_list.Tapped += listTapHandler;
            }
        }
예제 #3
0
        public List <Button> btns       = new List <Button>(); //初始化
        public GridView createGridView(PlayList playList)      //单独创建一个名为我的收藏的gridview,返回值为这个gridview
        {
            grid = new GridView();
            grid.HorizontalAlignment = HorizontalAlignment.Center;
            PivotItem pi1 = new PivotItem
            {
                Header  = playList.Name,
                Content = grid
            };

            mainpage_pivot.Items.Add(pi1);
            grid.IsItemClickEnabled = true;
            grid.ItemClick         += new ItemClickEventHandler((sender, arg) => {
                Live live = (Live)((StackPanel)arg.ClickedItem).Tag;
                //Debug.WriteLine(live.Name);
                root.Navigate(typeof(PlayerPage), live);
                Debug.WriteLine(live.GetSimpleName());
            });
            return(grid);
        }
예제 #4
0
        public static async Task DownloadShowAsync(One show, Live live, IDown d)
        {
            DownManager.down = d;
            // http://media2.neu6.edu.cn/review/program-1524520800-1524526860-chchd.m3u8
            var url = String.Format("http://media2.neu6.edu.cn/review/program-{0}-{1}-{2}.m3u8",
                                    show.start, show.end, live.GetSimpleName());

            Debug.WriteLine(url);
            //创建下载目录
            var downloadDic = await KnownFolders.VideosLibrary.CreateFolderAsync("NEUTV download",
                                                                                 CreationCollisionOption.OpenIfExists);

            //下载m3u8文件
            HttpClient httpClient = new HttpClient();
            var        response   = await httpClient.GetAsync(new Uri(url));

            var res = await response.Content.ReadAsStringAsync();

            Regex           re      = new Regex(@"(?<url>http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?)");
            MatchCollection mc      = re.Matches(res);
            List <String>   urlList = new List <string>();
            var             tsRe    = new Regex(@"(?<ts>[0-9]+\.ts)");

            foreach (Match m in mc)
            {
                var clipUrl = m.Result("${url}");
                urlList.Add(clipUrl);
            }
            if (down != null)
            {
                down.Start(urlList.Count);
            }
            //创建临时文件夹
            var tempDic = await downloadDic.CreateFolderAsync("temp",
                                                              CreationCollisionOption.GenerateUniqueName);

            //下载 视频分片
            var         Tasks = new List <Task>();
            TaskFactory fac   = new TaskFactory();

            Debug.WriteLine("start all");
            try
            {
                Task.Run(() =>
                {
                    Parallel.ForEach <string>(urlList, new ParallelOptions()
                    {
                        MaxDegreeOfParallelism = 10
                    },
                                              videoUrl => {
                        Act(videoUrl, httpClient, tempDic).Wait();
                    });
                }).ContinueWith((obj) =>
                {
                    Debug.WriteLine("end all");
                    SaveVideoFile(tempDic, downloadDic, urlList);
                });
            }
            catch (Exception e)
            {
            }
        }
예제 #5
0
        void AddLivesToPivot(GridView grid, Live a)  //向我的收藏里添加新的频道
        {
            StackPanel itemPanel = new StackPanel();
            TextBlock  t         = new TextBlock
            {
                Text                = a.Name,
                FontSize            = 24,
                HorizontalAlignment = HorizontalAlignment.Center,
            };
            Button c = new Button
            {
                Content             = "\xE00B",
                FontSize            = 24,
                HorizontalAlignment = HorizontalAlignment.Center,
                Tag        = itemPanel,
                Background = new SolidColorBrush(Color.FromArgb(0, 255, 255, 255)),
                FontFamily = font,
                Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 0, 0)),
            };

            c.Click += Favorite_Click;


            Image img = new Image
            {
                Source = new BitmapImage(new Uri("https://hdtv.neu6.edu.cn/wall/img/" + a.GetSimpleName() + "_s.png")),
                //TODO 可以换一种更睿智的方法,目前显示效果不够好
                //高清频道和非高清频道图片分辨率不同,手动设置图片宽高
                //否则非高清频道 textblock无法显示
                Width  = 300,
                Height = 225
            };

            itemPanel.Margin = new Thickness(8);
            itemPanel.Children.Add(img);
            itemPanel.Children.Add(t);
            itemPanel.Children.Add(c);
            itemPanel.Tag  = a;
            itemPanel.Name = a.Name;
            grid.Items.Add(itemPanel);
            panels.Add(itemPanel);
        }