Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scratch-www
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
scratch-www
Commits
246798b6
Commit
246798b6
authored
Nov 23, 2020
by
seotts
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use “play” event listener; clean-up code
parent
785386b1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
18 deletions
+18
-18
src/components/video-preview/video-preview.jsx
src/components/video-preview/video-preview.jsx
+2
-1
src/components/video-preview/video-preview.scss
src/components/video-preview/video-preview.scss
+2
-2
src/components/video/video.jsx
src/components/video/video.jsx
+14
-15
No files found.
src/components/video-preview/video-preview.jsx
View file @
246798b6
...
@@ -45,7 +45,7 @@ class VideoPreview extends React.Component {
...
@@ -45,7 +45,7 @@ class VideoPreview extends React.Component {
height=
{
this
.
props
.
videoHeight
}
height=
{
this
.
props
.
videoHeight
}
videoId=
{
this
.
props
.
videoId
}
videoId=
{
this
.
props
.
videoId
}
width=
{
this
.
props
.
videoWidth
}
width=
{
this
.
props
.
videoWidth
}
on
Load
=
{
this
.
handleVideoLoaded
}
on
VideoStart
=
{
this
.
handleVideoLoaded
}
/>
/>
</
div
>
</
div
>
)
:
(
)
:
(
...
@@ -53,6 +53,7 @@ class VideoPreview extends React.Component {
...
@@ -53,6 +53,7 @@ class VideoPreview extends React.Component {
className=
"video-thumbnail"
className=
"video-thumbnail"
onClick=
{
this
.
handleShowVideo
}
onClick=
{
this
.
handleShowVideo
}
>
>
{
/* Load an invisible spinner so that the image has a chance to load before it's needed */
}
<
img
<
img
className=
{
classNames
(
'
loading-spinner
'
,
'
hidden-spinner
'
)
}
className=
{
classNames
(
'
loading-spinner
'
,
'
hidden-spinner
'
)
}
src=
"/svgs/modal/spinner-white.svg"
src=
"/svgs/modal/spinner-white.svg"
...
...
src/components/video-preview/video-preview.scss
View file @
246798b6
...
@@ -46,10 +46,10 @@
...
@@ -46,10 +46,10 @@
position
:
relative
;
position
:
relative
;
}
}
.iframe-
not-load
ed
{
.iframe-
video-not-start
ed
{
visibility
:
hidden
;
visibility
:
hidden
;
}
}
.iframe-
load
ed
{
.iframe-
video-start
ed
{
visibility
:
visible
;
visibility
:
visible
;
}
}
src/components/video/video.jsx
View file @
246798b6
const
bindAll
=
require
(
'
lodash.bindall
'
);
const
PropTypes
=
require
(
'
prop-types
'
);
const
PropTypes
=
require
(
'
prop-types
'
);
const
React
=
require
(
'
react
'
);
const
React
=
require
(
'
react
'
);
const
classNames
=
require
(
'
classnames
'
);
const
classNames
=
require
(
'
classnames
'
);
...
@@ -11,7 +9,7 @@ class Video extends React.Component {
...
@@ -11,7 +9,7 @@ class Video extends React.Component {
super
(
props
);
super
(
props
);
this
.
state
=
{
this
.
state
=
{
load
ed
:
false
videoStart
ed
:
false
};
};
}
}
componentDidMount
()
{
componentDidMount
()
{
...
@@ -29,36 +27,37 @@ class Video extends React.Component {
...
@@ -29,36 +27,37 @@ class Video extends React.Component {
}
}
window
.
_wq
=
window
.
_wq
||
[];
window
.
_wq
=
window
.
_wq
||
[];
// Use onReady in combination with the Wistia 'play' event handler so that onVideoStart()
// isn't called until the video actually starts. onReady fires before the video player is visible.
window
.
_wq
.
push
({
window
.
_wq
.
push
({
id
:
this
.
props
.
videoId
,
id
:
this
.
props
.
videoId
,
onReady
:
video
=>
{
onReady
:
video
=>
{
video
.
bind
(
'
secondchange
'
,
s
=>
{
video
.
bind
(
'
play
'
,
()
=>
{
if
(
s
>=
0
)
{
this
.
setState
({
videoStarted
:
true
});
this
.
setState
({
loaded
:
true
});
this
.
props
.
onVideoStart
();
this
.
props
.
onLoad
();
return
video
.
unbind
;
}
});
});
}
}
});
});
}
}
render
()
{
render
()
{
const
loadedClass
=
this
.
state
.
loaded
?
'
iframe-loaded
'
:
'
iframe-not-loaded
'
;
// Provide CSS classes for anything using the video component to configure what happens before and after
// the video has played for the first time. See VideoPreview for an example.
const
videoStartedClass
=
this
.
state
.
videoStarted
?
'
iframe-video-started
'
:
'
iframe-video-not-started
'
;
return
(
return
(
<
div
className=
{
classNames
(
'
video-player
'
,
this
.
props
.
className
)
}
>
<
div
className=
{
classNames
(
'
video-player
'
,
this
.
props
.
className
)
}
>
<
iframe
<
iframe
allowFullScreen
allowFullScreen
// allowFullScreen is legacy, can we start using allow='fullscreen'?
className=
{
classNames
(
'
wistia_embed
'
,
`wistia_async_${this.props.videoId}`
,
videoStartedClass
)
}
// allow="fullscreen"
className=
{
classNames
(
'
wistia_embed
'
,
`wistia_async_${this.props.videoId}`
,
loadedClass
)
}
frameBorder=
"0"
// deprecated attribute
frameBorder=
"0"
// deprecated attribute
height=
{
this
.
props
.
height
}
height=
{
this
.
props
.
height
}
scrolling=
"no"
// deprecated attribute
scrolling=
"no"
// deprecated attribute
src=
{
`https://fast.wistia.net/embed/iframe/${this.props.videoId}?seo=false&videoFoam=true`
}
src=
{
`https://fast.wistia.net/embed/iframe/${this.props.videoId}?seo=false&videoFoam=true`
}
title=
{
this
.
props
.
title
}
title=
{
this
.
props
.
title
}
width=
{
this
.
props
.
width
}
width=
{
this
.
props
.
width
}
// onLoad={this.props.onLoad}
/>
/>
</
div
>
</
div
>
);
);
...
@@ -73,7 +72,7 @@ Video.defaultProps = {
...
@@ -73,7 +72,7 @@ Video.defaultProps = {
Video
.
propTypes
=
{
Video
.
propTypes
=
{
className
:
PropTypes
.
string
,
className
:
PropTypes
.
string
,
height
:
PropTypes
.
string
.
isRequired
,
height
:
PropTypes
.
string
.
isRequired
,
on
Load
:
PropTypes
.
func
,
on
VideoStart
:
PropTypes
.
func
,
title
:
PropTypes
.
string
.
isRequired
,
title
:
PropTypes
.
string
.
isRequired
,
videoId
:
PropTypes
.
string
.
isRequired
,
videoId
:
PropTypes
.
string
.
isRequired
,
width
:
PropTypes
.
string
.
isRequired
width
:
PropTypes
.
string
.
isRequired
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment