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:
'Create a new picker Dim filePicker As Windows.Storage.Pickers.FileOpenPicker = New Windows.Storage.Pickers.FileOpenPicker() filePicker.FileTypeFilter.Add(".wmv") filePicker.FileTypeFilter.Add(".mp4") filePicker.FileTypeFilter.Add(".mkv") filePicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary 'Retrieve file from picker Dim file As Windows.Storage.StorageFile = Await filePicker.PickSingleFileAsync() If file IsNot Nothing Then Dim stream As Windows.Storage.Streams.IRandomAccessStream = Await file.OpenAsync(Windows.Storage.FileAccessMode.Read) video.SetSource(stream, file.ContentType) If device IsNot Nothing Then connection = (CType(device, Windows.Media.Casting.CastingDevice)).CreateCastingConnection() AddHandler connection.ErrorOccurred, AddressOf Connection_ErrorOccurred AddHandler connection.StateChanged, AddressOf Connection_StateChanged Await connection.RequestStartCastingAsync(video.GetAsCastingSource()) End If End If