Update index.svelte

changed `playVideo` to `play`
added `paused()`, `pause()`, `jumpTo`, and `position`
This commit is contained in:
2020-10-01 12:41:23 +02:00
committed by GitHub
parent 5debdfafcc
commit 203bd1b908

View File

@@ -60,11 +60,32 @@
function onPlayerStateChange({ data }) { function onPlayerStateChange({ data }) {
dispatch("StateChange", data); dispatch("StateChange", data);
} }
export function playVideo() {
player.playVideo(); export function position() {
return player.getCurrentTime()
} }
export function play() {
player.playVideo();
console.log(player)
}
export function jumpTo(seconds) {
player.seekTo(seconds)
}
export function pause() {
player.pauseVideo()
}
export function paused() {
const playerState = player.getPlayerState()
console.log(playerState)
return [5, 2, -1].includes(playerState)
}
</script> </script>
<div class="yt-component"> <span class="yt-component" style="float: left">
<div id={divId} /> <div id={divId} />
</div> </span>