-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add BitPlayer route for simple timestamp generation
- Loading branch information
1 parent
5b74a31
commit ad53f93
Showing
2 changed files
with
43 additions
and
1 deletion.
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,40 @@ | ||
/*The name has nothing to do with bits and bytes, but refers to the term | ||
"bit player" meaning an actor playing a minor part, | ||
since this is kind of a no-frills YouTube player*/ | ||
|
||
import "./DocumentView.css" | ||
import React, {useState} from "react" | ||
import YouTube, {YouTubeProps} from "react-youtube" | ||
|
||
function Video({vId="rLEBp8R1_XA"}) { | ||
const [ptime, setPtime] = useState(-1) | ||
const [video, setVideoId] = useState(vId) | ||
|
||
const onPause : YouTubeProps["onPause"] = (event) => { | ||
/* eslint-disable @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call */ | ||
const player = event.target | ||
setPtime(player.getCurrentTime()) | ||
/* eslint-enable @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call */ | ||
} | ||
|
||
const onChange = (e: React.ChangeEvent<HTMLInputElement>) => { | ||
setVideoId(e.target.value) | ||
} | ||
|
||
return <> | ||
<div> | ||
<YouTube videoId={video} onPause={onPause}/> | ||
</div> | ||
{ptime >= 0 && <div>Paused at: {ptime.toFixed(2)}</div>} | ||
Enter video ID: | ||
<input type="search" id="corpus-bit-player" style = {{flexGrow: 1}} value = {video} onChange={onChange}/> | ||
</> | ||
|
||
} | ||
export const BitPlayer= () => { | ||
return (<div className="BitPlayer"> | ||
<header className="BitPlayer-header"> | ||
</header> | ||
<Video/> | ||
</div>) | ||
} |