Update index.svelte
This commit is contained in:
@@ -4,8 +4,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
let player;
|
let player;
|
||||||
import { createEventDispatcher, onMount } from "svelte";
|
import { onMount } from "svelte";
|
||||||
const dispatch = createEventDispatcher();
|
|
||||||
let divId = "player_" + parseInt(Math.random() * 100000).toString();
|
let divId = "player_" + parseInt(Math.random() * 100000).toString();
|
||||||
export let videoId;
|
export let videoId;
|
||||||
export let height = "390";
|
export let height = "390";
|
||||||
@@ -57,30 +56,11 @@
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onPlayerStateChange({ data }) {
|
export position = () => player.getCurrentTime()
|
||||||
dispatch("StateChange", data);
|
export play = () => player.playVideo()
|
||||||
}
|
export jumpTo = seconds => player.seekTo(seconds)
|
||||||
|
export pause = () => player.pauseVideo()
|
||||||
export function position() {
|
export paused = () => [5, 2, -1].includes(player.getPlayerState())
|
||||||
return player.getCurrentTime()
|
|
||||||
}
|
|
||||||
|
|
||||||
export function play() {
|
|
||||||
player.playVideo();
|
|
||||||
}
|
|
||||||
|
|
||||||
export function jumpTo(seconds) {
|
|
||||||
player.seekTo(seconds)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function pause() {
|
|
||||||
player.pauseVideo()
|
|
||||||
}
|
|
||||||
|
|
||||||
export function paused() {
|
|
||||||
const playerState = player.getPlayerState()
|
|
||||||
return [5, 2, -1].includes(playerState)
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user