react-video-renderer
Advanced tools
Comparing version 1.0.1 to 1.1.2
@@ -5,2 +5,3 @@ /// <reference types="react" /> | ||
export declare type VideoStatus = 'loading' | 'playing' | 'paused' | 'errored'; | ||
export declare type VideoError = MediaError | null; | ||
export interface VideoState { | ||
@@ -13,2 +14,3 @@ status: VideoStatus; | ||
isMuted: boolean; | ||
error?: VideoError; | ||
} | ||
@@ -42,6 +44,9 @@ export declare type NavigateFunction = (time: number) => void; | ||
isMuted: boolean; | ||
error?: VideoError; | ||
} | ||
export declare class Video extends Component<VideoProps, VideoComponentState> { | ||
videoElement: HTMLVideoElement; | ||
statusBeforeLoading?: VideoStatus; | ||
state: VideoComponentState; | ||
constructor(props: VideoProps); | ||
static defaultProps: Partial<VideoProps>; | ||
@@ -66,4 +71,5 @@ componentDidUpdate(prevProps: VideoProps): void; | ||
onDurationChange: (e: any) => void; | ||
onError: () => void; | ||
onError: (e: any) => void; | ||
onWaiting: () => void; | ||
render(): React.ReactNode; | ||
} |
@@ -26,4 +26,4 @@ "use strict"; | ||
__extends(Video, _super); | ||
function Video() { | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
function Video(props) { | ||
var _this = _super.call(this, props) || this; | ||
_this.state = { | ||
@@ -57,2 +57,5 @@ buffered: 0, | ||
var video = e.target; | ||
var currentStatus = _this.state.status; | ||
var statusBeforeLoading = _this.statusBeforeLoading; | ||
var status = currentStatus === 'loading' && statusBeforeLoading ? statusBeforeLoading : currentStatus; | ||
var _a = getVolumeFromVideo(video), volume = _a.volume, isMuted = _a.isMuted; | ||
@@ -62,2 +65,3 @@ _this.setState({ | ||
isMuted: isMuted, | ||
status: status, | ||
currentTime: video.currentTime, | ||
@@ -122,7 +126,17 @@ duration: video.duration | ||
}; | ||
_this.onError = function () { | ||
_this.onError = function (e) { | ||
var video = e.target; | ||
_this.setState({ | ||
status: 'errored' | ||
status: 'errored', | ||
error: video.error | ||
}); | ||
}; | ||
_this.onWaiting = function () { | ||
var status = _this.state.status; | ||
_this.statusBeforeLoading = status; | ||
_this.setState({ | ||
status: 'loading' | ||
}); | ||
}; | ||
_this.videoElement = document.createElement('video'); | ||
return _this; | ||
@@ -143,3 +157,3 @@ } | ||
get: function () { | ||
var _a = this.state, currentTime = _a.currentTime, volume = _a.volume, status = _a.status, duration = _a.duration, buffered = _a.buffered, isMuted = _a.isMuted; | ||
var _a = this.state, currentTime = _a.currentTime, volume = _a.volume, status = _a.status, duration = _a.duration, buffered = _a.buffered, isMuted = _a.isMuted, error = _a.error; | ||
return { | ||
@@ -151,3 +165,4 @@ currentTime: currentTime, | ||
buffered: buffered, | ||
isMuted: isMuted | ||
isMuted: isMuted, | ||
error: error | ||
}; | ||
@@ -178,3 +193,3 @@ }, | ||
var _b = this.props, src = _b.src, children = _b.children, autoPlay = _b.autoPlay, controls = _b.controls, preload = _b.preload; | ||
return children(React.createElement("video", { ref: this.saveVideoRef, src: src, preload: preload, controls: controls, autoPlay: autoPlay, onPlay: this.onPlay, onPause: this.onPause, onVolumeChange: this.onVolumeChange, onTimeUpdate: this.onTimeUpdate, onCanPlay: this.onCanPlay, onDurationChange: this.onDurationChange, onError: this.onError }), videoState, actions); | ||
return children(React.createElement("video", { ref: this.saveVideoRef, src: src, preload: preload, controls: controls, autoPlay: autoPlay, onPlay: this.onPlay, onPause: this.onPause, onVolumeChange: this.onVolumeChange, onTimeUpdate: this.onTimeUpdate, onCanPlay: this.onCanPlay, onDurationChange: this.onDurationChange, onError: this.onError, onWaiting: this.onWaiting }), videoState, actions); | ||
}; | ||
@@ -181,0 +196,0 @@ Video.defaultProps = { |
{ | ||
"name": "react-video-renderer", | ||
"version": "1.0.1", | ||
"version": "1.1.2", | ||
"main": "dist/index.js", | ||
@@ -12,2 +12,3 @@ "repository": "git@github.com:zzarcon/react-video-renderer.git", | ||
"@atlaskit/single-select": "^4.0.3", | ||
"@atlaskit/spinner": "^8.0.0", | ||
"ts-react-toolbox": "^0.0.46" | ||
@@ -14,0 +15,0 @@ }, |
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
14512
286
5