Dela via


Checking For Installed Media Center Applications From MCML

With the new Windows Media Center Presentation Layer (WMCPL) programming model it becomes easy to create rich and interactive media center experiences. While WMCPL supports an online only deployment and delivery model namely Windows Media Center Presentation Layer Web Applications many applications will still need to have code artefacts installed locally on the client machine. This may also be true for the new Online Gallery.

However unless this isn't going to change the Online Galery applications formerly known as Online Spotlight Services will only route a request to a remote page on the application providers server. So in this scenario the question is on how to determine if the local artifacts need to be installed or not and if they are installed to start the respective entrypoint. With hosted HTML one solution could be using ActiveX however ActiveX is not supported with WMCPL.
So the solution outline could look something like this:

1. Provide a basic MCML-based web application that just checks if the local application is already installed
2.1 If this is not the case offer to download an Windows Installer (msi) package so that the user can install the local application
2.2 If the Application is already installed launch the EntryPoint of the Application

In order to implement that you could do something like what I illustrate in the following sample.

<Mcml xmlns=" https://schemas.microsoft.com/2006/mcml "
xmlns:cor="assembly://MsCorLib/System"
xmlns:mce="assembly://Microsoft.MediaCenter/Microsoft.MediaCenter.Hosting"
xmlns:me="Me">

  <UI Name="CheckInstall">
<Locals>
<cor:Guid Name="AppGuid" Guid="2325435d-1f12-41ef-8fc1-0e226b6853f9"/>
<cor:Boolean Name="AppInstalled" Boolean="False" />
<cor:Boolean Name="ActInvoked" Boolean="False" />
<mce:AddInHost Name="MCEHost"/>
</Locals>
<Rules>
<Rule>
<Actions>
<Invoke Target="[MCEHost.ApplicationContext.IsApplicationRegistered]" guidApplication="[AppGuid]" ResultTarget="[AppInstalled]" />
<Set Target="[ActInvoked]" Value="True" />
</Actions>
</Rule>
<Condition Source="[AppInstalled]" ConditionOp="Equals" SourceValue="True">
<Actions>
<Invoke Target="[MCEHost.MediaCenterEnvironment.LaunchEntryPoint]" appId="2325435d-1f12-41ef-8fc1-0e226b6853f9" entryPointId="cbd877be-ac1a-42c3-9758-3bb262867f7a" parameters="null" />
</Actions>
</Condition>
<Rule>
<Conditions>
<Equality Source="[AppInstalled]" ConditionOp="Equals" Value="False" />
<Equality Source="[ActInvoked]" ConditionOp="ChangedTo" Value="True" />
</Conditions>
<Actions>
<Navigate Source="
https://www.gosoa.de/Files/Install.mcml " />
</Actions>
</Rule>
</Rules>
</UI>
</Mcml>

When running this sample it evaluates the two Boolean values defined in the <Locals> section. I had to take two because without them I had some issues with the rules evaluation which led to the situation that the conditions for "Install" was valid because of the initialization values of the locals and the Navigate action was performed before the Entrypoint was launched.
But now with the "double check" and binding the second value to the ChangedTo condition operator I get the expected behaviour.

Still there is one drawback of this solution which is that if you navigate back with the back button you will end up on an empty page since on the CheckInstall page no real UI content is defined.
Maybe I will try to find a way to refire the rules however I'm not sure if this then would be the right behaviour to be taken to the same page over and over again when not clicking the back button twice fast enough.