Improve behavior of custom embed w.r.t. https

Instead of silently failing when browser policy blocks HTTP embeds over HTTPS, pre-fill the video div with an error message and attempt to salvage the link with s/http/https/g.
This commit is contained in:
calzoneman 2014-12-10 23:56:17 -06:00
parent db56a8869d
commit a3a9fa074e
2 changed files with 25 additions and 0 deletions

View file

@ -89,6 +89,7 @@ MediaRefresherModule.prototype.refreshGoogleDocs = function (media, cb) {
case "Video not found":
case "Private video":
case "Google Docs error: Video has exceeded quota":
case "There is currently a bug with Google Drive which prevents playback of videos 1 hour long or longer.":
self.channel.logger.log("[mediarefresher] Google Docs refresh failed: " +
err);
self.channel.activeLock.release();
@ -137,6 +138,7 @@ MediaRefresherModule.prototype.initGooglePlus = function (media, cb) {
case "HTTP 302":
case "Video not found":
case "Private video":
case "Unable to retreive duration from Google+. This might be because the video is still processing.":
self.channel.logger.log("[mediarefresher] Google+ refresh failed: " +
err);
self.channel.activeLock.release();

View file

@ -863,6 +863,29 @@ var CustomPlayer = function (data) {
removeOld();
var div = $("#ytapiplayer");
div.attr("id", "");
/*
* 2014-12-10
*
* If a user is connected via HTTPS and the custom link is
* HTTP, then the embed fails due to mixed active content
* policy. Display a message indicating this.
*/
if (location.protocol.match(/^https/) &&
self.videoId.match(/http:/)) {
div.html("You are currently connected via HTTPS but " +
"the custom embed link uses non-secure HTTP. " +
"Your browser may therefore block it from loading. " +
"To fix this, either add the custom embed as a secure " +
"URL (https://...) if the source supports it, or " +
"visit this page over plain HTTP (your websocket will still " +
"use secure HTTPS for communication, just the page " +
"will load over plain HTTP).");
// Try to salvage the link
self.videoId = self.videoId.replace(/http:/g, "https:");
}
div.append(self.videoId);
self.player = div.find("iframe");