iBicha / UnityYoutubePlayer

Play YouTube videos in Unity
The Unlicense
336 stars 63 forks source link

[WebGL] JsonSerializationException #42

Closed DefaultV closed 3 years ago

DefaultV commented 3 years ago

Building a Unity project with WebGL as target, having the YoutubePlayer playing a simple URL on awake (Working in Editor) provides a black screen in the build and the following in the target console:

image

Video used: https://www.youtube.com/watch?v=eo8apVpcrIc

Unity export uses brotli compression with stripped engine code. Adding a constructor manually by embedding the package also provides same error. Code is as following in the YoutubeVideoMetadata.cs:


[JsonConstructor]
public YoutubeVideoMetaData(string Title, string Url, string Extension, YoutubeVideoFormat[] requestedFormats, YoutubeVideoFormat[] Formats, string FileName) {
    this.Title = Title;
    this.Url = Url;
    this.Extension = Extension;
    this.requestedFormats = requestedFormats;
    this.Formats = Formats;
    this.FileName = FileName;
}

Will gladly provide more info if needed!

iBicha commented 3 years ago

This might be a separate issue, but before digging further into it, it's worth mentioning that WebGL is not supported because of CORS. See #40

iBicha commented 3 years ago

On another note, I suspect that your constructor is being stripped out, because the compiler doesn't see where it's being used.

DefaultV commented 3 years ago

Hey again! Thanks for the quick response! Building with no stripping and adding constructors indeed removed the error, thanks for the heads-up!

whynames commented 1 year ago

Hey can you explain how did you make it work in Webgl?