GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - kiewic/MediaElementWithHttpClient: Use Windows.UI.Xaml.Controls.MediaElement with Windows.Web.Http.HttpClient.

BranchesTags
Open more actions menu

Latest commit

 

History

9 Commits
9 Commits

Folders and files

NameName
Last commit message
Last commit date
Windows10
Windows10
 
 
Windows8
Windows8
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 

Repository files navigation

MediaElementWithHttpClient

TL;DR

Use Windows.UI.Xaml.Controls.MediaElement with Windows.Web.Http.HttpClient.

Docs

MediaElement is a control to play audio and video in Windows Universal/Store apps.

However, when the audio or video is served from an internet server, using HttpClient is a better choice to handle the request because you can provide:

  • Authentication credentials.
  • Custom headers.
  • Etc.

The HttpRandomAccessStream class is a wrapper on top of HttpClient that can stream content from the internet and can be consumed as an IRandomAcessStream.

Example

MediaElement mediaPlayer = new MediaElement();

HttpClient client = new HttpClient();

// Add custom headers, credentials, etc.
client.DefaultRequestHeaders.Add("Foo", "Bar");

Uri uri = new Uri("http://video.ch9.ms/ch9/70cc/83e17e76-8be8-441b-b469-87cf0e6a70cc/ASPNETwithScottHunter_high.mp4");

HttpRandomAccessStream stream = await HttpRandomAccessStream.CreateAsync(client, uri);

mediaPlayer.SetSource(stream, "video/mp4");

Note: The server must support HTTP Range headers.

Windows8 vs Windows10 solutions.

Both solutions are equivalent, and the HttpRandomAccessStream class is the same in both solutions.

The Windows8 solution is targeted for Windows 8.1 and it loads great in Visual Studio 2013.

The Windows10 solution is targeted for Windows 10 (Universal Windows) and it loads great in Visual Studio 2015.

Windows.UI.Xaml.Controls.MediaPlayerElement

For an example with MediaPlayerElement, please go to kiewic/MediaPlayerElementWithHttpClient repository.

About

Use Windows.UI.Xaml.Controls.MediaElement with Windows.Web.Http.HttpClient.

Topics

windows-universalwinrt

Resources

Readme
MIT license
Activity

Stars

22 stars

Watchers

6 watching

Forks

11 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.