Search code examples
androidxamarinlibvlclibvlcsharp

Does the libvlcsharp MediaPlayerElement support non-touch devices?


I was messing around with libvlcsharp on Xamarin and the (fairly) new MediaPlayerElement UI on Android. For devices such as Android TV, there is no touch interface so you have to use something like a remote control.

For this case, I end up capturing keypresses in DispatchKeyEvent and send them to my app via MessagingCenter. I was wondering whether MediaPlayerElement can support non-touch devices automatically OR if not, what the best approach would be to handling keypresses in the app. I would have to "highlight" various controls of the MediaPlayerElement and then be able to select them when "DpadCenter" is pressed.

My questions are:

  1. Does MediaPlayerElement already support non touch gestures? This site here seems to suggest it might with the comment that you can turn them off.

  2. If it doesn't support them (and you have to roll your own), is there a programmatic way to highlight (e.g. change the background color) of the individual controls/buttons (such as pause or play) and invoke them?


Solution

  • Does MediaPlayerElement already support non touch gestures? This site here seems to suggest it might with the comment that you can turn them off.

    If it doesn't support them (and you have to roll your own), is there a programmatic way to highlight (e.g. change the background color) of the individual controls/buttons (such as pause or play) and invoke them

    You can override functionality for any control, so you should be able to hook your DpadCenter event and modify the behavior you expect of the player element.

    It is on the roadmap to provide better docs for this https://code.videolan.org/videolan/LibVLCSharp/-/issues/309

    For customization of the control, a similar answer was created a while ago: How to create LibVLCSharp custom playback controls in Xamarin Forms?

    Do share what you build with it :-) We don't have any Android TV sample for this.