예제 #1
0
 public void GigglePlaylist()
 {
     DispatchManager.RunOnDispatcher(() =>
     {
         PlaylistTransform.ScaleX = 1.5;
         PlaylistTransform.ScaleY = 1.5;
         AnimationTools.AnimateDouble(PlaylistTransform, "ScaleX", 1.0, 1250, null, false, true);
         AnimationTools.AnimateDouble(PlaylistTransform, "ScaleY", 1.0, 1250, null, false, true);
     });
 }
예제 #2
0
        private async void CastingPicker_CastingDeviceSelected(CastingDevicePicker sender, CastingDeviceSelectedEventArgs args)
        {
            //Casting must occur from the UI thread.  This dispatches the casting calls to the UI thread.
            await DispatchManager.RunOnDispatcherAsync(async() =>
            {
                //Create a casting connection from our selected casting device
                CastingConnection connection = args.SelectedCastingDevice.CreateCastingConnection();

                //Cast the content loaded in the media element to the selected casting device
                await connection.RequestStartCastingAsync(MediaPlayerHost.CastingSource);
            });
        }
예제 #3
0
 static async void RaiseVideoPlayerDisengaged()
 {
     await DispatchManager.RunOnDispatcherAsync(() =>
     {
         try
         {
             OnVideoPlayerDisengaged?.Invoke();
         }
         catch
         {
             // Ignore error
         }
     });
 }
예제 #4
0
        void ForceBindingRefresh()
        {
            DispatchManager.RunOnDispatcher(() =>
            {
                OnCurrentIndexChanged?.Invoke();
                RaisePropertyChanged(nameof(CanGoNext));
                RaisePropertyChanged(nameof(CanGoPrev));
                RaisePropertyChanged(nameof(CurrentEntry));
                RaisePropertyChanged(nameof(CurrentEpisode));

                if (CurrentEpisode != null)
                {
                    CoreTools.UpdateTile(CurrentEpisode);
                }
            });
        }
예제 #5
0
        public void RemoveEntry(PlaylistEntry entry)
        {
            DispatchManager.RunOnDispatcher(() =>
            {
                if (entry == null)
                {
                    return;
                }

                var currentEntry  = CurrentEntry;
                var previousIndex = CurrentIndex;

                if (currentEntry == entry)
                {
                    if (previousIndex + 1 < Entries.Count)
                    {
                        currentEntry = Entries[previousIndex + 1];
                    }
                    else if (previousIndex > 0)
                    {
                        currentEntry = Entries[previousIndex - 1];
                    }
                }

                Entries.Remove(entry);

                if (Entries.Count == 0)
                {
                    CurrentIndex = -1;
                }
                else
                {
                    CurrentIndex = Entries.IndexOf(currentEntry);

                    if (previousIndex == CurrentIndex)
                    {
                        ForceBindingRefresh();
                    }
                }
            });
        }
예제 #6
0
        private static async void PlaybackList_CurrentItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args)
        {
            try
            {
                if (args.NewItem == null)
                {
                    return;
                }

                var currentItem = sender.CurrentItem;
                if (currentItem == null)
                {
                    return;
                }

                CheckPlaylistState(sender);

                syncedItem = playbackList.CurrentItem;

                RestorePosition();

                if (CurrentEntry == null)
                {
                    return;
                }

                Debug.WriteLine("Switched to episode#" + CurrentEntry.Episode.Title);

                if (currentItem.Source.Duration.HasValue)
                {
                    CurrentEntry.Duration = currentItem.Source.Duration.Value.TotalSeconds;
                }
                else
                {
                    CurrentEntry.Duration = 0;
                }

                if (LocalSettings.Instance.VideoPlayback && args.NewItem.VideoTracks.Count > 0)
                {
                    videoPlayInProgess = true;
                    RaiseVideoPlayerEngaged();
                }
                else if (videoPlayInProgess)
                {
                    videoPlayInProgess = false;
                    RaiseVideoPlayerDisengaged();
                }

                // Playback rate
                try
                {
                    Player.PlaybackSession.PlaybackRate = LocalSettings.Instance.PlaySpeed / 100.0;
                }
                catch (Exception)
                {
                    LocalSettings.Instance.PlaySpeed = 100;
                }

                if (!(Application.Current as App).IsInBackground && CurrentEntry != null && CurrentEntry.IsStreaming && NetworkHelper.Instance.ConnectionInformation.IsInternetAvailable && NetworkHelper.Instance.ConnectionInformation.IsInternetOnMeteredConnection && !LocalSettings.Instance.StreamOnMetered)
                {
                    await DispatchManager.RunOnDispatcherAsync(async() =>
                    {
                        Pause(false);
                        await App.MessageAsync(StringsHelper.StreamingIsDisabled);
                    });
                }

                SyncState(Player.PlaybackSession.PlaybackState);
            }
            catch (Exception ex)
            {
                App.TrackException(ex);
                CoreTools.ShowDebugToast(ex.Message, "PlaybackList_CurrentItemChanged");
            }
        }
예제 #7
0
        async Task ParseAsync(Windows.Data.Xml.Dom.XmlDocument document, bool notify, bool checkDownloads)
        {
            try
            {
                GetLocalImage();

                var channel = document.GetElementsByTagName("channel")[0];

                var tempList = new List <Episode>();

                foreach (var currentItem in channel.ChildNodes)
                {
                    if (currentItem.NodeName != "item")
                    {
                        continue;
                    }

                    var item = currentItem as Windows.Data.Xml.Dom.XmlElement;

                    var episode = new Episode
                    {
                        Link             = item.GetChildNodeTextValue("link", ""),
                        Title            = item.GetChildNodeTextValue("title", "").Sanitize(),
                        Subtitle         = item.GetChildNodeTextValue("itunes:subtitle", "").Sanitize(),
                        Author           = item.GetChildNodeTextValue("itunes:author", "").Sanitize(),
                        Summary          = item.GetChildNodeTextValue("description", "").SanitizeAsHTML(),
                        Enclosure        = item.GetChildNodeAttribute("enclosure", "url", ""),
                        PictureUrl       = item.GetChildNodeAttribute("itunes:image", "href", ""),
                        DeclaredDuration = item.GetChildNodeTextValue("itunes:duration", ""),
                        Keywords         = item.GetChildNodeTextValue("itunes:keywords", ""),
                        PublicationDate  = item.GetChildNodeTextValue("pubDate", "").TryParseAsDateTime(),
                        PodcastFeedUrl   = FeedUrl
                    };

                    var    length = item.GetChildNodeAttribute("enclosure", "length", "");
                    double estimatedLength;
                    if (Double.TryParse(length, out estimatedLength))
                    {
                        episode.EstimatedFileSize = estimatedLength;
                    }

                    if (!episode.DeclaredDuration.Contains(":"))
                    {
                        episode.DeclaredDuration = "";
                    }

                    var itunesSummary = item.GetChildNodeTextValue("itunes:summary", "").SanitizeAsHTML();

                    if (itunesSummary.Length > episode.Summary.Length)
                    {
                        episode.Summary = itunesSummary;
                    }

                    var contentSummary = item.GetChildNodeTextValue("content:encoded", "").SanitizeAsHTML();

                    if (contentSummary.Length > episode.Summary.Length)
                    {
                        episode.Summary = contentSummary;
                    }

                    if (string.IsNullOrEmpty(episode.Author))
                    {
                        episode.Author = Title;
                    }

                    if (string.IsNullOrEmpty(episode.Enclosure))
                    {
                        episode.Enclosure = episode.Link;
                    }

                    if (string.IsNullOrEmpty(episode.PictureUrl))
                    {
                        episode.PictureUrl = LocalImage;
                    }

                    episode.Clean();

                    tempList.Add(episode);
                }

                var addedEpisodes = new List <Episode>();
                var indexToInject = 0;

                foreach (var episode in tempList.OrderByDescending(e => e.PublicationDate))
                {
                    var inLibraryEpisode = Episodes.FirstOrDefault(e => e.Enclosure == episode.Enclosure);
                    if (inLibraryEpisode != null)
                    {
                        inLibraryEpisode.Author            = episode.Author;
                        inLibraryEpisode.DeclaredDuration  = episode.DeclaredDuration;
                        inLibraryEpisode.Keywords          = episode.Keywords;
                        inLibraryEpisode.Link              = episode.Link;
                        inLibraryEpisode.PictureUrl        = episode.PictureUrl;
                        inLibraryEpisode.PodcastFeedUrl    = episode.PodcastFeedUrl;
                        inLibraryEpisode.Title             = episode.Title;
                        inLibraryEpisode.Subtitle          = episode.Subtitle;
                        inLibraryEpisode.Summary           = episode.Summary;
                        inLibraryEpisode.PublicationDate   = episode.PublicationDate;
                        inLibraryEpisode.EstimatedFileSize = episode.EstimatedFileSize;
                        continue;
                    }

                    await DispatchManager.RunOnDispatcherAsync(() =>
                    {
                        Episodes.Insert(indexToInject, episode);
                    });

                    indexToInject++;
                    addedEpisodes.Add(episode);

                    if (notify && IsInLibrary && LocalSettings.Instance.Notifications)
                    {
                        Messenger.Notify(string.Format(LocalSettings.Instance.NotificationMessage, episode.Title), Title, "", LocalImage);
                    }
                }

                if (addedEpisodes.Count > 0 && IsInLibrary && AppSettings.Instance.AutomaticallyAddNewEpisodeToPlaylist)
                {
                    await DispatchManager.RunOnDispatcherAsync(() =>
                    {
                        var reversedAddedEpisodes = addedEpisodes.OrderBy(e => e.PublicationDate).ToList();
                        if (Playlist.CurrentPlaylist != null)
                        {
                            Playlist.CurrentPlaylist.AddEpisodes(reversedAddedEpisodes);
                        }
                        else
                        {
                            Playlist.EpisodesToAdd.AddRange(reversedAddedEpisodes);
                        }
                    });
                }

                LocalSettings.Instance.NewEpisodesCount += addedEpisodes.Count;

                if (checkDownloads)
                {
                    CheckForAutomaticDownloads();
                }

                if (toExecuteWhenReady != null)
                {
                    toExecuteWhenReady();
                    toExecuteWhenReady = null;
                }
            }
            catch
            {
                await Messenger.ErrorAsync(StringsHelper.Error_UnableToParseRSS + " (" + Title + ")");
            }
        }