public
Created

Beamer Bookmarklet for Vimeo

  • Download Gist
beamer.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
var Beamer = {
open: function (movie) {
var beamerURL = 'beamer.control://play?url=' + escape(movie["URL"]);
 
if (movie["previewURL"] != null)
beamerURL += '&preview=' + escape(movie["previewURL"]);
 
if (movie["title"] != null)
beamerURL += "&title=" + escape(movie["title"]);
 
if (movie["duration"] != null)
beamerURL += "&duration=" + escape(movie["duration"]);
 
window.location.href = beamerURL;
},
 
playCallback: function(movie, error) {
if (movie == null || movie["URL"] == null) {
error = "Sorry, did not find suitable movie information to send to Beamer";
}
 
if (error != null) {
alert(error);
} else {
Beamer.open(movie);
}
},
 
playVimeoMovie: function(callback) {
var video;
for (property in window) {
if (property.match(/^clip\d+_\d+$/)) {
video = window[property].config;
break;
}
}
 
if (video == undefined) {
callback(null, "Could not find movie information on this page");
return;
} // else
 
var movie = {};
movie["previewURL"] = video["video"]["thumbnail"];
// Gather all video vars
var clip_id = video["video"]["id"];
var signature = video["request"]["signature"];
var timestamp = video["request"]["timestamp"];
var quality = video["video"]["hd"] == 1 ? "hd" : "sd";
 
movie["URL"] = "http://player.vimeo.com/play_redirect?clip_id=" + clip_id +
"&sig=" + signature +
"&time=" + timestamp +
"&quality=" + quality +
"&codecs=h264" +
"&type=moogaloop_local" +
"&embed_location=";
 
movie["title"] = video["video"]["title"] + " (" + video["video"]["url"] + ")"
movie["duration"] = video["video"]["duration"];
 
callback(movie);
},
 
run: function () {
if (window.location.href.match(/^https?:\/\/vimeo\.com\/\d+/)) {
Beamer.playVimeoMovie(Beamer.playCallback);
} else {
alert('Sorry, this bookmarklet only works on single video Vimeo pages.');
}
},
 
}
 
Beamer.run()

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.