title: I have a very strange question with xamarin.form and libvlcsharp
body: <p>When I create LibVLC and MediaPlayer objects in the constructor and play the video, there is only sound but no image. When I create LibVLC and MediaPlayer objects in the'Play' function, there are sounds and images. I don't want to create a MediaPlayer object every time the play function is called. what should I do?</p>
  <pre><code>using System;
  using System.ComponentModel;
  using System.Windows.Input;
  using LibVLCSharp.Shared;
  using static Xamarin.Essentials.Permissions;
  
  
  namespace MediaElement
  {
      /// &lt;summary&gt;
      /// Represents the main viewmodel.
      /// &lt;/summary&gt;
      public class MainViewModel : INotifyPropertyChanged
      {
          /// &lt;summary&gt;
          /// Property changed event
          /// &lt;/summary&gt;
          public event PropertyChangedEventHandler PropertyChanged;
  
  
          /// &lt;summary&gt;
          /// Initializes a new instance of &lt;see cref=&quot;MainViewModel&quot;/&gt; class.
          /// &lt;/summary&gt;
          public MainViewModel()
          {
              Core.Initialize();
              LibVLC = new LibVLC();
              MediaPlayer = new MediaPlayer(LibVLC) { EnableHardwareDecoding = true };
          }
  
          
          
  
          private LibVLC _libVLC;
          /// &lt;summary&gt;
          /// Gets the &lt;see cref=&quot;LibVLCSharp.Shared.LibVLC&quot;/&gt; instance.
          /// &lt;/summary&gt;
          public LibVLC LibVLC
          {
              get =&gt; _libVLC;
              private set =&gt; Set(nameof(LibVLC), ref _libVLC, value);
          }
  
          private MediaPlayer _mediaPlayer;
          /// &lt;summary&gt;
          /// Gets the &lt;see cref=&quot;LibVLCSharp.Shared.MediaPlayer&quot;/&gt; instance.
          /// &lt;/summary&gt;
          public MediaPlayer MediaPlayer
          {
              get =&gt; _mediaPlayer;
              private set =&gt; Set(nameof(MediaPlayer), ref _mediaPlayer, value);
          }
  
                 
  
          /// &lt;summary&gt;
          /// Initialize LibVLC and playback when page appears
          /// &lt;/summary&gt;
          public void Play(String path)
          {
                  MediaPlayer.Play(new LibVLCSharp.Shared.Media(LibVLC, new Uri(path)));             
          }
  
          
  
          private void Set&lt;T&gt;(string propertyName, ref T field, T value)
          {
              if (field == null &amp;&amp; value != null || field != null &amp;&amp; !field.Equals(value))
              {
                  field = value;
                  PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
              }
          }
  
      }
  }
  </code></pre>