Add RTMP player
This commit is contained in:
parent
01fbd3c54e
commit
b279a41122
26
player/rtmp.coffee
Normal file
26
player/rtmp.coffee
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
window.rtmpEventHandler = (id, event, data) ->
|
||||||
|
if event == 'volumechange'
|
||||||
|
PLAYER.volume = if data.muted then 0 else data.volume
|
||||||
|
|
||||||
|
window.RTMPPlayer = class RTMPPlayer extends CustomEmbedPlayer
|
||||||
|
constructor: (data) ->
|
||||||
|
if not (this instanceof RTMPPlayer)
|
||||||
|
return new RTMPPlayer(data)
|
||||||
|
|
||||||
|
@volume = VOLUME
|
||||||
|
@load(data)
|
||||||
|
|
||||||
|
load: (data) ->
|
||||||
|
data.meta.embed =
|
||||||
|
tag: 'object'
|
||||||
|
src: 'https://fpdownload.adobe.com/strobe/FlashMediaPlayback_101.swf'
|
||||||
|
params:
|
||||||
|
flashvars: "src=#{data.id}&\
|
||||||
|
streamType=live&\
|
||||||
|
javascriptCallbackFunction=rtmpEventHandler&\
|
||||||
|
autoPlay=true&\
|
||||||
|
volume=#{VOLUME}"
|
||||||
|
super(data)
|
||||||
|
|
||||||
|
getVolume: (cb) ->
|
||||||
|
cb(@volume)
|
|
@ -8,6 +8,7 @@ TYPE_MAP =
|
||||||
li: LivestreamPlayer
|
li: LivestreamPlayer
|
||||||
tw: TwitchPlayer
|
tw: TwitchPlayer
|
||||||
cu: CustomEmbedPlayer
|
cu: CustomEmbedPlayer
|
||||||
|
rt: RTMPPlayer
|
||||||
|
|
||||||
window.loadMediaPlayer = (data) ->
|
window.loadMediaPlayer = (data) ->
|
||||||
if data.type of TYPE_MAP
|
if data.type of TYPE_MAP
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
(function() {
|
(function() {
|
||||||
var CustomEmbedPlayer, DailymotionPlayer, LivestreamPlayer, Player, SoundCloudPlayer, TYPE_MAP, TwitchPlayer, VideoJSPlayer, VimeoPlayer, YouTubePlayer, genParam, sortSources,
|
var CustomEmbedPlayer, DailymotionPlayer, LivestreamPlayer, Player, RTMPPlayer, SoundCloudPlayer, TYPE_MAP, TwitchPlayer, 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; },
|
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;
|
hasProp = {}.hasOwnProperty;
|
||||||
|
|
||||||
|
@ -847,6 +847,42 @@
|
||||||
|
|
||||||
})(Player);
|
})(Player);
|
||||||
|
|
||||||
|
window.rtmpEventHandler = function(id, event, data) {
|
||||||
|
if (event === 'volumechange') {
|
||||||
|
return PLAYER.volume = data.muted ? 0 : data.volume;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
window.RTMPPlayer = RTMPPlayer = (function(superClass) {
|
||||||
|
extend(RTMPPlayer, superClass);
|
||||||
|
|
||||||
|
function RTMPPlayer(data) {
|
||||||
|
if (!(this instanceof RTMPPlayer)) {
|
||||||
|
return new RTMPPlayer(data);
|
||||||
|
}
|
||||||
|
this.volume = VOLUME;
|
||||||
|
this.load(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
RTMPPlayer.prototype.load = function(data) {
|
||||||
|
data.meta.embed = {
|
||||||
|
tag: 'object',
|
||||||
|
src: 'https://fpdownload.adobe.com/strobe/FlashMediaPlayback_101.swf',
|
||||||
|
params: {
|
||||||
|
flashvars: "src=" + data.id + "&streamType=live&javascriptCallbackFunction=rtmpEventHandler&autoPlay=true&volume=" + VOLUME
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return RTMPPlayer.__super__.load.call(this, data);
|
||||||
|
};
|
||||||
|
|
||||||
|
RTMPPlayer.prototype.getVolume = function(cb) {
|
||||||
|
return cb(this.volume);
|
||||||
|
};
|
||||||
|
|
||||||
|
return RTMPPlayer;
|
||||||
|
|
||||||
|
})(CustomEmbedPlayer);
|
||||||
|
|
||||||
TYPE_MAP = {
|
TYPE_MAP = {
|
||||||
yt: YouTubePlayer,
|
yt: YouTubePlayer,
|
||||||
vi: VimeoPlayer,
|
vi: VimeoPlayer,
|
||||||
|
@ -856,7 +892,8 @@
|
||||||
sc: SoundCloudPlayer,
|
sc: SoundCloudPlayer,
|
||||||
li: LivestreamPlayer,
|
li: LivestreamPlayer,
|
||||||
tw: TwitchPlayer,
|
tw: TwitchPlayer,
|
||||||
cu: CustomEmbedPlayer
|
cu: CustomEmbedPlayer,
|
||||||
|
rt: RTMPPlayer
|
||||||
};
|
};
|
||||||
|
|
||||||
window.loadMediaPlayer = function(data) {
|
window.loadMediaPlayer = function(data) {
|
||||||
|
|
Loading…
Reference in a new issue