private async void Button_Click(object sender, RoutedEventArgs e) { AdaptiveMediaSourceCreationResult result = null; try { result = await AdaptiveMediaSource.CreateFromUriAsync(new Uri(UrlBox.Text)); VideoElement.SetMediaStreamSource(result.MediaSource); } catch { try { VideoElement.Source = new Uri(UrlBox.Text); } catch { await Message(); return; } } }
private void InitializeVideo() { if (!_videoInitilized) { _videoInitilized = true; var videoEncodingProperties = VideoEncodingProperties.CreateH264(); videoEncodingProperties.Height = 720; videoEncodingProperties.Width = 960; var mediaStreamSource = new MediaStreamSource(new VideoStreamDescriptor(videoEncodingProperties)) { // never turn live on because it tries to skip frame which breaks the h264 decoding //IsLive = true, BufferTime = TimeSpan.FromSeconds(0.0) }; mediaStreamSource.SampleRequested += MediaStreamSource_SampleRequested; VideoElement.SetMediaStreamSource(mediaStreamSource); // never turn real time playback on //_mediaElement.RealTimePlayback = true; } }