This project is read-only.
2
Vote

How to Find a faulty You tube Video (i.e; Video not playing due to its restrictions or Removal )

description

Iam using MyToolKit Packages downloaded from nuget manager

In my app i have many youtube video urls some of those urls are not working , How to find them and display a message saying Video Unavailable

When i use this code it is working fine for videos that are playing, But i click on a video that is not working the Listbox control is being disabled and nothing is running.
private async void lbxSongsList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                if (lbxSongsList.SelectedIndex == -1)
                    return;
                AppSettings.LinkTitle = (lbxSongsList.SelectedItem as ShowLinks).Title.ToString();
                AppSettings.LinkType = (lbxSongsList.SelectedItem as ShowLinks).LinkType.ToString();

                var selecteditem1 = (sender as Selector).SelectedItem as ShowLinks;
                var Itemcollection = (sender as ListBox).Items.ToList();
                Constants.YoutubePlayList = new Dictionary<string, string>();
                foreach (var item in Itemcollection.Cast<ShowLinks>().Where(i => i.LinkOrder > selecteditem1.LinkOrder))
                {
                    if (!Constants.YoutubePlayList.ContainsKey(item.LinkUrl))
                        Constants.YoutubePlayList.Add(item.LinkUrl, item.Title);
                }
                foreach (var item in Itemcollection.Cast<ShowLinks>().Where(i => i.LinkOrder < selecteditem1.LinkOrder))
                {
                    if (!Constants.YoutubePlayList.ContainsKey(item.LinkUrl))
                        Constants.YoutubePlayList.Add(item.LinkUrl, item.Title);
                }
                AppSettings.PlayVideoTitle = Constants.YoutubePlayList.FirstOrDefault().Value;
                History objHistory = new History();
                objHistory.SaveSongHistory((lbxSongsList.SelectedItem as ShowLinks).ShowID.ToString(), (lbxSongsList.SelectedItem as ShowLinks).Title);

                if (ResourceHelper.AppName == Apps.Indian_Cinema_Pro.ToString() || ResourceHelper.AppName == Apps.Kids_TV_Pro.ToString() || ResourceHelper.AppName == Apps.Story_Time_Pro.ToString())
                    AppSettings.startplayingforpro = true;
                else
                    AppSettings.startplaying = true;
                if (ResourceHelper.ProjectName == AppResources.VideoMix)
                {
                    var item = lbxSongsList.SelectedItem as ShowLinks;
                    AppSettings.ShowID = item.ShowID.ToString();
                    AppSettings.LinkUrl = item.LinkUrl;
                    AppSettings.Title = item.Title;
                    Constants.TileImageUrl = item.UrlType;
                    AppSettings.LinkOrder = item.LinkOrder.ToString();
                    PageHelper.NavigateTo(NavigationHelper.MixVideosPopupPage);
                }
                else
                {                   
                    MyToolkit.Multimedia.YouTube.PlayAsync((lbxSongsList.SelectedItem as ShowLinks).LinkUrl, MyToolkit.Multimedia.YouTubeQuality.Quality480P);
                }
                lbxSongsList.SelectedIndex = -1;
                lbxSongsList.IsEnabled = false;              
                lbxSongsList.ItemsSource = OnlineShow.GetShowLinksByType(AppSettings.ShowID, LinkType.Songs/*, false*/);                
            }
            catch (Exception ex)
            {
                //string excep = ex.Message;
                //UtilitiesManager.LoadBrowserTask((lbxSongsList.SelectedItem as ShowLinks).LinkUrl);
            }
        }

comments