Skip to content

Example of using libvlcsharp in StereoKit

License

Notifications You must be signed in to change notification settings

Strepto/stereokit-video

Repository files navigation

VideoKit

Overview

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.

Demo

stereokit-video-demo_lowres.mp4

Features

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.

Usage

  1. 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 the Run 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
  2. 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)
  3. Play a video:

    var onlineUrl = new Uri("https://example.com/video.mp4");
    var offlineUrl = new Uri("file://path/to/video.mp4")
    player.PlayVideoAsync(onlineUrl);
  4. Call the Step method in your Step loop to handle UI and rendering:

    player.Step();
  5. Dispose of the player when done:

    player.Dispose();

Configuration

Video Configuration

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 Configuration

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.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Other

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

About

Example of using libvlcsharp in StereoKit

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published