Skip to content

Commit

Permalink
Fix title not display correctly on play custom URL...
Browse files Browse the repository at this point in the history
after play from playlist without YTTL config'd.
  • Loading branch information
JLChnToZ committed Apr 23, 2024
1 parent 2d5cab5 commit ddaf394
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 26 deletions.
53 changes: 51 additions & 2 deletions Packages/idv.jlchntoz.vvmw/Runtime/VVMW/Core.asset
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3}
m_Name: Core
m_EditorClassIdentifier:
serializedUdonProgramAsset: {fileID: 11400000, guid: c66af6782ebcca44cb681de0d9b43652,
serializedUdonProgramAsset: {fileID: 11400000, guid: 0fc467ba7ec4fbf43a9186c70fe1d22a,
type: 2}
udonAssembly:
assemblyError:
Expand Down Expand Up @@ -44,7 +44,7 @@ MonoBehaviour:
Data:
- Name:
Entry: 12
Data: 65
Data: 66
- Name:
Entry: 7
Data:
Expand Down Expand Up @@ -3751,6 +3751,55 @@ MonoBehaviour:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: hasCustomTitle
- Name: $v
Entry: 7
Data: 213|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: hasCustomTitle
- Name: <UserType>k__BackingField
Entry: 9
Data: 46
- Name: <SystemType>k__BackingField
Entry: 9
Data: 46
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 214|System.Collections.Generic.List`1[[System.Attribute, mscorlib]],
mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
Expand Down
55 changes: 34 additions & 21 deletions Packages/idv.jlchntoz.vvmw/Runtime/VVMW/Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public class Core : UdonSharpEventSender {
public string viewCount = "";
[NonSerialized, FieldChangeCallback(nameof(Description))]
public string description = "";
bool hasCustomTitle;

public string[] PlayerNames {
get {
Expand Down Expand Up @@ -282,31 +283,31 @@ public bool IsTrusted {
string Title {
get => title;
set {
if (url == null || !url.Equals(localUrl)) return;
if (hasCustomTitle || url == null || !url.Equals(localUrl)) return;
title = value;
}
}

string Author {
get => author;
set {
if (url == null || !url.Equals(localUrl)) return;
if (hasCustomTitle || url == null || !url.Equals(localUrl)) return;
author = value;
}
}

string ViewCount {
get => viewCount;
set {
if (url == null || !url.Equals(localUrl)) return;
if (hasCustomTitle || url == null || !url.Equals(localUrl)) return;
viewCount = value;
}
}

string Description {
get => description;
set {
if (url == null || !url.Equals(localUrl)) return;
if (hasCustomTitle || url == null || !url.Equals(localUrl)) return;
description = value;
}
}
Expand Down Expand Up @@ -405,15 +406,7 @@ public void PlayUrlMP(VRCUrl pcUrl, VRCUrl questUrl, byte playerType) {
#endif
activeHandler.LoadUrl(url, false);
if (RequestSync()) state = LOADING;
if (yttl != null) {
if (!url.Equals(this.url)) {
author = "";
title = "";
viewCount = "";
description = "";
}
yttl.LoadData(url, this);
}
LoadYTTL();
}

public override void OnVideoError(VideoError videoError) {
Expand Down Expand Up @@ -756,7 +749,8 @@ public override void OnDeserialization() {
url = pcUrl;
altUrl = questUrl;
}
if (state != IDLE && localUrl != url && (!IsUrlValid(localUrl) || !IsUrlValid(url) || localUrl.Get() != url.Get())) {
bool shouldReload = state != IDLE && localUrl != url && (!IsUrlValid(localUrl) || !IsUrlValid(url) || localUrl.Get() != url.Get());
if (shouldReload) {
if (activeHandler == null) {
Debug.LogWarning($"[VVMW] Owner serialization incomplete, will queue a sync request.");
SendCustomEventDelayedSeconds(nameof(_RequestOwnerSync), 1);
Expand All @@ -770,15 +764,9 @@ public override void OnDeserialization() {
trustUpdated = false;
SendEvent("_OnVideoBeginLoad");
activeHandler.LoadUrl(url, false);
if (yttl != null) {
author = "";
title = "";
viewCount = "";
description = "";
yttl.LoadData(url, this);
}
}
localUrl = url;
if (shouldReload) LoadYTTL();
if (activeHandler != null && activeHandler.IsReady) {
int intState = state;
switch (intState) {
Expand Down Expand Up @@ -934,12 +922,37 @@ public void _SyncAudioLink() {
public void Yttl_OnDataLoaded() => SendEvent("_OnTitleData");

public void SetTitle(string title, string author) {
hasCustomTitle = true;
url = VRCUrl.Empty;
this.title = title;
this.author = author;
description = "";
viewCount = "";
SendEvent("_OnTitleData");
}

public void _ResetTitle() {
if (!hasCustomTitle) return;
hasCustomTitle = false;
url = VRCUrl.Empty;
if (yttl == null) {
author = "";
title = "";
viewCount = "";
description = "";
} else
LoadYTTL();
SendEvent("_OnTitleData");
}

void LoadYTTL() {
if (yttl == null || hasCustomTitle || url.Equals(localUrl)) return;
author = "";
title = "";
viewCount = "";
description = "";
if (localUrl != null)
yttl.LoadData(localUrl, this);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3}
m_Name: FrontendHandler
m_EditorClassIdentifier:
serializedUdonProgramAsset: {fileID: 11400000, guid: 5c092b7f8962cd844be63af6e369643f,
serializedUdonProgramAsset: {fileID: 11400000, guid: 774834c68f75e0341872b18681f02dda,
type: 2}
udonAssembly:
assemblyError:
Expand Down
7 changes: 5 additions & 2 deletions Packages/idv.jlchntoz.vvmw/Runtime/VVMW/FrontendHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,10 @@ public override void OnDeserialization() {
localHistoryTitles = string.IsNullOrEmpty(historyTitles) && (historyUrls == null || historyUrls.Length == 0) ?
new string[0] : historyTitles.Split('\u2029');
localFlags = flags;
if (playListIndex > 0 && (localPlayListIndex != playListIndex || localPlayingIndex != playingIndex))
core.SetTitle(playListEntryTitles[playingIndex], playListTitles[playListIndex - 1]);
if (playListIndex > 0) {
if (localPlayListIndex != playListIndex || localPlayingIndex != playingIndex)
core.SetTitle(playListEntryTitles[playingIndex], playListTitles[playListIndex - 1]);
} else core._ResetTitle();
localPlayListIndex = playListIndex;
localPlayingIndex = playingIndex;
core.Loop = RepeatOne;
Expand Down Expand Up @@ -565,6 +567,7 @@ void PlayQueueList(int index, bool deleteOnly) {
localQueuedTitles = newTitles;
if (!deleteOnly) {
core.PlayUrl(url, playerIndex);
core._ResetTitle();
RecordPlaybackHistory(url, playerIndex, title);
}
RequestSync();
Expand Down

0 comments on commit ddaf394

Please sign in to comment.