There is a C# application which uses LibVLC via NuGet packages.
These are the packages:
With these packages it is very easy to drop some mediaplayers into your WinForms application.
All you have to do is to initialize a player and give a new Media
to it:
LibVLCSharp.Shared.LibVLC libVLC = new LibVLC();
LibVLCSharp.WinForms.VideoView videoView;
videoView.MediaPlayer = new LibVLCSharp.Shared.MediaPlayer(libVLC)
videoView.MediaPlayer.Play(new Media(libVLC, "URL", FromType.FromLocation));
Now I want to feed the mediaplayer with my custom data from a buffer. It can be byte-array, or anything similar. (data shall be considered to come from a valid mp4 file chunk-by-chunk).
How can I achieve that with libVLC in C#?
Use this Media constructor
new Media(libVLC, new StreamMediaInput(stream));
stream
can by any .NET Stream.
This sample is with a torrent stream for example: https://github.com/mfkl/lvst/blob/master/LVST/Program.cs
If you don't want to create a Stream where not needed, you could also implement your own MediaInput
class, and implement the required methods
https://code.videolan.org/videolan/LibVLCSharp/-/blob/master/src/LibVLCSharp/MediaInput.cs
Then, the usage is the same as @mfkl pointed out. Be careful though, the MediaInput must be disposed!
this._mediaInput = new MyMediaInput();
mediaPlayer.Play(new Media(libVLC, this._mediaInput));
// At the end
this._mediaInput.Dispose();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With