Skip to content
Snippets Groups Projects

Added VLC Canvas Example and VLC 3D Example scenes to Demos and reorganized Demos folder slightly

Merged LL requested to merge brisingre/vlc-unity:new-demos into master
3 unresolved threads

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.

Edited by LL

Merge request reports

Pipeline #197555 passed

Pipeline passed for 171df3c9 on brisingre:new-demos

Approval is optional

Merged by Martin FinkelMartin Finkel 3 years ago (Mar 8, 2022 5:41am UTC)

Merge details

  • Changes merged into with 171df3c9.
  • Deleted the source branch.
  • Auto-merge enabled

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • 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.

    • Author Contributor

      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)

    • :thumbsup: for now, your code comment explanation is definitely welcome and necessary!

    • Please register or sign in to reply
  • LL added 1 commit

    added 1 commit

    • 226161e8 - fixed baked lighting, removed TMPro (though it is missed). Added maxVolume input to the GUI script

    Compare with previous version

  • Self reminder: Update documentation.txt and readme with more info before merging this.

  • Author Contributor

    Might also want to mention the OFL on LiberationSANS

  • Martin Finkel added 5 commits

    added 5 commits

    • fdde035d - notice: mention open font license
    • bb167dad - rename - add VLC in filenames
    • a8cff027 - readme: mention scenes
    • d3f8a003 - readme: mention Android support
    • 171df3c9 - doc: mention all the scenes

    Compare with previous version

  • Martin Finkel approved this merge request

    approved this merge request

  • merged

  • Thank you for this much needed contribution @brisingre!

  • Please register or sign in to reply
    Loading