documentation.txt 2.18 KB
Newer Older
Martin Finkel's avatar
Martin Finkel committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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
- RenderingPlugin.dll, the VLC-Unity native plugin https://code.videolan.org/mfkl/vlc-unity

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.

First, to load the libvlc libraries on Windows, you need to do an extra step:

Declare this native call:

```
[DllImport("RenderingPlugin")]
static extern void SetPluginPath(string path);
```

And call it with:
```
SetPluginPath(Application.dataPath);
```

You can then load the libvlc libraries.
```
Core.Initialize($"{Application.dataPath}\\Plugins");
```

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

The frame updating is done in a Unity coroutine
```
IntPtr texptr = MediaPlayer.GetFrame(out bool updated);
if (updated)
{
    tex.UpdateExternalTexture(texptr);
}
```

See UseRenderingPlugin.CallPluginAtEndOfFrames() for more details.

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.