From 2d0fe02a195326d6092e9dbc466fa077ec06693a Mon Sep 17 00:00:00 2001 From: Calvin Montgomery Date: Wed, 9 Jul 2014 21:55:49 -0700 Subject: [PATCH] Move vimeo simulator out of the changemedia callback --- www/js/callbacks.js | 54 +++++---------------------------------------- www/js/util.js | 50 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 48 deletions(-) diff --git a/www/js/callbacks.js b/www/js/callbacks.js index d18af9f6..f495528a 100644 --- a/www/js/callbacks.js +++ b/www/js/callbacks.js @@ -850,16 +850,16 @@ Callbacks = { }); } - if(CHANNEL.opts.allow_voteskip) + if (CHANNEL.opts.allow_voteskip) $("#voteskip").attr("disabled", false); $("#currenttitle").text("Currently Playing: " + data.title); - if(data.type != "sc" && PLAYER.type == "sc") + if (data.type != "sc" && PLAYER.type == "sc") // [](/goddamnitmango) fixSoundcloudShit(); - if(data.type != "jw" && PLAYER.type == "jw") { + if (data.type != "jw" && PLAYER.type == "jw") { // Is it so hard to not mess up my DOM? $("
").attr("id", "ytapiplayer") .insertBefore($("#ytapiplayer_wrapper")); @@ -874,60 +874,18 @@ Callbacks = { data.url = data.id; } - /* - VIMEO SIMULATOR 2014 - - Vimeo decided to block my domain. After repeated emails, they refused to - unblock it. Rather than give in to their demands, there is a serverside - option which extracts direct links to the h264 encoded MP4 video files. - These files can be loaded in a custom player to allow Vimeo playback without - triggering their dumb API domain block. - - It's a little bit hacky, but my only other option is to keep buying new - domains every time one gets blocked. No thanks to Vimeo, who were of no help - and unwilling to compromise on the issue. - */ if (NO_VIMEO && data.type === "vi" && data.meta.direct) { - data.type = "fi"; - // For browsers that don't support native h264 playback - if (USEROPTS.no_h264) { - data.forceFlash = true; - } - - /* Convert youtube-style quality key to vimeo workaround quality */ - var q = { - small: "mobile", - medium: "sd", - large: "sd", - hd720: "hd", - hd1080:"hd", - highres: "hd" - }[USEROPTS.default_quality] || "sd"; - - var fallback = { - hd: "sd", - sd: "mobile", - mobile: false - }; - - while (!(q in data.meta.direct) && q != false) { - q = fallback[q]; - } - - if (!q) { - q = "sd"; - } - - data.url = data.meta.direct[q].url; + data = vimeoSimulator2014(data); } + /* RTMP player has been replaced with the general flash player */ if (data.type === "rt") { data.url = data.id; data.type = "fi"; data.forceFlash = true; } - if(data.type != PLAYER.type) { + if (data.type != PLAYER.type) { loadMediaPlayer(data); } diff --git a/www/js/util.js b/www/js/util.js index b1e42eaf..31dc2c67 100644 --- a/www/js/util.js +++ b/www/js/util.js @@ -2674,3 +2674,53 @@ function formatScriptAccessPrefs() { }); }); } + +/* + VIMEO SIMULATOR 2014 + + Vimeo decided to block my domain. After repeated emails, they refused to + unblock it. Rather than give in to their demands, there is a serverside + option which extracts direct links to the h264 encoded MP4 video files. + These files can be loaded in a custom player to allow Vimeo playback without + triggering their dumb API domain block. + + It's a little bit hacky, but my only other option is to keep buying new + domains every time one gets blocked. No thanks to Vimeo, who were of no help + and unwilling to compromise on the issue. +*/ +function vimeoSimulator2014(data) { + /* Vimeo Simulator uses the raw file player */ + data.type = "fi"; + + /* For browsers that don't support native h264 playback */ + if (USEROPTS.no_h264) { + data.forceFlash = true; + } + + /* Convert youtube-style quality key to vimeo workaround quality */ + var q = { + small: "mobile", + medium: "sd", + large: "sd", + hd720: "hd", + hd1080:"hd", + highres: "hd" + }[USEROPTS.default_quality] || "sd"; + + var fallback = { + hd: "sd", + sd: "mobile", + mobile: false + }; + + /* Pick highest quality less than or equal to user's preference from the options */ + while (!(q in data.meta.direct) && q != false) { + q = fallback[q]; + } + if (!q) { + q = "sd"; + } + + data.url = data.meta.direct[q].url; + return data; +}