From b34f97262997e864c0a177f954dab81c8b9b71a6 Mon Sep 17 00:00:00 2001 From: calzoneman Date: Sun, 21 Jun 2015 10:39:16 -0400 Subject: [PATCH] Add imgur and ustream --- player/imgur.coffee | 12 +++++++++++ player/update.coffee | 2 ++ player/ustream.coffee | 12 +++++++++++ www/js/player-new.js | 50 +++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 player/imgur.coffee create mode 100644 player/ustream.coffee diff --git a/player/imgur.coffee b/player/imgur.coffee new file mode 100644 index 00000000..0d5e70ea --- /dev/null +++ b/player/imgur.coffee @@ -0,0 +1,12 @@ +window.ImgurPlayer = class ImgurPlayer extends CustomEmbedPlayer + constructor: (data) -> + if not (this instanceof ImgurPlayer) + return new ImgurPlayer(data) + + @load(data) + + load: (data) -> + data.meta.embed = + tag: 'iframe' + src: "https://imgur.com/a/#{data.id}/embed" + super(data) diff --git a/player/update.coffee b/player/update.coffee index 7ba21d85..83090d14 100644 --- a/player/update.coffee +++ b/player/update.coffee @@ -10,6 +10,8 @@ TYPE_MAP = cu: CustomEmbedPlayer rt: RTMPPlayer hb: HitboxPlayer + us: UstreamPlayer + im: ImgurPlayer window.loadMediaPlayer = (data) -> if data.type of TYPE_MAP diff --git a/player/ustream.coffee b/player/ustream.coffee new file mode 100644 index 00000000..e935ae5d --- /dev/null +++ b/player/ustream.coffee @@ -0,0 +1,12 @@ +window.UstreamPlayer = class UstreamPlayer extends CustomEmbedPlayer + constructor: (data) -> + if not (this instanceof UstreamPlayer) + return new UstreamPlayer(data) + + @load(data) + + load: (data) -> + data.meta.embed = + tag: 'iframe' + src: "https://www.ustream.tv/embed/#{data.id}?v=3&wmode=direct&autoplay=1" + super(data) diff --git a/www/js/player-new.js b/www/js/player-new.js index d555dcc0..800f15f7 100644 --- a/www/js/player-new.js +++ b/www/js/player-new.js @@ -1,5 +1,5 @@ (function() { - var CustomEmbedPlayer, DEFAULT_ERROR, DailymotionPlayer, HITBOX_ERROR, HitboxPlayer, LivestreamPlayer, Player, RTMPPlayer, SoundCloudPlayer, TYPE_MAP, TwitchPlayer, VideoJSPlayer, VimeoPlayer, YouTubePlayer, genParam, sortSources, + var CustomEmbedPlayer, DEFAULT_ERROR, DailymotionPlayer, HITBOX_ERROR, HitboxPlayer, ImgurPlayer, LivestreamPlayer, Player, RTMPPlayer, SoundCloudPlayer, TYPE_MAP, TwitchPlayer, UstreamPlayer, VideoJSPlayer, VimeoPlayer, YouTubePlayer, genParam, sortSources, extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; @@ -921,6 +921,50 @@ })(CustomEmbedPlayer); + window.UstreamPlayer = UstreamPlayer = (function(superClass) { + extend(UstreamPlayer, superClass); + + function UstreamPlayer(data) { + if (!(this instanceof UstreamPlayer)) { + return new UstreamPlayer(data); + } + this.load(data); + } + + UstreamPlayer.prototype.load = function(data) { + data.meta.embed = { + tag: 'iframe', + src: "https://www.ustream.tv/embed/" + data.id + "?v=3&wmode=direct&autoplay=1" + }; + return UstreamPlayer.__super__.load.call(this, data); + }; + + return UstreamPlayer; + + })(CustomEmbedPlayer); + + window.ImgurPlayer = ImgurPlayer = (function(superClass) { + extend(ImgurPlayer, superClass); + + function ImgurPlayer(data) { + if (!(this instanceof ImgurPlayer)) { + return new ImgurPlayer(data); + } + this.load(data); + } + + ImgurPlayer.prototype.load = function(data) { + data.meta.embed = { + tag: 'iframe', + src: "https://imgur.com/a/" + data.id + "/embed" + }; + return ImgurPlayer.__super__.load.call(this, data); + }; + + return ImgurPlayer; + + })(CustomEmbedPlayer); + TYPE_MAP = { yt: YouTubePlayer, vi: VimeoPlayer, @@ -932,7 +976,9 @@ tw: TwitchPlayer, cu: CustomEmbedPlayer, rt: RTMPPlayer, - hb: HitboxPlayer + hb: HitboxPlayer, + us: UstreamPlayer, + im: ImgurPlayer }; window.loadMediaPlayer = function(data) {