Closed
Bug 1244459
Opened 10 years ago
Closed 8 years ago
"TypeError: ytPlayer.getPlayerState is not a function" after "youtube.com/channel/"*
Categories
(Firefox :: Extension Compatibility, defect)
Tracking
()
RESOLVED
WONTFIX
| Tracking | Status | |
|---|---|---|
| platform-rel | --- | - |
People
(Reporter: willalwaysdie, Unassigned)
Details
(Whiteboard: [platform-rel-Youtube])
Attachments
(1 file)
|
2.28 KB,
application/zip
|
Details |
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.97 Safari/537.36
Steps to reproduce:
I have a problem with FF and Youtube API (ALSO I should say that I don't have that problem in Chomium-browsers - Google Chrome...)
You can download my attached Addon for FF to test the problem I described below.
Addon contains next scripts:
-------content-script.js:-------
var YtWatchPageStuff = {
initProcess: function () {
messageManager.loadFrameScript("chrome://myaddon/content/frame-script.js", true);
}
};
YtWatchPageStuff.initProcess();
--------------------------
-------frame-script.js:-------
addEventListener("DOMContentLoaded", function(e) {
var doc = e.originalTarget;
if (doc.nodeName != "#document") return;
if (doc.body !== null && doc.location.href !== null && doc.location.href.search(/youtube\.com/i) !== -1) {
var YtWatchScript = doc.createElement('script');
YtWatchScript.setAttribute("src", "chrome://myaddon/content/ytscript.js");
doc.head.appendChild(YtWatchScript);
YtWatchScript.parentNode.removeChild(YtWatchScript);
}
});
--------------------------
------ytscript.js:-------
function YoutubePageInCurrentTabWasChanged(event) {
if (typeof ytPlayer.getPlayerState() === 'undefined' || ytPlayer.getPlayerState() === -1 || ytPlayer.getPlayerState() === 5 || ytPlayer.getPlayerState() === 3) {
setTimeout(function() { YoutubePageInCurrentTabWasChanged(event); }, 10);
return;
}
if (event == -1 && typeof ytPlayer.getPlayerState !== 'undefined' && ytPlayer.getPlayerState() >= 0 && ytPlayer.getPlayerState() !== 2) {
alert("GOOD!");
} else return;
}
function onYouTubePlayerReady(player) {
ytPlayer = player;
if (typeof player !== 'object') return;
if (window.location.href.match(/watch/i)) {
alert("GOOD!");
}
ytPlayer.addEventListener('onStateChange', YoutubePageInCurrentTabWasChanged);
}
--------------------------
**********************
So here's my problem:
Using this extension I should get pop-up message "GOOD!" only on "youtube.com/watch*"
For e.g. in one my tab when I open https://www.youtube.com/watch?v=FrG4TEcSuRg or just https://youtube.com/ and then clicking some video from the main page I get this message ("GOOD!") - so it works ok.
Also when I change the current video to some others videos (clicking some videos/links from https://www.youtube.com/watch?v=FrG4TEcSuRg - just see first schreenshot) it again pops up the message (it still works ok).
1 screenshot - http://postimg.org/image/99nfo41y7/full/
But if I open some youtube/channel* page for e.g. https://www.youtube.com/channel/UCrDkAvwZum-UTjHmzDI2iIw and click on the title of autoplaying video (or other videos you can see on this channel page) to open it in youtube/watch* (see screenshot 2) and when it loads the video in youtube/watch* in the same tab it doesn't show the pop up message "GOOD!" anymore, instead you can see "TypeError: ytPlayer.getPlayerState is not a function" in Console.
2 screenshot - http://postimg.org/image/nrkmw3t9b/
For channel page please use my link - https://www.youtube.com/channel/UCrDkAvwZum-UTjHmzDI2iIw
because this channel page contains an autoplaying video (so that problem is only related to channel pages that contain autoplaying video in it)
(when you test the problem with channel don't use ctrl+r, adressbar or bookmarks to change the youtube page in the current tab, click only on links you can see on the page)
I hope you can understand my problem. Sorry for my English!
And again I don't have that problem in Google Chrome (I use the same script - ytscript.js for Chrome's extension) - I open https://www.youtube.com/channel/UCrDkAvwZum-UTjHmzDI2iIw in Chrome and click on the title of autoplaying video and when it loads the video in youtube/watch* in the same tab I get the message "GOOD!"
Actual results:
I get "TypeError: ytPlayer.getPlayerState is not a function" when I open an autoplaying video (click on the title of it) from the channel page in the current tab
Expected results:
pop-up message "GOOD!" when it's loaded https://www.youtube.com/watch?v=FrG4TEcSuRg from https://www.youtube.com/channel/UCrDkAvwZum-UTjHmzDI2iIw in the same tab
Updated•10 years ago
|
platform-rel: --- → ?
Updated•10 years ago
|
Whiteboard: [platform-rel-Youtube]
Updated•10 years ago
|
platform-rel: ? → -
Comment 1•8 years ago
|
||
Mass-closing old Extension Compatibility bugs that relate to legacy add-ons or NPAPI plug-ins. If you think this bug is still valid, please reopen or comment.
Sorry for the bug spam, and happy Friday!
Status: UNCONFIRMED → RESOLVED
Closed: 8 years ago
Resolution: --- → WONTFIX
You need to log in
before you can comment on or make changes to this bug.
Description
•