void MainPage_Loaded(object sender, RoutedEventArgs e) { Uri uri = new Uri("files/111.mp3", UriKind.RelativeOrAbsolute); StreamResourceInfo sr = Application.GetResourceStream(uri); source = new WaveMediaStreamSource(sr.Stream); TestMediaElement.SetSource(source); }
private void Play(Stream DownloadedStream) { stream = new WaveMediaStreamSource(DownloadedStream); mediaElement.SetSource(stream); //mediaElement.Play(); PauseIcon.Visibility = Visibility.Collapsed; PlayIcon.Visibility = Visibility.Visible; }
void OnDownloadComplete(object o, OpenReadCompletedEventArgs e) { try { System.IO.Stream stream = e.Result; WaveMediaStreamSource wave = new WaveMediaStreamSource(stream); this.Media.SetSource(wave); this.Media.Play(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }