The YouTube livestream chat works on the desktop by using
<iframe src="https://youtube.com/live_chat?v=[LIVE VIDEO ID]"></iframe>
But, it doesn't appear on mobile using the same code.
I've narrowed the problem down to what seems to be a User-Agent issue. When testing the mobile version of the site with Chrome on a desktop (inspect element > phone icon > iphonex > refresh), it still doesn't show up. But when I change the user agent on chromes iPhone (inspect element-ed) version and refresh, it shows up (inspect element > network conditions > user agent).
To backup, this claim about the User-Agent, the only other thread I could find on the internet about this (found Here) talks about how it fixed it for him (or maybe not?). When I tried implementing his solution, I got no results.
I've tried to change the User-Agent using PHP and JavaScript now, neither of them working on an iPhone's Safari or the Google Chrome iPhone (inspect element-ed).
I've also tried re-creating the embed with PHP, but it failed with multiple 404 errors.
It's odd because when I change the User-Agent through the inspect element-ed version, it works.
I've tried changing the User-Agent in JavaScript with
//First Try
Object.defineProperty(navigator, 'userAgent', {
get: function () { return 'Mozilla/5.0 (Windows NT 6.2; WOW64;
rv:28.0) Gecko/20100101 Firefox/28.0)'; }});
//Second Try
navigator.__defineGetter__('userAgent', function () {
return "Mozilla/5.0 (Windows NT 6.2; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0)"});
//Third Try
var xhr = new XMLHttpRequest(...);
xhr.setRequestHeader("User-Agent","test");
I've tried changing it with PHP with
ini_set('user_agent', 'MyBrowser v42.0.4711');
This leads me to believe that I'm setting it wrong in all of these, there's another factor I'm forgetting, or mobile isn't capable of supporting it.
But, if mobile wasn't capable of setting it, it would show me a message. When setting the User-Agent in PHP, nothing happened, until I requested the desktop site which gave me a message along the lines of
Your browser is too old to use livechat
Not sure if it really is, or it's just the User-Agent.
I'm open to using the YouTubeLivestreamingChat API, but I can't really figure out how to use it (specifically what a part is). I'm also open to a solution in PHP or JavaScript.