Skip to content

Commit a51449f

Browse files
committed
🚧 Add play and pause
1 parent 8711618 commit a51449f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/components/PlayerVideo/index.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1-
import React from "react";
1+
import React, { useRef } from "react";
22

33
function PlayerVideo() {
4+
const video = useRef(null);
5+
6+
const playAndPause = () =>
7+
video.current.paused ? video.current.play() : video.current.pause();
8+
49
return (
5-
<video src="http://sveltejs.github.io/assets/caminandes-llamigos.mp4"></video>
10+
<video
11+
ref={video}
12+
onClick={playAndPause}
13+
src="http://sveltejs.github.io/assets/caminandes-llamigos.mp4"
14+
></video>
615
);
716
}
817

0 commit comments

Comments
 (0)