Skip to content

Commit faca3f7

Browse files
committed
Add handling for the VideoError parameter on OnVideoError
1 parent 34f18ad commit faca3f7

File tree

6 files changed

+124
-14
lines changed

6 files changed

+124
-14
lines changed

Assets/USharpVideo/Scenes/VideoPlayerExampleScene.unity

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4536,42 +4536,42 @@ PrefabInstance:
45364536
type: 3}
45374537
propertyPath: DynamicMaterials.Array.data[0]
45384538
value:
4539-
objectReference: {fileID: 2100000, guid: dfa3df02074a4a244bdae8f939beccbe, type: 2}
4539+
objectReference: {fileID: 2100000, guid: dd37924cea904bc408bb5659e140ed22, type: 2}
45404540
- target: {fileID: 6759095419728963412, guid: 8894fa7e4588a5c4fab98453e558847d,
45414541
type: 3}
45424542
propertyPath: DynamicMaterials.Array.data[1]
45434543
value:
4544-
objectReference: {fileID: 2100000, guid: 4e42f7c9c766b1b4b9a1678c9934d795, type: 2}
4544+
objectReference: {fileID: 2100000, guid: dc056341635f19c43912574c1c0bf2be, type: 2}
45454545
- target: {fileID: 6759095419728963412, guid: 8894fa7e4588a5c4fab98453e558847d,
45464546
type: 3}
45474547
propertyPath: DynamicMaterials.Array.data[2]
45484548
value:
4549-
objectReference: {fileID: 2100000, guid: dd37924cea904bc408bb5659e140ed22, type: 2}
4549+
objectReference: {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
45504550
- target: {fileID: 6759095419728963412, guid: 8894fa7e4588a5c4fab98453e558847d,
45514551
type: 3}
45524552
propertyPath: DynamicMaterials.Array.data[3]
45534553
value:
4554-
objectReference: {fileID: 2100000, guid: dc056341635f19c43912574c1c0bf2be, type: 2}
4554+
objectReference: {fileID: 2100000, guid: a882e10351f5d0c46be0a0e6853422fe, type: 2}
45554555
- target: {fileID: 6759095419728963412, guid: 8894fa7e4588a5c4fab98453e558847d,
45564556
type: 3}
45574557
propertyPath: DynamicMaterials.Array.data[4]
45584558
value:
4559-
objectReference: {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
4559+
objectReference: {fileID: 2100000, guid: dfa3df02074a4a244bdae8f939beccbe, type: 2}
45604560
- target: {fileID: 6759095419728963412, guid: 8894fa7e4588a5c4fab98453e558847d,
45614561
type: 3}
45624562
propertyPath: DynamicMaterials.Array.data[5]
45634563
value:
4564-
objectReference: {fileID: 2100000, guid: a882e10351f5d0c46be0a0e6853422fe, type: 2}
4564+
objectReference: {fileID: 2100000, guid: 0ca000f61841d694caa625c0652a50a9, type: 2}
45654565
- target: {fileID: 6759095419728963412, guid: 8894fa7e4588a5c4fab98453e558847d,
45664566
type: 3}
45674567
propertyPath: DynamicMaterials.Array.data[6]
45684568
value:
4569-
objectReference: {fileID: 2100000, guid: 0ca000f61841d694caa625c0652a50a9, type: 2}
4569+
objectReference: {fileID: 2100000, guid: bc5bf9e5a224a6b4695639fbeed28616, type: 2}
45704570
- target: {fileID: 6759095419728963412, guid: 8894fa7e4588a5c4fab98453e558847d,
45714571
type: 3}
45724572
propertyPath: DynamicMaterials.Array.data[7]
45734573
value:
4574-
objectReference: {fileID: 2100000, guid: bc5bf9e5a224a6b4695639fbeed28616, type: 2}
4574+
objectReference: {fileID: 2100000, guid: 4e42f7c9c766b1b4b9a1678c9934d795, type: 2}
45754575
- target: {fileID: 6759095419728963412, guid: 8894fa7e4588a5c4fab98453e558847d,
45764576
type: 3}
45774577
propertyPath: DynamicMaterials.Array.data[8]
Binary file not shown.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:0e229e87a45ee72b27962475da7e89f034a0121c41d301c231e40aa806471a22
3+
size 2582329

Assets/USharpVideo/Scenes/VideoPlayerExampleScene/ReflectionProbe-0.exr.meta

Lines changed: 89 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/USharpVideo/Scripts/ExampleVideoPlayer.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using UdonSharp;
66
using UnityEngine;
77
using VRC.SDK3.Components;
8+
using VRC.SDK3.Components.Video;
89
using VRC.SDK3.Video.Components;
910
using VRC.SDK3.Video.Components.AVPro;
1011
using VRC.SDK3.Video.Components.Base;
@@ -125,7 +126,7 @@ public override void OnVideoEnd()
125126
}
126127
}
127128

128-
public override void OnVideoError()
129+
public override void OnVideoError(VideoError videoError)
129130
{
130131
_currentPlayer.Stop();
131132
Debug.LogError("Video failed: " + _syncedURL);

Assets/USharpVideo/Scripts/USharpVideoPlayer.cs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
using VRC.SDK3.Video.Components.Base;
1212
using VRC.SDKBase;
1313
using VRC.Udon;
14+
using VRC.SDK3.Components.Video;
1415

1516
#if UNITY_EDITOR && !COMPILER_UDONSHARP
1617
using UnityEditor;
1718
using UnityEditorInternal;
1819
using UdonSharpEditor;
19-
using System.Collections.Generic;
2020
#endif
2121

2222
namespace UdonSharp.Video
@@ -149,12 +149,12 @@ void TakeOwnership()
149149
void StartVideoLoad(VRCUrl url)
150150
{
151151
Debug.Log("[USharpVideo] Started video load");
152-
_currentPlayer.LoadURL(url);
153152
_statusStr = "Loading video...";
154153
SetStatusText(_statusStr);
155154
_loadingVideo = true;
156155
_currentLoadingTime = 0f;
157156
_currentRetryCount = 0;
157+
_currentPlayer.LoadURL(url);
158158
}
159159

160160
void PlayVideo(VRCUrl url, bool disablePlaylist)
@@ -452,7 +452,7 @@ public override void OnVideoEnd()
452452
PlayNextVideoFromPlaylist();
453453
}
454454

455-
public override void OnVideoError()
455+
public override void OnVideoError(VideoError videoError)
456456
{
457457
_loadingVideo = false;
458458
_currentLoadingTime = 0f;
@@ -462,7 +462,24 @@ public override void OnVideoError()
462462
_currentPlayer.Stop();
463463
Debug.LogError("[USharpVideo] Video failed: " + _syncedURL);
464464

465-
_statusStr = "Failed to load video";
465+
switch (videoError)
466+
{
467+
case VideoError.RateLimited:
468+
_statusStr = "Rate limited, try again in a few seconds";
469+
break;
470+
case VideoError.PlayerError:
471+
_statusStr = "Video player error";
472+
break;
473+
case VideoError.InvalidURL:
474+
_statusStr = "Invalid URL";
475+
break;
476+
case VideoError.AccessDenied:
477+
_statusStr = "Video blocked, enable untrusted URLs";
478+
break;
479+
default:
480+
_statusStr = "Failed to load video";
481+
break;
482+
}
466483
SetStatusText(_statusStr);
467484
PlayNextVideoFromPlaylist();
468485
}
@@ -479,7 +496,7 @@ void UpdateVideoLoad()
479496

480497
if (++_currentRetryCount > MAX_RETRY_COUNT)
481498
{
482-
OnVideoError();
499+
OnVideoError(VideoError.Unknown);
483500
}
484501
else
485502
{

0 commit comments

Comments
 (0)