public void Play() { if (VideoPlayerElement.Source != null) { VideoPlayerElement.Play(); this.Background = Brushes.Gray; MediaState = MediaState.Play; } }
private void OnDownloadOrPlayClick(object sender, RoutedEventArgs e) { if (media == null) { return; } if (!downloaded) { PlaybackButton.IsEnabled = false; PlaybackButton.Content = "downloading..."; MessageMediaVideoConstructor mediaVideo = (MessageMediaVideoConstructor)media; Task.Run(() => TelegramSession.Instance.Files.DownloadVideo(mediaVideo.video, Handler)).ContinueWith( (result) => { Deployment.Current.Dispatcher.BeginInvoke(() => { videoSource = result.Result; PlaybackButton.Content = "play"; PlaybackButton.IsEnabled = true; PlaybackProgress.Visibility = Visibility.Collapsed; downloaded = true; }); }); } else { PlaybackButton.Visibility = Visibility.Collapsed; if (videoSource == null) { return; } using (var isf = IsolatedStorageFile.GetUserStoreForApplication()) { using (var isfs = new IsolatedStorageFileStream(videoSource, FileMode.Open, FileAccess.Read, FileShare.Read, isf)) { VideoPlayerElement.SetSource(isfs); VideoPlayerElement.Play(); } } } }