Giter Site home page Giter Site logo

usharpvideo-subtitles's Introduction

Subtitles support for USharpVideo

This prefab adds support for SRT subtitles to USharpVideo - it will also work with base video players supported by VRChat (Unity and AVPro). To check this out in-game visit this test world or world from this list.

The core of this prefab is based on this code by Haï~.
Currently, there are minor issues for the Quest users - see here.

Features

  • Subtitle synchronization with everyone in the instance
  • Option to use own subtitles locally
  • Rich customization with the ability for the players to save their settings

Worlds using this prefab

Contact me if you want your world to be added to this list.

Requirements

Installation

I suggest adding "subtitles" to your world's tags when using this prefab so that people can find worlds with subtitle support more easily.

  1. Install UdonSharp first
  2. Import USharpVideo (required even if you're not planning on using it)
  3. Import latest release unitypackage
  4. Drag the Subtitles prefab into your scene
    • when using USharpVideo you can also drag Subtitles prefab into USharpVideo in your scene and reset transform values
  5. When a window asking you to import TextMeshPro Essentials appears - just do it
  6. Add a reference in the Subtitles object (SubtitleManager script) to:
    • when using USharpVideo (Target Video Player field) - USharpVideoPlayer from the USharpVideo object
    • in any other case (Base Video Player field) - VRCUnityVideoPlayer or VRCAVProVideoPlayer that have to be somewhere in your scene - depends on which one you're using (you can change this dynamically)
  7. Add a reference in the Subtitles/Overlay object (Video Screen field) to the video player's screen object, the overlay will copy the position and rotation of the screen on start
    • if this doesn't work on your world then you will have to manually adjust Subtitles/Overlay object's position and rotation to match the video screen object (while keeping the mentioned earlier field empty)

Quick API reference

Methods that you might be interested in using when integrating this prefab with other stuff in your world.

SubtitleManager.SetVideoPlayer(BaseVRCVideoPlayer): void

Use this to change the video player reference that the subtitles are synced with

  • Does nothing when using USharpVideo

SubtitleManager.HasSubtitles(): bool

Check whenever subtitles are currently loaded

  • It will return true if subtitles are loaded for the current mode (IsLocal())

SubtitleManager.ProcessInput(string): void

Loads subtitles from the text string globally or locally (depending on IsLocal() value)

  • When using USharpVideo - only the player who can control the video player can do this
  • For other video players - if IsLocked() is true then only the Master can do this
  • To check whenever player is able to execute this - use SubtitleManager.CanControlSubtitles()

SubtitleManager.ProcessURLInput(VRCUrl): void

Loads subtitles from the URL globally or locally (depending on IsLocal() value)

  • When using USharpVideo - only the player who can control the video player can do this
  • For other video players - if IsLocked() is true then only the Master can do this
  • To check whenever player is able to execute this - use SubtitleManager.CanControlSubtitles()

SubtitleManager.ClearSubtitles(): void

Clears the subtitles globally or locally (depending on IsLocal() value)

  • When using USharpVideo - only the player who can control the video player can do this
  • For other video players - if IsLocked() is true then only the Master can do this
  • To check whenever player is able to execute this - use SubtitleManager.CanControlSubtitles()

SubtitleManager.IsLocked(): bool

Whenever the access is locked to Master only

  • When using USharpVideo it shares the same state with it

SubtitleManager.SetLocked(bool): void

Change lock state, must be executed by the Master

  • Does nothing when used with USharpVideo as it shares the same state with it
  • This can fail if the synchronization is ongoing - check if SubtitleManager.IsSynchronized() is true before running it
  • To check whenever player is able to execute this - use SubtitleManager.IsPrivilegedUser(VRCPlayerApi)

SubtitleManager.IsEnabled(): bool

Whenever the subtitles are enabled for the the player

SubtitleManager.SetEnabled(bool): void

Enable or disable the subtitles for the the player

SubtitleManager.IsLocal(): bool

Whenever the player is using local subtitles

SubtitleManager.SetLocal(bool): void

Switch between using global and local subtitles

SubtitleManager.SynchronizeSubtitles(): void

Re-synchronizes the subtitles globally, only the person who loaded them can do this (or the master if the synchronization is finished) - this can change when that person leaves the instance or lock state changes - check the SubtitleManager.gameObject owner in this case

  • This can fail if the synchronization is ongoing - check if SubtitleManager.IsSynchronized() is true before running it
  • To check whenever player is able to execute this - use SubtitleManager.CanSynchronizeSubtitles()

SubtitleOverlayHandler.GetCanvasTransform(): Transform

Use this method to get transform values of the overlay's Canvas in case you want to display something on the same screen

SubtitleOverlayHandler.MoveOverlay(GameObject): void

Moves the overlay to the given object's transform values

  • Make sure that the settings popup is not visible at this time as it will stay in the old position until it is re-opened

SubtitleControlHandler.IsSettingsPopupActive(): bool

Check if settings popup is currently open

SubtitleControlHandler.ToggleSettingsPopup(): void

Toggle settings popup, use this to show and hide the popup using separate button

SubtitleControlHandler.ImportSettingsFromString(string): void

Import settings from the given string (the same string which is displayed in the settings window), the format is pretty easy to figure out

usharpvideo-subtitles's People

Contributors

jacklul avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

usharpvideo-subtitles's Issues

Issue with French Subtitles

Hi ! Sorry for my english, I've an issue with French Subtitles, when I load it, I ve issue with special characters (é à ç etc...)
Subtitle load it like "?" inside a black square.

Do you know how I can solve this thing ?

Thank you !

B4rTux_

Could not subtitle connect to video player

I tried to set up on VRchat world to make a subtitle for the video player. It seems not working right when I tested paste subtitle, and nothing happened. I went to your VRchat world subtitle. Your subtitle is working with video than my VRchat world. Is there a subtitle to connect video player match install?

trimStart(Char) variant isn't exposed in Udon sharp anymore

Assets/USharpVideoSubtitles/Scripts/SubtitleManager.cs(545,75): Method is not exposed to Udon: 'text.Substring(text.IndexOf(@"{\an") + 6).TrimStart(' ')'
Code_2YAI6q2D54

this could be fixed by changing to a different trimStart variant, my VRChat SDK - Worlds version is 3.5.0

Issues on Quest platform

Tested it on my Quest 1 and found out:

  • Status field does not show prefab status / is stuck with "Not initialized" placeholder - InputField not accessible by Udon? workaround applied
  • Users are not able to paste the subtitles - TextMeshPro input field seems to not trigger input popup?
  • Users unable to import/export their setttings - InputField not accessible by Udon?

As far as I know, these issues are caused by Quest VRChat build and cannot be fixed in the prefab but I'm keeping this issue open to keep track of this issue.
USharpVideo seems to have the same issue, the fields for current and previous URL always remain empty.

Everything else seems to work.

Related canny issue: https://vrchat.canny.io/quest-creators/p/864-ui-inputfields-are-not-functional-on-quest

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.