Blank Page Project in Visual Studio 2017 UWP

This code will be familiar to anyone who has seen the UWP Samples and/or the Media Casting article but I just cannot get it to work. The connection attempts to connect but always returns a "device cannot play the media" error. irrespective of the file type. I am fully able to cast using the inbuilt windows Cast To context menu item so it's not a question of any inherent compatibility. Anybody any ideas on how I can get this to work?

VB Code:
  1. 'Create a new picker
  2.         Dim filePicker As Windows.Storage.Pickers.FileOpenPicker = New Windows.Storage.Pickers.FileOpenPicker()
  3.         filePicker.FileTypeFilter.Add(".wmv")
  4.         filePicker.FileTypeFilter.Add(".mp4")
  5.         filePicker.FileTypeFilter.Add(".mkv")
  6.         filePicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary
  7.         'Retrieve file from picker
  8.         Dim file As Windows.Storage.StorageFile = Await filePicker.PickSingleFileAsync()
  9.         If file IsNot Nothing Then
  10.             Dim stream As Windows.Storage.Streams.IRandomAccessStream = Await file.OpenAsync(Windows.Storage.FileAccessMode.Read)
  13.             video.SetSource(stream, file.ContentType)
  15.             If device IsNot Nothing Then
  17.                 connection = (CType(device, Windows.Media.Casting.CastingDevice)).CreateCastingConnection()
  18.                 AddHandler connection.ErrorOccurred, AddressOf Connection_ErrorOccurred
  19.                 AddHandler connection.StateChanged, AddressOf Connection_StateChanged
  20.                 Await connection.RequestStartCastingAsync(video.GetAsCastingSource())
  21.             End If
  25.         End If