Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@faintlines/video-player

Package Overview
Dependencies
Maintainers
0
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@faintlines/video-player - npm Package Compare versions

Comparing version 2.5.8 to 2.6.0

dist/FilePlayer.js

38

dist/_virtual/_rollupPluginBabelHelpers.js

@@ -47,2 +47,9 @@ function _arrayLikeToArray(r, a) {

}
function _construct(t, e, r) {
if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
var o = [null];
o.push.apply(o, e);
var p = new (t.bind.apply(t, o))();
return r && _setPrototypeOf(p, r.prototype), p;
}
function _defineProperties(e, r) {

@@ -150,2 +157,9 @@ for (var t = 0; t < r.length; t++) {

}
function _isNativeFunction(t) {
try {
return -1 !== Function.toString.call(t).indexOf("[native code]");
} catch (n) {
return "function" == typeof t;
}
}
function _isNativeReflectConstruct() {

@@ -587,4 +601,26 @@ try {

}
function _wrapNativeSuper(t) {
var r = "function" == typeof Map ? new Map() : void 0;
return _wrapNativeSuper = function (t) {
if (null === t || !_isNativeFunction(t)) return t;
if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function");
if (void 0 !== r) {
if (r.has(t)) return r.get(t);
r.set(t, Wrapper);
}
function Wrapper() {
return _construct(t, arguments, _getPrototypeOf(this).constructor);
}
return Wrapper.prototype = Object.create(t.prototype, {
constructor: {
value: Wrapper,
enumerable: !1,
writable: !0,
configurable: !0
}
}), _setPrototypeOf(Wrapper, t);
}, _wrapNativeSuper(t);
}
export { _arrayLikeToArray as arrayLikeToArray, _arrayWithHoles as arrayWithHoles, _arrayWithoutHoles as arrayWithoutHoles, _assertThisInitialized as assertThisInitialized, _asyncToGenerator as asyncToGenerator, _callSuper as callSuper, _classCallCheck as classCallCheck, _createClass as createClass, _createForOfIteratorHelper as createForOfIteratorHelper, _defineProperty as defineProperty, _extends as extends, _get as get, _getPrototypeOf as getPrototypeOf, _inherits as inherits, _isNativeReflectConstruct as isNativeReflectConstruct, _iterableToArray as iterableToArray, _iterableToArrayLimit as iterableToArrayLimit, _nonIterableRest as nonIterableRest, _nonIterableSpread as nonIterableSpread, _objectSpread2 as objectSpread2, _objectWithoutProperties as objectWithoutProperties, _objectWithoutPropertiesLoose as objectWithoutPropertiesLoose, _possibleConstructorReturn as possibleConstructorReturn, _regeneratorRuntime as regeneratorRuntime, _setPrototypeOf as setPrototypeOf, _slicedToArray as slicedToArray, _superPropBase as superPropBase, _toConsumableArray as toConsumableArray, _toPrimitive as toPrimitive, _toPropertyKey as toPropertyKey, _typeof as typeof, _unsupportedIterableToArray as unsupportedIterableToArray };
export { _arrayLikeToArray as arrayLikeToArray, _arrayWithHoles as arrayWithHoles, _arrayWithoutHoles as arrayWithoutHoles, _assertThisInitialized as assertThisInitialized, _asyncToGenerator as asyncToGenerator, _callSuper as callSuper, _classCallCheck as classCallCheck, _construct as construct, _createClass as createClass, _createForOfIteratorHelper as createForOfIteratorHelper, _defineProperty as defineProperty, _extends as extends, _get as get, _getPrototypeOf as getPrototypeOf, _inherits as inherits, _isNativeFunction as isNativeFunction, _isNativeReflectConstruct as isNativeReflectConstruct, _iterableToArray as iterableToArray, _iterableToArrayLimit as iterableToArrayLimit, _nonIterableRest as nonIterableRest, _nonIterableSpread as nonIterableSpread, _objectSpread2 as objectSpread2, _objectWithoutProperties as objectWithoutProperties, _objectWithoutPropertiesLoose as objectWithoutPropertiesLoose, _possibleConstructorReturn as possibleConstructorReturn, _regeneratorRuntime as regeneratorRuntime, _setPrototypeOf as setPrototypeOf, _slicedToArray as slicedToArray, _superPropBase as superPropBase, _toConsumableArray as toConsumableArray, _toPrimitive as toPrimitive, _toPropertyKey as toPropertyKey, _typeof as typeof, _unsupportedIterableToArray as unsupportedIterableToArray, _wrapNativeSuper as wrapNativeSuper };
//# sourceMappingURL=_rollupPluginBabelHelpers.js.map

1

dist/index.js

@@ -6,5 +6,4 @@ import VideoPlayer from './VideoPlayer.js';

export { HlsErrorType, classifyHlsError } from './utils/hlsErrorClassifier.js';
export { HLS_JS_VERSION } from './videoPlayerConfig.js';
export { default as SubtitlesPlayer } from './SubtitlesPlayer.js';
export { isValidSubtitlesUrl } from './subtitlesUtils.js';
//# sourceMappingURL=index.js.map
import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, extends as _extends, objectSpread2 as _objectSpread2, toConsumableArray as _toConsumableArray } from './_virtual/_rollupPluginBabelHelpers.js';
import styles from './VideoPlayer.module.css.js';
import FilePlayer from './FilePlayer.js';
import SubtitlesPlayer from './SubtitlesPlayer.js';
import MediaChromeControls from './MediaChromeControls.js';
import { SUPPORTS_HLS, SUPPORTS_DASH } from './videoUtils.js';
import { HLS_JS_VERSION, HLS_OPTIONS } from './videoPlayerConfig.js';
import { SUPPORTS_HLS } from './videoUtils.js';
import { HLS_OPTIONS } from './videoPlayerConfig.js';
import { classifyHlsError, HlsErrorType } from './utils/hlsErrorClassifier.js';
import React, { forwardRef, useState, useRef, useImperativeHandle, useEffect, useCallback, useMemo, useContext } from 'react';
import React, { forwardRef, useState, useRef, useImperativeHandle, useEffect, useCallback } from 'react';
import classnames from 'classnames';
import ReactPlayer from './node_modules/.pnpm/react-player@2.16.0_react@18.2.0/node_modules/react-player/file.js';
var _excluded = ["url", "hlsUrl", "dashUrl", "fileUrl", "className", "subtitlesClassName", "subtitlesBottomPercent", "progressInterval", "playsInline", "startAt", "autoPlay", "preload", "poster", "loopRange", "autoRetry", "hlsOptions", "controls", "enableSubtitles", "onPlay", "onPause", "onProgress", "onLoadedMetadata", "onError", "onRetryAttempt", "onBuffer", "onBufferEnd", "onToggleSubtitles"],
_excluded2 = ["children"],
_excluded3 = ["playerRef"];
var WrapperPropsContext = /*#__PURE__*/React.createContext();
var _excluded = ["url", "hlsUrl", "fileUrl", "className", "subtitlesClassName", "subtitlesBottomPercent", "progressInterval", "playsInline", "startAt", "autoPlay", "preload", "poster", "loopRange", "autoRetry", "hlsOptions", "controls", "width", "height", "style", "enableSubtitles", "onPlay", "onPause", "onProgress", "onLoadedMetadata", "onError", "onRetryAttempt", "onBuffer", "onBufferEnd", "onToggleSubtitles"],
_excluded2 = ["playerRef"];

@@ -24,8 +22,7 @@ // A session-persistent list of unplayable HLS files, sharable by all VideoPlayer instances.

hlsUrl = _ref.hlsUrl,
dashUrl = _ref.dashUrl,
fileUrl = _ref.fileUrl,
className = _ref.className,
subtitlesClassName = _ref.subtitlesClassName,
subtitlesBottomPercent = _ref.subtitlesBottomPercent,
_ref$progressInterval = _ref.progressInterval,
subtitlesClassName = _ref.subtitlesClassName;
_ref.subtitlesBottomPercent;
var _ref$progressInterval = _ref.progressInterval,
progressInterval = _ref$progressInterval === void 0 ? 500 : _ref$progressInterval,

@@ -44,2 +41,7 @@ _ref$playsInline = _ref.playsInline,

controls = _ref.controls,
_ref$width = _ref.width,
width = _ref$width === void 0 ? "640px" : _ref$width,
_ref$height = _ref.height,
height = _ref$height === void 0 ? "360px" : _ref$height,
style = _ref.style,
_ref$enableSubtitles = _ref.enableSubtitles,

@@ -76,3 +78,2 @@ enableSubtitles = _ref$enableSubtitles === void 0 ? false : _ref$enableSubtitles,

hlsUrl: (urlObj === null || urlObj === void 0 ? void 0 : urlObj.hls) || hlsUrl,
dashUrl: (urlObj === null || urlObj === void 0 ? void 0 : urlObj.dash) || dashUrl,
fileUrl: (urlObj === null || urlObj === void 0 ? void 0 : urlObj.file) || fileUrl

@@ -84,17 +85,13 @@ }),

useImperativeHandle(ref, function () {
var _playerRef$current, _playerRef$current$ge, _playerRef$current2, _playerRef$current2$g;
return {
paused: playerRef === null || playerRef === void 0 ? void 0 : (_playerRef$current = playerRef.current) === null || _playerRef$current === void 0 ? void 0 : (_playerRef$current$ge = _playerRef$current.getInternalPlayer()) === null || _playerRef$current$ge === void 0 ? void 0 : _playerRef$current$ge.paused,
duration: playerRef === null || playerRef === void 0 ? void 0 : (_playerRef$current2 = playerRef.current) === null || _playerRef$current2 === void 0 ? void 0 : (_playerRef$current2$g = _playerRef$current2.getInternalPlayer()) === null || _playerRef$current2$g === void 0 ? void 0 : _playerRef$current2$g.duration,
paused: false,
duration: null,
play: function play() {
setPlaying(true);
return tryPlaying(playerRef);
return setPlaying(true);
},
pause: function pause() {
var _playerRef$current3, _playerRef$current3$g;
setPlaying(false);
return playerRef === null || playerRef === void 0 ? void 0 : (_playerRef$current3 = playerRef.current) === null || _playerRef$current3 === void 0 ? void 0 : (_playerRef$current3$g = _playerRef$current3.getInternalPlayer()) === null || _playerRef$current3$g === void 0 ? void 0 : _playerRef$current3$g.pause();
return setPlaying(false);
},
seekTo: function seekTo(time) {
_seekTo(playerRef, time);
seekTo: function seekTo(seconds) {
return playerRef.current.seekTo(seconds);
}

@@ -111,4 +108,3 @@ };

if (loopRangeRef.current) {
var _playerRef$current4;
applyLoopRange(loopRangeRef.current, progress.playedSeconds, playerRef === null || playerRef === void 0 ? void 0 : (_playerRef$current4 = playerRef.current) === null || _playerRef$current4 === void 0 ? void 0 : _playerRef$current4.getInternalPlayer(),
applyLoopRange(loopRangeRef.current, progress.playedSeconds, playerRef,
// when applying loop range, skip buffering events for a short while

@@ -125,8 +121,8 @@ function () {

if (ref && ref.current) {
var _playerRef$current5;
var player = playerRef === null || playerRef === void 0 ? void 0 : (_playerRef$current5 = playerRef.current) === null || _playerRef$current5 === void 0 ? void 0 : _playerRef$current5.getInternalPlayer();
ref.current.duration = player === null || player === void 0 ? void 0 : player.duration;
var _playerRef$current;
ref.current.duration = (_playerRef$current = playerRef.current) === null || _playerRef$current === void 0 ? void 0 : _playerRef$current.getDuration();
}
if (startAt && !startAtSetRef.current) {
_seekTo(playerRef, startAt);
var _playerRef$current2;
(_playerRef$current2 = playerRef.current) === null || _playerRef$current2 === void 0 ? void 0 : _playerRef$current2.seekTo(startAt);
startAtSetRef.current = true;

@@ -160,41 +156,36 @@ }

}, [selectedUrl, onError, onRetryAttempt, autoRetry]);
var providerProps = useMemo(function () {
return {
className: className,
subtitlesClassName: subtitlesClassName,
subtitlesUrl: subtitlesUrl,
playerRef: playerRef,
subtitlesBottomPercent: subtitlesBottomPercent,
controls: controls,
onToggleSubtitles: onToggleSubtitles,
enableSubtitles: enableSubtitles
};
}, [className, subtitlesClassName, subtitlesUrl, playerRef, subtitlesBottomPercent, controls, onToggleSubtitles, enableSubtitles]);
return /*#__PURE__*/React.createElement(WrapperPropsContext.Provider, {
value: providerProps
}, /*#__PURE__*/React.createElement(ReactPlayer, _extends({
return /*#__PURE__*/React.createElement(Wrapper, {
className: className,
subtitlesClassName: subtitlesClassName,
subtitlesUrl: subtitlesUrl,
controls: controls,
onToggleSubtitles: onToggleSubtitles,
enableSubtitles: enableSubtitles,
playerRef: playerRef,
width: width,
height: height,
style: style
}, /*#__PURE__*/React.createElement(FilePlayer, _extends({
ref: playerRef,
key: retryAttempt,
url: selectedUrl,
wrapper: Wrapper,
playing: playing,
config: {
file: {
hlsVersion: HLS_JS_VERSION,
hlsOptions: _objectSpread2(_objectSpread2({}, HLS_OPTIONS), hlsOptions || {}),
// we force the use of hls.js to make sure it is the one handling the stream
// and not the default one, as for example happends in IOS
forceHLS: selectedUrlType === "hls",
dashVersion: "4.0.0-npm",
attributes: _objectSpread2({
autoPlay: autoPlay,
preload: preload,
poster: poster,
slot: "media",
disablePictureInPicture: true
}, getRemotePlaybackAttribute())
}
hlsOptions: _objectSpread2(_objectSpread2({}, HLS_OPTIONS), hlsOptions || {}),
// we force the use of hls.js to make sure it is the one handling the stream
// and not the default one, as for example happends in IOS
forceHLS: selectedUrlType === "hls",
attributes: _objectSpread2({
autoPlay: autoPlay,
preload: preload,
poster: poster,
slot: "media",
disablePictureInPicture: true
}, getRemotePlaybackAttribute())
},
playsinline: playsInline,
progressInterval: progressInterval,
width: width,
height: height,
style: style,
onPlay: playHandler,

@@ -212,18 +203,22 @@ onPause: pauseHandler,

VideoPlayer.displayName = "VideoPlayer";
var Wrapper = /*#__PURE__*/forwardRef(function (_ref2, ref) {
var children = _ref2.children,
props = _objectWithoutProperties(_ref2, _excluded2);
var _ref3 = useContext(WrapperPropsContext) || {},
className = _ref3.className,
subtitlesClassName = _ref3.subtitlesClassName,
subtitlesBottomPercent = _ref3.subtitlesBottomPercent,
subtitlesUrl = _ref3.subtitlesUrl,
playerRef = _ref3.playerRef,
controls = _ref3.controls,
onToggleSubtitles = _ref3.onToggleSubtitles,
enableSubtitles = _ref3.enableSubtitles;
return /*#__PURE__*/React.createElement("div", _extends({
ref: ref,
className: classnames(className, styles.wrapper)
}, props), controls ? /*#__PURE__*/React.createElement(MediaChromeControls, {
function Wrapper(_ref2) {
var className = _ref2.className,
subtitlesClassName = _ref2.subtitlesClassName,
subtitlesBottomPercent = _ref2.subtitlesBottomPercent,
subtitlesUrl = _ref2.subtitlesUrl,
controls = _ref2.controls,
onToggleSubtitles = _ref2.onToggleSubtitles,
enableSubtitles = _ref2.enableSubtitles,
playerRef = _ref2.playerRef,
width = _ref2.width,
height = _ref2.height,
style = _ref2.style,
children = _ref2.children;
return /*#__PURE__*/React.createElement("div", {
className: classnames(className, styles.wrapper),
style: _objectSpread2(_objectSpread2({}, style), {}, {
width: width,
height: height
})
}, controls ? /*#__PURE__*/React.createElement(MediaChromeControls, {
subtitlesEnabled: enableSubtitles,

@@ -238,3 +233,3 @@ subtitlesUrl: subtitlesUrl,

}) : null);
});
}
function ensureUrlObject(url) {

@@ -245,8 +240,8 @@ return typeof url === "string" ? {

}
var VideoSubtitlesPlayer = function VideoSubtitlesPlayer(_ref4) {
var playerRef = _ref4.playerRef,
props = _objectWithoutProperties(_ref4, _excluded3);
var VideoSubtitlesPlayer = function VideoSubtitlesPlayer(_ref3) {
var playerRef = _ref3.playerRef,
props = _objectWithoutProperties(_ref3, _excluded2);
var getCurrentTime = useCallback(function () {
var _playerRef$current6, _playerRef$current6$g;
return playerRef === null || playerRef === void 0 ? void 0 : (_playerRef$current6 = playerRef.current) === null || _playerRef$current6 === void 0 ? void 0 : (_playerRef$current6$g = _playerRef$current6.getInternalPlayer()) === null || _playerRef$current6$g === void 0 ? void 0 : _playerRef$current6$g.currentTime;
var _playerRef$current3;
return (_playerRef$current3 = playerRef.current) === null || _playerRef$current3 === void 0 ? void 0 : _playerRef$current3.getCurrentTime();
}, [playerRef]);

@@ -276,3 +271,3 @@ return /*#__PURE__*/React.createElement(SubtitlesPlayer, _extends({

setTimeout(function () {
return tryPlaying(playerRef);
return playerRef.current.play();
}, 3000);

@@ -324,29 +319,8 @@ return;

}
function tryPlaying(playerRef) {
var _playerRef$current7, _playerRef$current7$g;
var promise = playerRef === null || playerRef === void 0 ? void 0 : (_playerRef$current7 = playerRef.current) === null || _playerRef$current7 === void 0 ? void 0 : (_playerRef$current7$g = _playerRef$current7.getInternalPlayer()) === null || _playerRef$current7$g === void 0 ? void 0 : _playerRef$current7$g.play();
if (promise) {
promise["catch"](NOOP);
}
return promise;
}
function _seekTo(playerRef, time) {
var _playerRef$current8;
var player = playerRef === null || playerRef === void 0 ? void 0 : (_playerRef$current8 = playerRef.current) === null || _playerRef$current8 === void 0 ? void 0 : _playerRef$current8.getInternalPlayer();
if (player) {
player.currentTime = time;
}
// TODO: the following doesn't work. figure out why
// playerRef?.current?.seekTo(time, "seconds");
}
function selectVideoUrl(_ref5) {
var hlsUrl = _ref5.hlsUrl,
dashUrl = _ref5.dashUrl,
fileUrl = _ref5.fileUrl;
function selectVideoUrl(_ref4) {
var hlsUrl = _ref4.hlsUrl,
fileUrl = _ref4.fileUrl;
if (hlsUrl && SUPPORTS_HLS && !UNPLAYABLE_HLS_URLS[hlsUrl]) {
return [hlsUrl, "hls"];
}
if (dashUrl && SUPPORTS_DASH) {
return [dashUrl, "dash"];
}
return [fileUrl, "file"];

@@ -364,3 +338,3 @@ }

}
function applyLoopRange(range, currentTime, player, callback) {
function applyLoopRange(range, currentTime, playerRef, callback) {
var _range = _slicedToArray(range, 3),

@@ -373,3 +347,3 @@ start = _range[0],

if (currentTime >= end || jumpToStart && currentTime < start) {
player.currentTime = start;
playerRef.current.seekTo(start);
if (callback) {

@@ -380,7 +354,4 @@ callback();

}
function NOOP() {
// nothing
}
export { VideoPlayer as default, ensureUrlObject, handlePlayerError };
//# sourceMappingURL=VideoPlayer.js.map
import { objectSpread2 as _objectSpread2 } from './_virtual/_rollupPluginBabelHelpers.js';
var _navigator$deviceMemo, _navigator;
var HLS_JS_VERSION = "1.5.13";
var ANDROID_VERSION = getAndroidMajorVersion();

@@ -41,3 +40,3 @@ var DEVICE_MEMORY = (_navigator$deviceMemo = (_navigator = navigator) === null || _navigator === void 0 ? void 0 : _navigator.deviceMemory) !== null && _navigator$deviceMemo !== void 0 ? _navigator$deviceMemo : 8; // 8 is maximum

export { HLS_JS_VERSION, HLS_OPTIONS };
export { HLS_OPTIONS };
//# sourceMappingURL=videoPlayerConfig.js.map

@@ -26,5 +26,2 @@ import { typeof as _typeof } from './_virtual/_rollupPluginBabelHelpers.js';

var SUPPORTS_HLS = hasNativeHlsSupport() || hasHlsJsSupport();
// https://github.com/Dash-Industry-Forum/dash.js/issues/2055#issuecomment-313187528
var SUPPORTS_DASH = mediaSource && typeof mediaSource.isTypeSupported === "function";
function filterVideoUrls(urls) {

@@ -41,3 +38,3 @@ return urls.filter(function (url) {

export { SUPPORTS_DASH, SUPPORTS_HLS, filterVideoUrls, isVideoUrl };
export { SUPPORTS_HLS, filterVideoUrls, isVideoUrl };
//# sourceMappingURL=videoUtils.js.map
{
"name": "@faintlines/video-player",
"version": "2.5.8",
"version": "2.6.0",
"description": "",

@@ -16,3 +16,3 @@ "license": "UNLICENSED",

"flush-promises": "^1.0.2",
"react-player": "^2.12.0"
"hls.js": "1.5.13"
},

@@ -23,4 +23,4 @@ "peerDependencies": {

"lodash": "^4.17.21",
"react": "^16.14.0 || ^17 || ^18",
"react-dom": "^16.14.0 || ^17 || ^18"
"react": "^17 || ^18",
"react-dom": "^17 || ^18"
},

@@ -27,0 +27,0 @@ "devDependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc