react-player
Advanced tools
Comparing version 2.0.2-beta.0 to 2.1.0
@@ -23,2 +23,3 @@ import * as React from 'react'; | ||
embedOptions?: Object; | ||
onUnstarted?(): void; | ||
} | ||
@@ -25,0 +26,0 @@ |
@@ -7,3 +7,3 @@ "use strict"; | ||
exports.DASH_EXTENSIONS = exports.HLS_EXTENSIONS = exports.VIDEO_EXTENSIONS = exports.AUDIO_EXTENSIONS = exports.MATCH_URL_VIDYARD = exports.MATCH_URL_MIXCLOUD = exports.MATCH_URL_DAILYMOTION = exports.MATCH_URL_TWITCH_CHANNEL = exports.MATCH_URL_TWITCH_VIDEO = exports.MATCH_URL_WISTIA = exports.MATCH_URL_STREAMABLE = exports.MATCH_URL_FACEBOOK = exports.MATCH_URL_VIMEO = exports.MATCH_URL_SOUNDCLOUD = exports.MATCH_URL_YOUTUBE = void 0; | ||
var MATCH_URL_YOUTUBE = /(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})|youtube\.com\/playlist\?list=/; | ||
var MATCH_URL_YOUTUBE = /(?:youtu\.be\/|youtube(?:-nocookie)?\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})|youtube\.com\/playlist\?list=|youtube\.com\/user\//; | ||
exports.MATCH_URL_YOUTUBE = MATCH_URL_YOUTUBE; | ||
@@ -10,0 +10,0 @@ var MATCH_URL_SOUNDCLOUD = /(?:soundcloud\.com|snd\.sc)\/[^.]+$/; |
@@ -279,2 +279,10 @@ "use strict"; | ||
if (this.hls) { | ||
this.hls.destroy(); | ||
} | ||
if (this.dash) { | ||
this.dash.reset(); | ||
} | ||
if (this.shouldUseHLS(url)) { | ||
@@ -281,0 +289,0 @@ (0, _utils.getSDK)(HLS_SDK_URL.replace('VERSION', hlsVersion), HLS_GLOBAL).then(function (Hls) { |
@@ -112,4 +112,13 @@ "use strict"; | ||
_this2.player.bind(PAUSE, _this2.props.onPause); | ||
_this2.player.bind(PAUSE, function () { | ||
var remaining = _this2.duration - _this2.currentTime; | ||
if (remaining < 0.05) { | ||
// Prevent onPause firing right before onEnded | ||
return; | ||
} | ||
_this2.props.onPause(); | ||
}); | ||
_this2.player.bind(PLAY_PROGRESS, function (e) { | ||
@@ -116,0 +125,0 @@ _this2.currentTime = e.currentPosition / 1000; |
@@ -92,6 +92,7 @@ "use strict"; | ||
key: "load", | ||
value: function load(url, isReady) { | ||
value: function load(url) { | ||
var _this2 = this; | ||
var _this$props = this.props, | ||
playing = _this$props.playing, | ||
config = _this$props.config, | ||
@@ -101,2 +102,7 @@ onError = _this$props.onError, | ||
var id = url && url.match(_patterns.MATCH_URL_VIDYARD)[1]; | ||
if (this.player) { | ||
this.stop(); | ||
} | ||
(0, _utils.getSDK)(SDK_URL, SDK_GLOBAL, SDK_GLOBAL_READY).then(function (Vidyard) { | ||
@@ -119,3 +125,4 @@ if (!_this2.container) return; | ||
uuid: id, | ||
container: _this2.container | ||
container: _this2.container, | ||
autoplay: playing ? 1 : 0 | ||
}, config.options)); | ||
@@ -122,0 +129,0 @@ Vidyard.api.getPlayerMetadata(id).then(function (meta) { |
@@ -62,2 +62,5 @@ "use strict"; | ||
var MATCH_PLAYLIST = /list=([a-zA-Z0-9_-]+)/; | ||
var MATCH_USER_UPLOADS = /user\/([a-zA-Z0-9_-]+)\/?/; | ||
var MATCH_NOCOOKIE = /youtube-nocookie\.com/; | ||
var NOCOOKIE_HOST = 'https://www.youtube-nocookie.com'; | ||
@@ -74,2 +77,11 @@ function parsePlaylist(url) { | ||
}; | ||
} else if (MATCH_USER_UPLOADS.test(url)) { | ||
var _url$match3 = url.match(MATCH_USER_UPLOADS), | ||
_url$match4 = _slicedToArray(_url$match3, 2), | ||
username = _url$match4[1]; | ||
return { | ||
listType: 'user_uploads', | ||
list: username | ||
}; | ||
} | ||
@@ -98,4 +110,4 @@ | ||
_defineProperty(_assertThisInitialized(_this), "onStateChange", function (_ref) { | ||
var data = _ref.data; | ||
_defineProperty(_assertThisInitialized(_this), "onStateChange", function (event) { | ||
var data = event.data; | ||
var _this$props = _this.props, | ||
@@ -108,4 +120,8 @@ onPlay = _this$props.onPlay, | ||
onReady = _this$props.onReady, | ||
loop = _this$props.loop; | ||
loop = _this$props.loop, | ||
_this$props$config = _this$props.config, | ||
playerVars = _this$props$config.playerVars, | ||
onUnstarted = _this$props$config.onUnstarted; | ||
var _window$SDK_GLOBAL$Pl = window[SDK_GLOBAL].PlayerState, | ||
UNSTARTED = _window$SDK_GLOBAL$Pl.UNSTARTED, | ||
PLAYING = _window$SDK_GLOBAL$Pl.PLAYING, | ||
@@ -116,2 +132,3 @@ PAUSED = _window$SDK_GLOBAL$Pl.PAUSED, | ||
CUED = _window$SDK_GLOBAL$Pl.CUED; | ||
if (data === UNSTARTED) onUnstarted(); | ||
@@ -127,7 +144,10 @@ if (data === PLAYING) { | ||
if (data === ENDED) { | ||
var isPlaylist = !!_this.callPlayer('getPlaylist'); | ||
var isPlaylist = !!_this.callPlayer('getPlaylist'); // Only loop manually if not playing a playlist | ||
if (loop && !isPlaylist) { | ||
_this.play(); // Only loop manually if not playing a playlist | ||
if (playerVars.start) { | ||
_this.seekTo(playerVars.start); | ||
} else { | ||
_this.play(); | ||
} | ||
} | ||
@@ -179,3 +199,3 @@ | ||
if (isReady) { | ||
if (MATCH_PLAYLIST.test(url)) { | ||
if (MATCH_PLAYLIST.test(url) || MATCH_USER_UPLOADS.test(url)) { | ||
this.player.loadPlaylist(parsePlaylist(url)); | ||
@@ -223,3 +243,4 @@ return; | ||
} | ||
} | ||
}, | ||
host: MATCH_NOCOOKIE.test(url) ? NOCOOKIE_HOST : undefined | ||
}, embedOptions)); | ||
@@ -226,0 +247,0 @@ }, _onError); |
@@ -66,2 +66,8 @@ "use strict"; | ||
_defineProperty(_assertThisInitialized(_this), "handleKeyPress", function (e) { | ||
if (e.key === 'Enter' || e.key === ' ') { | ||
_this.props.onClick(); | ||
} | ||
}); | ||
return _this; | ||
@@ -168,3 +174,5 @@ } | ||
className: "react-player__preview", | ||
onClick: onClick | ||
onClick: onClick, | ||
tabIndex: 0, | ||
onKeyPress: this.handleKeyPress | ||
}, playIcon || defaultPlayIcon); | ||
@@ -171,0 +179,0 @@ } |
@@ -46,3 +46,4 @@ "use strict"; | ||
playerVars: object, | ||
embedOptions: object | ||
embedOptions: object, | ||
onUnstarted: func | ||
}), | ||
@@ -100,2 +101,5 @@ facebook: shape({ | ||
exports.propTypes = propTypes; | ||
var noop = function noop() {}; | ||
var defaultProps = { | ||
@@ -137,3 +141,4 @@ playing: false, | ||
}, | ||
embedOptions: {} | ||
embedOptions: {}, | ||
onUnstarted: noop | ||
}, | ||
@@ -186,16 +191,16 @@ facebook: { | ||
}, | ||
onReady: function onReady() {}, | ||
onStart: function onStart() {}, | ||
onPlay: function onPlay() {}, | ||
onPause: function onPause() {}, | ||
onBuffer: function onBuffer() {}, | ||
onBufferEnd: function onBufferEnd() {}, | ||
onEnded: function onEnded() {}, | ||
onError: function onError() {}, | ||
onDuration: function onDuration() {}, | ||
onSeek: function onSeek() {}, | ||
onProgress: function onProgress() {}, | ||
onEnablePIP: function onEnablePIP() {}, | ||
onDisablePIP: function onDisablePIP() {} | ||
onReady: noop, | ||
onStart: noop, | ||
onPlay: noop, | ||
onPause: noop, | ||
onBuffer: noop, | ||
onBufferEnd: noop, | ||
onEnded: noop, | ||
onError: noop, | ||
onDuration: noop, | ||
onSeek: noop, | ||
onProgress: noop, | ||
onEnablePIP: noop, | ||
onDisablePIP: noop | ||
}; | ||
exports.defaultProps = defaultProps; |
{ | ||
"name": "react-player", | ||
"version": "2.0.2-beta.0", | ||
"version": "2.1.0", | ||
"description": "A React component for playing a variety of URLs, including file paths, YouTube, Facebook, Twitch, SoundCloud, Streamable, Vimeo, Wistia and DailyMotion", | ||
@@ -5,0 +5,0 @@ "main": "lib/ReactPlayer.js", |
@@ -129,3 +129,3 @@ <h1 align='center'> | ||
--- | ------- | ||
`youtube` | `playerVars`: Override the [default player vars](https://developers.google.com/youtube/player_parameters?playerVersion=HTML5)<br />`embedOptions`: Override the [default embed options](https://developers.google.com/youtube/iframe_api_reference#Loading_a_Video_Player) | ||
`youtube` | `playerVars`: Override the [default player vars](https://developers.google.com/youtube/player_parameters?playerVersion=HTML5)<br />`embedOptions`: Override the [default embed options](https://developers.google.com/youtube/iframe_api_reference#Loading_a_Video_Player)<br />`onUnstarted`: Called when state changes to `unstarted` (usually when video fails to autoplay) | ||
`facebook` | `appId`: Your own [Facebook app ID](https://developers.facebook.com/docs/apps/register#app-id)<br />`version`: Facebook SDK version<br />`playerId`: Override player ID for consistent server-side rendering (use with [`react-uid`](https://github.com/thearnica/react-uid)) | ||
@@ -132,0 +132,0 @@ `soundcloud` | `options`: Override the [default player options](https://developers.soundcloud.com/docs/api/html5-widget#params) |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1175090
4773
0