Results 1 to 2 of 2

Thread: Media Casting Fail

  1. #1

    Thread Starter
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Media Casting Fail

    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)
    11.  
    12.  
    13.             video.SetSource(stream, file.ContentType)
    14.  
    15.             If device IsNot Nothing Then
    16.  
    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
    22.  
    23.  
    24.  
    25.         End If
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  2. #2
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: Media Casting Fail

    Whoa. What a surprise. Haven't seen you in a long time.

    Sorry though, I can't help with this problem as I haven't even begun to learn programming for UWP. Just posted to say hi
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width