function ReactPlayer() {
var _ref;
var _temp, _this, _ret;
_classCallCheck(this, ReactPlayer);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = ReactPlayer.__proto__ || Object.getPrototypeOf(ReactPlayer
)).call.apply(_ref, [this].concat(args))), _this), _this.seekTo = function (fraction) {
if (_this.player) {
_this.player.seekTo(fraction);
}
}, _this.getDuration = function () {
if (!_this.player) return null;
return _this.player.getDuration();
}, _this.getCurrentTime = function () {
if (!_this.player) return null;
var duration = _this.player.getDuration();
var fractionPlayed = _this.player.getFractionPlayed();
if (duration === null || fractionPlayed === null) {
return null;
}
return fractionPlayed * duration;
}, _this.progress = function () {
if (_this.props.url && _this.player) {
var loaded = _this.player.getFractionLoaded() || 0;
var played = _this.player.getFractionPlayed() || 0;
var duration = _this.player.getDuration();
var progress = {};
if (loaded !== _this.prevLoaded) {
progress.loaded = loaded;
if (duration) {
progress.loadedSeconds = progress.loaded * duration;
}
}
if (played !== _this.prevPlayed) {
progress.played = played;
if (duration) {
progress.playedSeconds = progress.played * duration;
}
}
if (progress.loaded || progress.played) {
_this.props.onProgress(progress);
}
_this.prevLoaded = loaded;
_this.prevPlayed = played;
}
_this.progressTimeout = setTimeout(_this.progress, _this.props.progressFrequency);
}, _this.ref = function (player) {
_this.player = player;
}, _this.renderPlayer = function (Player) {
var active = Player.canPlay(_this.props.url);
var _this$props = _this.props,
youtubeConfig = _this$props.youtubeConfig,
soundcloudConfig = _this$props.soundcloudConfig,
vimeoConfig = _this$props.vimeoConfig,
vidmeConfig = _this$props.vidmeConfig,
fileConfig = _this$props.fileConfig,
activeProps = _objectWithoutProperties(_this$props, ['youtubeConfig', 'soundcloudConfig', 'vimeoConfig', 'vidmeConfig', '
fileConfig']);
var props = active ? _extends({}, activeProps, { ref: _this.ref }) : {};
return _react2['default'].createElement(Player, _extends({
key: Player.displayName,
youtubeConfig: youtubeConfig,
soundcloudConfig: soundcloudConfig,
vimeoConfig: vimeoConfig,
vidmeConfig: vidmeConfig,
fileConfig: fileConfig
}, props));
}, _temp), _possibleConstructorReturn(_this, _ret);
}n/a
propTypes.fileConfig = function () { [native code] }n/a
propTypes.height = function () { [native code] }n/a
propTypes.onReady = function () { [native code] }n/a
propTypes.playing = function () { [native code] }n/a
propTypes.soundcloudConfig = function () { [native code] }n/a
propTypes.style = function () { [native code] }n/a
propTypes.url = function () { [native code] }n/a
propTypes.vidmeConfig = function () { [native code] }n/a
propTypes.vimeoConfig = function () { [native code] }n/a
propTypes.volume = function () { [native code] }n/a
propTypes.width = function () { [native code] }n/a
propTypes.youtubeConfig = function () { [native code] }n/a
function onBuffer() {}n/a
function onDuration() {}n/a
function onEnded() {}...
_this.postMessage('addEventListener', 'pause');
_this.postMessage('addEventListener', 'finish');
}
if (data.event === 'playProgress') _this.fractionPlayed = data.data.percent;
if (data.event === 'loadProgress') _this.fractionLoaded = data.data.percent;
if (data.event === 'play') _this.onPlay();
if (data.event === 'pause') _this.props.onPause();
if (data.event === 'finish') _this.onEnded();
if (data.method === 'getDuration') {
_this.duration = data.value; // Store for use later
_this.onReady();
}
}, _this.onEnded = function () {
var _this$props = _this.props,
loop = _this$props.loop,
...function onError() {}...
return Promise.resolve(songData[url]);
}
return (0, _fetchJsonp2['default'])(RESOLVE_URL + '?url=' + url + '&client_id=' + this.clientId
).then(function (response) {
if (response.ok) {
songData[url] = response.json();
return songData[url];
} else {
_this2.props.onError(new Error('SoundCloud track could not be resolved
x27;));
}
});
}
}, {
key: 'load',
value: function load(url) {
var _this3 = this;
...function onPause() {}...
_this.postMessage('addEventListener', 'play');
_this.postMessage('addEventListener', 'pause');
_this.postMessage('addEventListener', 'finish');
}
if (data.event === 'playProgress') _this.fractionPlayed = data.data.percent;
if (data.event === 'loadProgress') _this.fractionLoaded = data.data.percent;
if (data.event === 'play') _this.onPlay();
if (data.event === 'pause') _this.props.onPause();
if (data.event === 'finish') _this.onEnded();
if (data.method === 'getDuration') {
_this.duration = data.value; // Store for use later
_this.onReady();
}
}, _this.onEnded = function () {
var _this$props = _this.props,
...function onPlay() {}...
_this.postMessage('addEventListener', 'loadProgress');
_this.postMessage('addEventListener', 'play');
_this.postMessage('addEventListener', 'pause');
_this.postMessage('addEventListener', 'finish');
}
if (data.event === 'playProgress') _this.fractionPlayed = data.data.percent;
if (data.event === 'loadProgress') _this.fractionLoaded = data.data.percent;
if (data.event === 'play') _this.onPlay();
if (data.event === 'pause') _this.props.onPause();
if (data.event === 'finish') _this.onEnded();
if (data.method === 'getDuration') {
_this.duration = data.value; // Store for use later
_this.onReady();
}
}, _this.onEnded = function () {
...function onProgress() {}n/a
function onReady() {}...
if (data.event === 'playProgress') _this.fractionPlayed = data.data.percent;
if (data.event === 'loadProgress') _this.fractionLoaded = data.data.percent;
if (data.event === 'play') _this.onPlay();
if (data.event === 'pause') _this.props.onPause();
if (data.event === 'finish') _this.onEnded();
if (data.method === 'getDuration') {
_this.duration = data.value; // Store for use later
_this.onReady();
}
}, _this.onEnded = function () {
var _this$props = _this.props,
loop = _this$props.loop,
onEnded = _this$props.onEnded;
if (loop) {
...function onStart() {}n/a
className = function () { [native code] }n/a
controls = function () { [native code] }n/a
fileConfig = function () { [native code] }n/a
height = function () { [native code] }n/a
hidden = function () { [native code] }n/a
loop = function () { [native code] }n/a
onBuffer = function () { [native code] }n/a
onDuration = function () { [native code] }n/a
onEnded = function () { [native code] }...
_this.postMessage('addEventListener', 'pause');
_this.postMessage('addEventListener', 'finish');
}
if (data.event === 'playProgress') _this.fractionPlayed = data.data.percent;
if (data.event === 'loadProgress') _this.fractionLoaded = data.data.percent;
if (data.event === 'play') _this.onPlay();
if (data.event === 'pause') _this.props.onPause();
if (data.event === 'finish') _this.onEnded();
if (data.method === 'getDuration') {
_this.duration = data.value; // Store for use later
_this.onReady();
}
}, _this.onEnded = function () {
var _this$props = _this.props,
loop = _this$props.loop,
...onError = function () { [native code] }...
return Promise.resolve(songData[url]);
}
return (0, _fetchJsonp2['default'])(RESOLVE_URL + '?url=' + url + '&client_id=' + this.clientId
).then(function (response) {
if (response.ok) {
songData[url] = response.json();
return songData[url];
} else {
_this2.props.onError(new Error('SoundCloud track could not be resolved
x27;));
}
});
}
}, {
key: 'load',
value: function load(url) {
var _this3 = this;
...onPause = function () { [native code] }...
_this.postMessage('addEventListener', 'play');
_this.postMessage('addEventListener', 'pause');
_this.postMessage('addEventListener', 'finish');
}
if (data.event === 'playProgress') _this.fractionPlayed = data.data.percent;
if (data.event === 'loadProgress') _this.fractionLoaded = data.data.percent;
if (data.event === 'play') _this.onPlay();
if (data.event === 'pause') _this.props.onPause();
if (data.event === 'finish') _this.onEnded();
if (data.method === 'getDuration') {
_this.duration = data.value; // Store for use later
_this.onReady();
}
}, _this.onEnded = function () {
var _this$props = _this.props,
...onPlay = function () { [native code] }...
_this.postMessage('addEventListener', 'loadProgress');
_this.postMessage('addEventListener', 'play');
_this.postMessage('addEventListener', 'pause');
_this.postMessage('addEventListener', 'finish');
}
if (data.event === 'playProgress') _this.fractionPlayed = data.data.percent;
if (data.event === 'loadProgress') _this.fractionLoaded = data.data.percent;
if (data.event === 'play') _this.onPlay();
if (data.event === 'pause') _this.props.onPause();
if (data.event === 'finish') _this.onEnded();
if (data.method === 'getDuration') {
_this.duration = data.value; // Store for use later
_this.onReady();
}
}, _this.onEnded = function () {
...onProgress = function () { [native code] }n/a
onReady = function () { [native code] }...
if (data.event === 'playProgress') _this.fractionPlayed = data.data.percent;
if (data.event === 'loadProgress') _this.fractionLoaded = data.data.percent;
if (data.event === 'play') _this.onPlay();
if (data.event === 'pause') _this.props.onPause();
if (data.event === 'finish') _this.onEnded();
if (data.method === 'getDuration') {
_this.duration = data.value; // Store for use later
_this.onReady();
}
}, _this.onEnded = function () {
var _this$props = _this.props,
loop = _this$props.loop,
onEnded = _this$props.onEnded;
if (loop) {
...onStart = function () { [native code] }n/a
playbackRate = function () { [native code] }...
if (!this.isReady || !this.player || !this.player.volume) return;
this.player.volume(fraction);
}
}, {
key: 'setPlaybackRate',
value: function setPlaybackRate(rate) {
if (!this.isReady || !this.player || !this.player.playbackRate) return;
this.player.playbackRate(rate);
}
}, {
key: 'getDuration',
value: function getDuration() {
if (!this.isReady || !this.player || !this.player.duration) return;
return this.player.duration();
}
...playing = function () { [native code] }n/a
playsinline = function () { [native code] }n/a
progressFrequency = function () { [native code] }n/a
soundcloudConfig = function () { [native code] }n/a
style = function () { [native code] }n/a
url = function () { [native code] }n/a
vidmeConfig = function () { [native code] }n/a
vimeoConfig = function () { [native code] }n/a
volume = function () { [native code] }...
if (!this.isReady || !this.player) return;
this.player.time(this.getDuration() * fraction);
}
}, {
key: 'setVolume',
value: function setVolume(fraction) {
if (!this.isReady || !this.player || !this.player.volume) return;
this.player.volume(fraction);
}
}, {
key: 'setPlaybackRate',
value: function setPlaybackRate(rate) {
if (!this.isReady || !this.player || !this.player.playbackRate) return;
this.player.playbackRate(rate);
}
...width = function () { [native code] }n/a
youtubeConfig = function () { [native code] }n/a
fileConfig = function () { [native code] }n/a
isRequired = function () { [native code] }n/a
height = function () { [native code] }n/a
isRequired = function () { [native code] }n/a
onReady = function () { [native code] }...
if (data.event === 'playProgress') _this.fractionPlayed = data.data.percent;
if (data.event === 'loadProgress') _this.fractionLoaded = data.data.percent;
if (data.event === 'play') _this.onPlay();
if (data.event === 'pause') _this.props.onPause();
if (data.event === 'finish') _this.onEnded();
if (data.method === 'getDuration') {
_this.duration = data.value; // Store for use later
_this.onReady();
}
}, _this.onEnded = function () {
var _this$props = _this.props,
loop = _this$props.loop,
onEnded = _this$props.onEnded;
if (loop) {
...isRequired = function () { [native code] }n/a
playing = function () { [native code] }n/a
isRequired = function () { [native code] }n/a
soundcloudConfig = function () { [native code] }n/a
isRequired = function () { [native code] }n/a
style = function () { [native code] }n/a
isRequired = function () { [native code] }n/a
url = function () { [native code] }n/a
isRequired = function () { [native code] }n/a
vidmeConfig = function () { [native code] }n/a
isRequired = function () { [native code] }n/a
vimeoConfig = function () { [native code] }n/a
isRequired = function () { [native code] }n/a
volume = function () { [native code] }...
if (!this.isReady || !this.player) return;
this.player.time(this.getDuration() * fraction);
}
}, {
key: 'setVolume',
value: function setVolume(fraction) {
if (!this.isReady || !this.player || !this.player.volume) return;
this.player.volume(fraction);
}
}, {
key: 'setPlaybackRate',
value: function setPlaybackRate(rate) {
if (!this.isReady || !this.player || !this.player.playbackRate) return;
this.player.playbackRate(rate);
}
...isRequired = function () { [native code] }n/a
width = function () { [native code] }n/a
isRequired = function () { [native code] }n/a
youtubeConfig = function () { [native code] }n/a
isRequired = function () { [native code] }n/a
function parseStartTime(url) {
var match = url.match(MATCH_START_QUERY);
if (match) {
var stamp = match[1];
if (stamp.match(MATCH_START_STAMP)) {
return parseStartStamp(stamp);
}
if (MATCH_NUMERIC.test(stamp)) {
return parseInt(stamp, 10);
}
}
return 0;
}n/a