jacklul/USharpVideo-Subtitles
소개
This prefab adds subtitles support to USharpVideo (or any other video player) in VRChat
디자인 및 미디어What you can do
- Load subtitles from the pasted text or URL
- Subtitle synchronization with everyone in the instance
- Option to use own subtitles locally
- Rich customization with the ability to save the settings
측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalSubtitles 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.
The core of this prefab is based on this code by Haï~.
Features
- Load subtitles from the pasted text or URL
- Subtitle synchronization with everyone in the instance
- Option to use own subtitles locally
- Rich customization with the ability to save the settings
- Integration with USharpVideo
- Persistence support
Requirements
- Unity 2022.3.22f1+ (see VRChat's Current Unity Version page)
- VRChat SDK 3.7.4+
- USharpVideo v1.0.0+
- Project created using Creator Companion
Installation
[!TIP] I suggest adding "subtitles" to your world's tags when using this prefab so that people can find worlds with subtitle support more easily.
Import USharpVideo
- This is required even if you're not planning on using it
Import latest release unitypackage
Drag the
Subtitlesprefab into your scene- when using USharpVideo you can also drag
Subtitlesprefab intoUSharpVideoin your scene and resetSubtitlesobject's transform values
- when using USharpVideo you can also drag
When a window asking you to import TextMeshPro Essentials appears - just do it
Add a reference in the
Subtitlesobject (SubtitleManager script) to:- when using USharpVideo (Target Video Player field) - USharpVideoPlayer from the
USharpVideoobject - 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)
- when using USharpVideo (Target Video Player field) - USharpVideoPlayer from the
Add a reference in the
Subtitles/Overlayobject (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/Overlayobject's position and rotation to match the video screen object (while keeping the mentioned earlier field empty)
- if this doesn't work on your world then you will have to manually adjust
Upgrading
Delete the prefab from your scene
Import new package
Re-do Installation steps 3. 5. and 6.
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
- SubtitleManager.HasSubtitles(): bool
- SubtitleManager.ProcessInput(string): void
- SubtitleManager.ProcessURLInput(VRCUrl): void
- SubtitleManager.ClearSubtitles(): void
- SubtitleManager.IsLocked(): bool
- SubtitleManager.SetLocked(bool): void
- SubtitleManager.IsEnabled(): bool
- SubtitleManager.SetEnabled(bool): void
- SubtitleManager.IsLocal(): bool
- SubtitleManager.SetLocal(bool): void
- SubtitleManager.GetTimeOffset(): float
- SubtitleManager.SetTimeOffset(float): void
- SubtitleManager.IsSyncedURL(): bool
- SubtitleManager.ReloadSyncedURL(): bool
- SubtitleManager.SynchronizeSubtitles(): void
- SubtitleOverlayHandler.GetCanvasTransform(): Transform
- SubtitleOverlayHandler.MoveOverlay(GameObject): void
- SubtitleControlHandler.IsSettingsPopupActive(): bool
- SubtitleControlHandler.ToggleSettingsPopup(): void
- SubtitleControlHandler.ImportSettingsFromString(string): void
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
trueif 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()istruethen 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()istruethen 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()istruethen 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()istruebefore 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.GetTimeOffset(): float
Get current time offset value
SubtitleManager.SetTimeOffset(float): void
Set time offset value
SubtitleManager.IsSyncedURL(): bool
Check if URL was synced or not, make sure to also check if SubtitleManager.IsSynchronized() is true
- If this is false and
SubtitleManager.IsSynchronized()istruethen subtitles from pasted text are used
SubtitleManager.ReloadSyncedURL(): bool
Reload data from synced URL, can be used to retry failed requests
- This is done locally, anyone can call this
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()istruebefore 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
관련 프로젝트 살펴보기
불러오는 중…
