2

I have a working example of my issue here. Basically: when I place the LibVLCSharp MediaPlayerElement into MainPage.xaml directly, I'm able to get playback. When I try to create a reusable control by hosting the MediaPlayerElement in a ContentView that I can use in several parts of my application, all I get is a black screen. The only difference appears to be hosting it inside a ContentView.

Ultimately, my goal is to create a single, reusable class that I can use in several parts of my Xamarin application to render video without copying and pasting code. I've found that it's most stable to set the properties I want to set (clearing the Play/Stop, etc. controls) in XAML. So I've gravitated to implementing my reusable component as a ContentView and just referencing it in multiple places.

Does anyone have any idea on why I get a black screen in this example?

Ben
  • 314
  • 2
  • 11
  • 1
    Your MediaPlayer is not a Bindable property/ does not raise PropertyChanged, so the VideoView is initialized with a null media player when it loads, and the never changed, even after the start. – cube45 Dec 05 '20 at 08:27
  • Can you post it as a response so I can give you credit for the answer? Thanks so much. – Ben Dec 05 '20 at 14:47

1 Answers1

1

See this line: https://github.com/kwende/LibVLCSharpContentView/blob/65fd9c2bf1afc97374a9052c86b9c066934f7b7d/LibVLCSharpContentView/LibVLCSharpContentView/VideoPlayer.xaml.cs#L28

Your MediaPlayer is not a Bindable property/does not raise PropertyChanged, so the VideoView is initialized with a null media player when it loads, and the never changed, even after the start.

cube45
  • 3,429
  • 2
  • 24
  • 35