documentation.txt 1.92 KB
Newer Older
Martin Finkel's avatar
Martin Finkel committed
1
2
3
4
5
6
Welcome to VLC for Unity on Windows!


For reference, you need to a bunch of components to get this working:
- libvlc.dll, libvlccore.dll (and its plugins in /libs folder): These are nightly build DLLs of the VLC player libraries https://code.videolan.org/videolan/vlc
- Custom build of libvlcsharp, the official VideoLAN C# binding to libvlc https://code.videolan.org/videolan/LibVLCSharp
Martin Finkel's avatar
Martin Finkel committed
7
- VLCUnityPlugin.dll, the VLC-Unity native plugin https://code.videolan.org/mfkl/vlc-unity
Martin Finkel's avatar
Martin Finkel committed
8
9
10
11
12
13
14
15
16
17
18

This is all included in this package and it all works automatically for you.

LibVLCSharp docs (not Unity specific) https://code.videolan.org/videolan/LibVLCSharp/blob/3.x/docs/getting_started.md

!! You need to set your Unity target platform to "PC, Mac & Linux Standalone" to target Windows classic. Go for the x86_64 architecture.

The scene from Assets/VLC-Unity-Windows/Scripts/main.unity provides a way to get started quickly.

Regarding the integration code that you need, you will find it in UseRenderingPlugin.cs.

Martin Finkel's avatar
Martin Finkel committed
19
First, you need to load the native libraries:
Martin Finkel's avatar
Martin Finkel committed
20
```
Martin Finkel's avatar
Martin Finkel committed
21
Core.Initialize(UnityEngine.Application.dataPath);
Martin Finkel's avatar
Martin Finkel committed
22
23
24
25
26
27
28
29
```

You can then create LibVLCSharp objects
```
LibVLC = new LibVLC();
MediaPlayer = new MediaPlayer(LibVLC);
```

30
The frame updating is done in a Unity coroutine or Update() function
Martin Finkel's avatar
Martin Finkel committed
31
32
33
34
35
36
37
38
```
IntPtr texptr = MediaPlayer.GetFrame(out bool updated);
if (updated)
{
    tex.UpdateExternalTexture(texptr);
}
```

39
See Update() function for more details.
Martin Finkel's avatar
Martin Finkel committed
40
41
42
43
44
45
46
47

Once that is all setup, you can create a new Media and start playback like so
```
MediaPlayer.Play(new Media(LibVLC, "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4", FromType.FromLocation));
```

To get up and running easily and quickly, I recommend you load the Assets/VLC-Unity-Windows/Scripts/main.unity scene and get started from there. 
The few lines of setup code I mentioned above are located in UseRenderingPlugin.cs.