1

I am using LibVLCSharp and VideoLAN.LibVLC.UWP nuget packages in an UWP app that runs on XBOX. My app does video streaming and I have been using the default Windows Media controls and they work fine. I wanted to also support VLC to handle more codecs and I was able to integrate it in the app, however it seems like while the player is buffering it is making heavy use of the UI thread and the app gets unresponsive to user inputs. The UI thread is completely responsive once the buffering is done.

My understanding is that although the Play method is synchronous it simply signals the player and doesn't block the calling thread. I am sure this is how this works because the UI is not completely unresponsive but it does get stuck a lot.

I am calling the the play method within an async method code like this:

    await vlcPlayerElement.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
    {
      vlcPlayerElement.MediaPlayer.Play(new VLCMedia(libVLC, url, FromType.FromLocation));
    });

Is there anything I can do to ensure the UI thread is responsive at all times?

Thanks in advance for the any help.

  • 1
    "I am calling the the play method within an async method" - No you're not, you're calling it synchronously on the UI thread. Read your code again. – Blindy Jan 19 '22 at 16:58
  • @Blindy, I meant to say the call is done within an async method. I know I am calling it within the UI thread and I know the method is synchronous, but the method simply signals the player and returns. The ui is not completly blocked. If I do not call the method within the context of the ui thread the video does not play. – Fernando Sibaja Jan 19 '22 at 17:16
  • 1
    You don't need to be calling the Play method in the UI thread, you can call it from anywhere, except from the libvlc thread (i.e. within libvlc callbacks) – cube45 Jan 19 '22 at 21:07
  • Can you share some logs? Maybe a small repro? That code cannot be blocking your UI, it just sends a play command – mfkl Jan 20 '22 at 02:51
  • @mfkl Let me build a demo of what I mean. Thanks for getting back to me. – Fernando Sibaja Jan 20 '22 at 03:16

0 Answers0