All Projects → kiewic → MediaElementWithHttpClient

kiewic / MediaElementWithHttpClient

Licence: MIT License
Use Windows.UI.Xaml.Controls.MediaElement with Windows.Web.Http.HttpClient.

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to MediaElementWithHttpClient

ModernKeePass
KDBX password manager for the Windows Store
Stars: ✭ 29 (+52.63%)
Mutual labels:  winrt
libwinmedia
[Archived] A cross-platform simple media playback library for C/C++.
Stars: ✭ 35 (+84.21%)
Mutual labels:  winrt
react-native-xaml
A React Native Windows library to use XAML / WinUI controls
Stars: ✭ 55 (+189.47%)
Mutual labels:  winrt
Win32Acrylic
Acrylic demo applications based on different technology stack
Stars: ✭ 35 (+84.21%)
Mutual labels:  winrt
Modern-Gitter
A Gitter client application for the Windows platform
Stars: ✭ 16 (-15.79%)
Mutual labels:  winrt
XamlIslands
Repository with several XAML Islands v1 samples (Win32, WPF, and WinForms) to demonstrate how to use it.
Stars: ✭ 47 (+147.37%)
Mutual labels:  winrt
mvvmhelpers
MVVM, converter and behavior library for all XAML based frameworks
Stars: ✭ 21 (+10.53%)
Mutual labels:  winrt
Template10
Making Windows 10 apps great again
Stars: ✭ 1,420 (+7373.68%)
Mutual labels:  winrt
UWPToyVpn
A UWP VPN plugin sample.
Stars: ✭ 31 (+63.16%)
Mutual labels:  winrt
UWP-Flow-Frame
Flow Frame is a new and improved Frame control. This builds upon the default frame control by providing high-performance page transition animations powered by the composition layer. Fresh, new animations will be used by default, with options to configure the animations or even create your own custom animations (from scratch).
Stars: ✭ 14 (-26.32%)
Mutual labels:  winrt

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].