nystudio107 / craft-youtubeliveembed

This plugin allows you to embed a YouTube live stream and/or live chat on your webpage
MIT License
17 stars 4 forks source link

Chat no longer working in craft 4 #35

Closed JayGreentree closed 1 year ago

JayGreentree commented 2 years ago

Describe the bug

When installed on craft 4.x I get video but the chat gives crafts' 404 template not found error. Instead of the iframe giving the Youtube chat embed url it is only showing "&embed_domain=example.com" (tested locally and in production)

Screenshots

2022-10-04 12_49_05-

Versions

khalwat commented 2 years ago

Can you give me the Twig code you're using to render both the YouTube video, and also the chat please?

khalwat commented 2 years ago

Also in local dev with devMode on, you should be getting a full stack trace of the error... that would be helpful in diagnosing this as well.

JayGreentree commented 2 years ago

Can you give me the Twig code you're using to render both the YouTube video, and also the chat please?

` {% if craft.youtubelive.isLive() %} {{ craft.youtubelive.embedStream() }} {% else %}

                  {% endif %}`

` {% if craft.youtubelive.isLive() %} {{ craft.youtubelive.embedStream() }} {% else %}

                  {% endif %}`

When the page is rendered this is what the iframe shows:

<div class="youtube-chat-resp-container"><iframe class="youtube-chat-resp-iframe" src="&embed_domain=localhost" allow="autoplay; fullscreen; encrypted-media"></iframe></div>

Also in local dev with devMode on, you should be getting a full stack trace of the error... that would be helpful in diagnosing this as well.

I copied the craft.youtubelive.embedChat() to a blank twig template:

FireShot Capture 006 -  - localhost

craft 3 works as expected if that makes any difference. I did try to look at the plugin but I'm not a php "expert". Nothing really stuck out as being an obvious issue.

https://github.com/JayGreentree/craft4-dev-live has my current local install if that would help.

khalwat commented 2 years ago

Here's what it renders the chat:

https://github.com/nystudio107/craft-youtubeliveembed/blob/develop/src/services/Embed.php#L87

This calls getYoutubeChatUrl which returns an empty string (which is what you're seeing):

https://github.com/nystudio107/craft-youtubeliveembed/blob/61f060e7fd87ad81a9904d8de99ff783fd52c2e8/src/services/Embed.php#L164

...if getVideoIdFromLiveStream doesn't return an id.

But the code looks the same on Craft 3 vs. Craft 4 -- are you sure the data being fed into it is the same? Did you configure it via the config/youtubeliveembed.php file?

JayGreentree commented 2 years ago

I'll try that when Im able I have very limited internet currently. I didnt have the config file in v3 i used the ui admin/settings/plugins/youtubeliveembed.

JayGreentree commented 2 years ago

I did clean dev installs of v3 and v4 using the config file and same result. Video works on both but chat is not working on craft v4 and other then the 404 error I see nothing related to the plugin in the logs except that its in memory. If it helps I've added my v4 logs console-2022-08-23.zip

khalwat commented 1 year ago

Okay so I think the problem here was just that the plugin settings were no longer visible in the Craft 4 version.

I've updated both:

v3 -> https://github.com/nystudio107/craft-youtubeliveembed/releases/tag/1.0.9

v4 -> https://github.com/nystudio107/craft-youtubeliveembed/releases/tag/4.0.0

Please update, and then ensure your YouTube Channel ID is set properly in the plugin settings. This should resolve the issue for you.