-
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
108 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React, { useLayoutEffect } from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
const StyledContainer = styled.div` | ||
& iframe { | ||
position: absolute; | ||
top: 0; | ||
width: 600px; | ||
height: 100%; | ||
} | ||
`; | ||
|
||
const Embedly = ({ onRender }) => { | ||
useLayoutEffect(() => { | ||
onRender(); | ||
}, [onRender]); | ||
|
||
return ( | ||
<StyledContainer> | ||
<iframe | ||
frameBorder="0" | ||
src="//cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplayer.vimeo.com%2Fvideo%2F159048928&url=https%3A%2F%2Fvimeo.com%2F159048928&image=http%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F560697717_1280.jpg&key=1d5c48f7edc34c54bdae4c37b681ea2b&type=text%2Fhtml&schema=vimeo" | ||
/> | ||
</StyledContainer> | ||
); | ||
}; | ||
|
||
export default Embedly; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,20 @@ | ||
import React, { useLayoutEffect } from 'react' | ||
import React, { useLayoutEffect } from 'react'; | ||
|
||
export default ({ onRender }) => { | ||
const YoutubeIframe = ({ onRender }) => { | ||
useLayoutEffect(() => { | ||
onRender() | ||
}, []) | ||
onRender(); | ||
}, [onRender]); | ||
|
||
return ( | ||
<iframe | ||
width="560" | ||
height="315" | ||
src="https://www.youtube.com/embed/-rD541GWdDM" | ||
frameBorder="0" | ||
<iframe | ||
width="560" | ||
height="315" | ||
src="https://www.youtube.com/embed/-rD541GWdDM" | ||
frameBorder="0" | ||
allow="accelerometer;autoplay;encrypted-media;gyroscope;" | ||
allowFullScreen /> | ||
) | ||
} | ||
allowFullScreen | ||
/> | ||
); | ||
}; | ||
|
||
export default YoutubeIframe; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import Player from './Player'; | ||
|
||
// For Embedly API details, please refer to https://docs.embed.ly/docs/playerjs | ||
export default class YoutubeIframePlayer extends Player { | ||
#videoEl; | ||
#player; | ||
|
||
constructor(options = {}) { | ||
super(options); | ||
|
||
this.#videoEl = options.videoEl; | ||
// eslint-disable-next-line no-undef | ||
this.#player = new embedly.Player(this.#videoEl); | ||
this.#player.on('ready', () => { | ||
logger.info('Embedly player ready'); | ||
}); | ||
} | ||
|
||
getVideoElement() { | ||
return this.#videoEl; | ||
} | ||
|
||
play() { | ||
this.#player.play(); | ||
} | ||
|
||
pause() { | ||
this.#player.pause(); | ||
} | ||
|
||
seek(timestamp) { | ||
const timeToSeek = timestamp - this.seekSeconds; | ||
this.#player.setCurrentTime(timeToSeek); | ||
} | ||
|
||
getCurrentTime() { | ||
return new Promise(resolve => { | ||
this.#player.getCurrentTime(currentTime => { | ||
resolve(Math.floor(currentTime)); | ||
}); | ||
}); | ||
} | ||
|
||
getDuration() { | ||
return new Promise(resolve => { | ||
this.#player.getDuration(resolve); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.