Added VLC Canvas Example and VLC 3D Example scenes to Demos and reorganized Demos folder slightly
Added two new demos for VLC Unity.
VLC Canvas Example implements a canvas GUI for a simple media player with play, pause, stop, seek, volume, track switching, and file loading functionality.
VLC 3D Example demonstrates how to play media on a 3D model in a unity scene. The scene is very simple but I tried to make it look a little nicer with baked lighting and some textures. It only added about 20mb to the package, I think that's worth it.
Both examples are based on VLCPlayerExample.cs, a more fleshed-out MediaPlayer monobehavior with enough features that it could be used as-is for some simple tasks. It has fixes and workarounds for many issues we have discovered over the past few months, some of which may not be required for much longer. All of these are commented.
There are still a few things here that could be improved, including:
A better system for executing actions on the main thread from VLC events in VlcPlayerExampleGUI.cs (once we decide on one)
An official VLC font instead of LiberationSans, which is a Unity default
A shader that can handle letterboxing for the 3d screen, so it can play videos that aren't 16:9
A loop option on VLCPlayerExample
Audio output through Unity audio for the 3d scene
We should also be sure we mention any licenses we need to, including the VlcPlayerExampleCamera script and the icons.
Merge request reports
Activity
- Resolved by Martin Finkel
41 ///Unity wants to do everything on the main thread, but VLC events use their own thread. 42 ///These variables can be set to true in a VLC event handler indicate that a function should be called next Update. 43 ///This is not actually thread safe and should be gone soon! 44 bool _shouldUpdateTracks = false; //Set this to true and the Tracks menu will regenerate next frame 45 bool _shouldClearTracks = false; //Set this to true and the Tracks menu will clear next frame 46 47 List<Button> _videoTracksButtons = new List<Button>(); 48 List<Button> _audioTracksButtons = new List<Button>(); 49 List<Button> _textTracksButtons = new List<Button>(); 50 51 52 void Start() 53 { 54 //VLC Event Handlers 55 vlcPlayer.mediaPlayer.Playing += (object sender, EventArgs e) => { 56 //Always use Try/Catch for VLC Events We will be able to remove these comments when !34 is merged. But thanks for the code comments explaining this to Unity users.
Possibly? I'm not sure all the impacts of this merge, and it might totally fix this. Still, I think I should clarify that this is different from the thing where anything that throws an exception in an event handler causes a freeze. That is likely to be fixed soon, and will make this issue a lot less dangerous for users, but it won't fully fix it. This is a workaround for a Unity issue, described here: #140 (comment 310096)
added 1 commit
- 226161e8 - fixed baked lighting, removed TMPro (though it is missed). Added maxVolume input to the GUI script
Thank you for this much needed contribution @brisingre!