Exemplo n.º 1
0
        private void PlayAndAddToRecent(ItemEx item)
        {
            var items = _dataService.AddToRecentlyPlayedList(item);

            RecentlyPlayedChannels.Clear();
            foreach (var tempItem in items)
            {
                if (RecentlyPlayedChannels.FirstOrDefault(o => o.chlink == tempItem.chlink) == null)
                {
                    RecentlyPlayedChannels.Add(tempItem);
                }
            }
            if (RecentlyPlayedChannels.Count > 0)
            {
                AreRecentChannelsPresent = true;
            }
            else
            {
                AreRecentChannelsPresent = false;
            }

            DependencyObject rootGrid = VisualTreeHelper.GetChild(Window.Current.Content, 0);

            if (rootGrid != null)
            {
                var mediaPlayer = (MediaElement)VisualTreeHelper.GetChild(rootGrid, 0);
                if (mediaPlayer != null)
                {
                    mediaPlayer.Source = new Uri(SelectedChannel.chlink, UriKind.RelativeOrAbsolute);
                    mediaPlayer.Play();
                }
            }
        }
Exemplo n.º 2
0
        private async Task LoadRecentStations()
        {
            await DispatcherHelper.UIDispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
            {
                var items = await _dataService.LoadRecentStations();
                if (items != null)
                {
                    foreach (var item in items)
                    {
                        RecentlyPlayedChannels.Add(item);
                    }
                }

                if (RecentlyPlayedChannels.Count > 0)
                {
                    AreRecentChannelsPresent = true;
                }
                else
                {
                    AreRecentChannelsPresent = false;
                }
            });
        }