public static void Play(this MediaElement element, EpisodeViewModel episode) { if (App.Playlist == null) App.Playlist = new[] { episode }; if (!App.Playlist.Contains(episode)) App.Playlist.Add(episode); Play(episode); }
private static void Play(EpisodeViewModel episode) { foreach (var ep in App.Playlist) { ep.PlayCommand.Label = "Play"; ep.PlayCommand.Symbol = Symbol.Play; } if (episode.Episode.WebPath.StartsWith("http://") || episode.Episode.WebPath.StartsWith("https://")) PlayFromNetwork(episode); else PlayLocalEpisode(episode); SetupTimer(); timer.Start(); }
private static async void PlayLocalEpisode(EpisodeViewModel episode) { try { var file = await StorageFile.GetFileFromPathAsync(episode.Episode.WebPath); IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.Read); App.Player.SetSource(stream, file.ContentType); App.UpdateSystemControls(episode.Episode); _viewModel.NowPlaying.Episode = episode; _viewModel.NowPlaying.Episode.PlayCommand.Symbol = Symbol.Pause; _viewModel.NowPlaying.Episode.PlayCommand.Label = "Pause"; } catch (Exception ex) { if (ex is FormatException) { ; } } }
private static void PlayFromNetwork(EpisodeViewModel episode) { App.Player.Source = new Uri(episode.Episode.WebPath); App.Position = App.Playlist.IndexOf(episode); App.Player.Play(); App.UpdateSystemControls(episode.Episode); _viewModel.NowPlaying.Episode = episode; _viewModel.NowPlaying.Episode.PlayCommand.Symbol = Symbol.Pause; _viewModel.NowPlaying.Episode.PlayCommand.Label = "Pause"; }