Enabling PlayReady support on Xbox One UWP Developer Preview

In the previous days I was trying the recently released Xbox One UWP Developer preview with these samples involving Smooth Streaming / PlayReady and noticed that playback was not working properly on the console with the MediaElement always returning the error MEDIA_ERR_SRC_NOT_SUPPORTED – 0x80070005.

As highlighted in this forum post, the following capability must be added to the app manifest in order to enable playback of PlayReady DRM protected content on Xbox One UWP developer preview:

I’ve updated the Smooth Streaming / PlayReady samples and they are now available for download here on GitHub.

Xamarin.Forms: using the PanGestureRecognizer

Recently I’ve blogged about Xamarin.Forms and how to create a XAML Behavior for enabling Multi-Touch gestures to generic elements and implementing a scale / pinch functionality.

Fortunately the framework provides three types of recognizer that greatly simplify the implementation:

  • PinchGestureRecognizer allows user interactions for zoom / scale functionalities;
  • PanGestureRecognizer enables pan / translate transformations;
  • TapGestureRecognizer detects tap events.

Yesterday I decided to try the PanGestureRecognizer for extending the capabilities of the Behavior described in the previous post.

First of all, I added two Bindable properties in order to permit activation / deactivation of individual gestures (Bindable properties are equivalent to Dependency ones in UWP XAML)

In this way we can specify in our XAML what gestures are enabled:

Then I initialised the GestureRecognizers adding a new PanGestureRecognizer to the recognizers list:

And subscribed to the PanUpdated event in order to apply the translate transform:

The implementation of this event handler permits to update the X and Y coordinates of the element when a Pan gesture is detected:

Here we go: the sample app can now be deployed to the emulators and iOS / Android / Windows devices.

Just a couple of notes:

  • deployment to iOS required this workaround to work properly since the new sample app uses different assemblies;
  • Tap gestures on Android requires Xamarin.Forms – minimum version v2.1.0.6501-pre1 as pointed by the official documentation.

As usual, the latest source code is available for download on GitHub.

Having fun with Xamarin.Forms and Multi-Touch Behaviors

Recently Xamarin has released preview support for the Universal Windows Platform in their Xamarin.Forms framework so I have been playing around with version 2.0 for testing its features and verify how easy is to target multiple platforms (iOS, Android, Windows 10 UWP, Windows Phone, Windows 8.1) with a single codebase.

One of the experiments I have done is related to custom multi-touch gestures: the idea to use a XAML Behavior is a common scenario to write well structured code so I started creating a new Cross-Platform Xamarin.Forms Portable project and upgraded the NuGet packages to the latest stable version of the framework (currently v2.0.1.6505).

I have then read the official documentation and analysed the samples available on GitHub: a very good example is the PinchGesture one so, starting from it, I created a new MultiTouchBehavior implementing this gesture and attached the same Behavior to an Image object added to a sample ContentPage, as described below in this lovely cross-platform XAML 🙂

The BindingContext=”{Binding}” is used to trigger the BindingContextChanged event and initialise correctly the GestureRecognizers  for the parent object since the AssociatedObject.Parent is set to null when the Behavior.OnAttachedTo() is called (I suppose that the XAML tree is not yet completely created when the behavior is attached in Xamarin.Forms):

Here is the project deployed to the Android, iOS and Windows 10 emulators:

MultiTouch_Android_Emulator   Simulator Screen Shot 14 Feb 2016, 18.25.00   MultiTouch_Windows10_Emulator

I’ve been particularly impressed by Xamarin.Forms: the possibility to target so many platforms using the same code is a killer feature and the development environment is also very comfortable to use.

The sample code used in this post is available on GitHub, I’m planning to add more functionalities in the future with particular regard to other common multi-touch gestures using Xamarin.Forms and XAML.

XAML Behaviors, Windows 10 UWP and Open-Source

I’ve always been a great fan of XAML Behaviors: they help following good coding practices and keeping separation of concerns in your code. Ah, did I also mention that they help to write elegant code? 😉

Good news is that XAML Behaviors have been Open-Sourced and are available for download and contributions on GitHub: more information available in the official announcement here.

I already had fun submitting a couple of Pull Requests: head over to GitHub and enjoy!

TypedMVVM samples for Windows 10 UWP and IoC fixes

A new version of the TypedMVVM samples is now available on CodePlex and contains a basic sample targeting Windows 10 UWP.

The repository also contains a fix for the basic IoC container: now the code correctly handles the register<T>() and resolve<T>() functions and populates the internal dictionary of object instances

My friend Lee has also pushed to GitHub a new sample using TypedMVVM for web apps here: check it out!

NDepend v6 available

Version 6 of NDepend is now available for download from the official site.

New features include:

  • enhanced Visual Studio integration;
  • support for Visual Studio 2015;
  • rule files shareable amongst projects;
  • default rules description and HowToFix;
  • default rules less false positives;
  • colored code metric view;
  • intuitive display of code coverage percentage;
  • compiler generated code removal;
  • async support;
  • analysis enhancements;
  • support for Visual Studio Blue, Dark, Light themes;
  • support for high DPI resolution;
  • integration with TFS, SonarQube and TeamCity.

A detailed description of the new capabilities is available here.

Windows 10 UWP: Using PlayReady content protection with live DASH

I’ve recently blogged about using PlayReady content protection with Smooth Streaming on Windows 10 UWP by initialising a MediaProtectionManager object in the player element.

Since PlayReady is a technology for handling protected media content, it is possible to use it with different stream formats like Dynamic Adaptive Streaming over HTTP (DASH).

In the previous days, I have been exploring the live DASH sample available in the Universal Windows Platform repository on GitHub: the example enables playback of streams containing the profile “urn:mpeg:dash:profile:isoff-live:2011“.

It is possible to just add PlayReady content protection to this live player by initialising the MediaExtensionManager and then handling the MediaProtectionManager setup / ServiceRequested event:

The updated Visual Studio solution is available here on GitHub.

Smooth Streaming PlayReady samples for Windows 10 UWP available on GitHub

Lately I have been investigating PlayReady support available in the new Windows 10 Universal Windows Platform and found that the additional SDK necessary for Windows 8.1 Universal apps is not required for UWP since PlayReady Client is now part of the platform as described in this MSDN documentation.

When migrating Windows 8.1 apps to UWP, the key is to change the namespace from Microsoft.Media.PlayReadyClient to Windows.Media.Protection.PlayReady:

I have just pushed two samples on GitHub (C# and JavaScript) which also require the Universal Smooth Streaming SDK.

Multi-Touch Behaviors project moved to GitHub

I’ve just pushed to GitHub a first version of the Multi-Touch Behaviors containing a new sample targeting Windows 10 UWP (work in progress…) and some refactoring using shared projects in order to simplify the code and reusing it across different platforms.

For new contributions just send pull requests here!

Multi-Touch Behaviors sample: Main Page

Windows 10 UWP and Project Westminster: giving new life to your web sites with Hosted Web Apps

One of the most interesting features available in the new Windows 10 Universal Windows Platform (UWP) is the concept of Hosted Web Apps: an existing web site can be easily published to the Windows Store by creating a package pointing to it and, in this case, enabling access to the underlying UWP platform.

This feature enables the developer to easily enrich existing sites with Windows 10 specific functionalities and services like Cortana, Voice recognition, Xbox Live, just to name a few.

The steps required for creating an hosted web app using Visual Studio 2015 are quite simple:

1 – Create a new JavaScript Windows Universal project:

HostedWebAppVs2015_1

2 – Remove all unneeded source files from the project

Since the app will be pointing to an existing web site, the folders js / css / WinJS and the default.html file can all be removed from the project

HostedWebAppVs2015_2

3 – Modify the app manifest to provide the target URL and content rules

The package.appxmanifest file must contain the details of the Start Page and also the content rules specifying if the web site will have access or not to the Windows Runtime:

 

4 – Access desired Windows Runtime functionalities in the website code

I’ve created a very simple web page which will be accessing the UWP platform if the code is executed within an hosted web app. In this case we are only verifying the internet connection, but it could be modified to access Cortana APIs!

 

Here we go. These are the steps required for creating an hosted web app in Windows 10 UWP.

If you want to play with the code, I’ve published the sample on GitHub.