Win8 XAML video player : easy globalization / translations

, , Comments Off on Win8 XAML video player : easy globalization / translations

Now that you can easily stream videos from Azure’s blobs, you may want to translate the strings used in the player Framework.

Today, I struggled a lot doing something basic : translating in french the text of the “error view” in the player framework.

As usual, there is an easy solution !

I tried a lot of things, but none of it has done the job :

  • to set the language attribute of the mediaPlayer
  • to remove the default ErrorPlugin and add a one with the language set
  • to create and apply a custom error view style

Finally, I downloaded the source code of the player framework and I noticed that there is a ResourceLoader property on the MediaPlayer class. This is the resource loader used to get all the strings of the MediaPlayer.

So the solution is easy : just copy the resource file of the player framework and customize it for your application. As this is a static property, you can do it once and for all in the App’s Loaded method.

Here is what I do in my app :
[csharp]MediaPlayer.ResourceLoader = new ResourceLoader("/Microsoft.PlayerFramework");[/csharp]

With this folder/file tree :

If you need to refresh your knowledge, you can also read my post on ressources. It targets WinJS but the basics are the same.