VideoKit is an implementation of a VLC video player using the LibVLCSharp library and StereoKit for rendering. It provides a sample interface for playing video files and handling audio playback for use in StereoKit.
The VideoKit app here is compatible with Oculus Quest and Windows.
Any online video can be played by providing the URL to the video file, or local files using local paths.
- Local paths are not supported on Android. Streaming from the web works fine for most use-cases.
stereokit-video-demo_lowres.mp4
VideoKitPlayer
is a C# class designed to play video files using the LibVLCSharp library and StereoKit for rendering.
It supports audio playback and provides a simple UI for controlling video playback. The class is very hacky and a proof
of viability, not a production-ready setup.
Any improvements to the setup would be appreciated as pull requests.
- Play, pause, and seek video.
- Display video using StereoKit.
- Handle audio playback with callbacks.
- Manage video and audio resources efficiently.
-
ON ANDROID: Initialize the libvlc library before initializing StereoKit. This is required to load the native libvlc library on Android. Add the following line to the
MainActivity.cs
file in theRun
method:// In Platforms/Android/MainActivity.cs/Run() method // Add the following line to initialize the libvlc library on android before the StereoKit initialization Core.Initialize(); // Load the native libvlc library
-
Create an instance of
VideoKitPlayer
and initialize it:var player = new VideoKitPlayer(); var texture = player.InitializeSoundAndTexture(); // use the texture in a material (check the Program.cs for an example)
-
Play a video:
var onlineUrl = new Uri("https://example.com/video.mp4"); var offlineUrl = new Uri("file://path/to/video.mp4") player.PlayVideoAsync(onlineUrl);
-
Call the
Step
method in your Step loop to handle UI and rendering:player.Step();
-
Dispose of the player when done:
player.Dispose();
To configure video settings such as resolution, try to tweak the constants in the VideoKitPlayer
class.
For more details on configuring video formats, refer to the LibVLCSharp documentation.
Audio settings can be configured similarly by modifying the constants in the VideoKitPlayer
class. For more details on
audio configuration, refer to the LibVLCSharp audio documentation.
This project is licensed under the MIT License. See the LICENSE
file for more details.
The project was scaffolded using the StereoKit Template. You can start your own StereoKit project template using:
mkdir "MyProjectKit"
cd "MyProjectKit"
dotnet new install StereoKit.Templates
dotnet new sk-multi