Skip to content

Commit

Permalink
Add base subtitle
Browse files Browse the repository at this point in the history
  • Loading branch information
hockyy committed Dec 27, 2022
1 parent 065f624 commit 93f2d3e
Show file tree
Hide file tree
Showing 9 changed files with 1,054 additions and 75 deletions.
598 changes: 598 additions & 0 deletions intellij-java-google-style.xml

Large diffs are not rendered by default.

343 changes: 303 additions & 40 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
"dependencies": {
"electron-serve": "^1.1.0",
"electron-store": "^8.1.0",
"html-react-parser": "^3.0.6",
"react-dropzone": "^14.2.3",
"shunou-js": "^0.0.4",
"video.js": "^7.20.3"
},
"devDependencies": {
Expand Down
26 changes: 0 additions & 26 deletions renderer/components/MiteiruPlayer.tsx

This file was deleted.

18 changes: 18 additions & 0 deletions renderer/components/Sentence.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export const Sentence = ({origin, separation}) => {
const handleChange = (origin) => {
console.log(origin)
}
return <button className={"subtitle"} onClick={() => {
handleChange(origin)
}}>
{separation.map((val, index) => {
return <ruby key={index}>{val.bottom}
<rp>(</rp>
<rt>{val.top ?? ''}</rt>
<rp>)</rp>
</ruby>
})}
</button>
}

export default Sentence;
113 changes: 113 additions & 0 deletions renderer/components/Subtitle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
import React, {useEffect, useState} from "react";

import parse from 'html-react-parser';
import Sentence from "./Sentence";

const example = [
{
"origin": "アニメ",
"hiragana": "あにめ",
"basicForm": "アニメ-animation",
"pos": "名詞-普通名詞-一般",
"separation": [
{
"bottom": "ア",
"top": null
},
{
"bottom": "ニ",
"top": null
},
{
"bottom": "メ",
"top": null
}
]
},
{
"origin": "を",
"hiragana": "お",
"basicForm": "を",
"pos": "助詞-格助詞",
"separation": [
{
"bottom": "を",
"top": null
}
]
},
{
"origin": "見",
"hiragana": "み",
"basicForm": "見る",
"pos": "動詞-非自立可能",
"separation": [
{
"bottom": "見",
"top": "み"
}
]
},
{
"origin": "て",
"hiragana": "て",
"basicForm": "て",
"pos": "助詞-接続助詞",
"separation": [
{
"bottom": "て",
"top": null
}
]
},
{
"origin": "い",
"hiragana": "い",
"basicForm": "居る",
"pos": "動詞-非自立可能",
"separation": [
{
"bottom": "い",
"top": null
}
]
},
{
"origin": "ます",
"hiragana": "ます",
"basicForm": "ます",
"pos": "助動詞",
"separation": [
{
"bottom": "ま",
"top": null
},
{
"bottom": "す",
"top": null
}
]
}
]

export const Subtitle = (props) => {
const [caption, setCaption] = useState([])
useEffect(() => {
let current = example.map((val, index) => {
return <Sentence key={index} origin={val.origin} separation={val.separation}/>
})
setCaption(current)

}, []);
return <div style={{
WebkitTextStrokeColor: "black",
WebkitTextStrokeWidth: "1px",
fontSize: "50px",
fontFamily: "Arial",
fontWeight: "bold",
}}>
{caption}
</div>
}

export default Subtitle
12 changes: 10 additions & 2 deletions renderer/components/VideoJS.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, {useEffect} from 'react';
import videojs from 'video.js';
import 'video.js/dist/video-js.css';
import Subtitle from "./Subtitle";

export const VideoJS = (props) => {
const videoRef = React.useRef(null);
Expand Down Expand Up @@ -48,8 +49,15 @@ export const VideoJS = (props) => {
}, [playerRef]);

return (
<div data-vjs-player>
<div ref={videoRef}/>
<div>
<div>
<div className={'z-[-1] fixed w-[100vw]'}>
<div data-vjs-player>
<div ref={videoRef}></div>
</div>
</div>
<Subtitle/>
</div>
<button onClick={handle}>Coba</button>
</div>
);
Expand Down
8 changes: 1 addition & 7 deletions renderer/pages/video.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import {ipcRenderer} from "electron";
import React, {useCallback, useState} from "react";
import {useDropzone} from "react-dropzone";
import VideoJS from "../components/VideoJS";
import MiteiruPlayer from "../components/MiteiruPlayer";
import VideoReact from "../components/VideoReact";
import ReactPlayer from "react-player";
import Subtitle from "../components/Subtitle";


function Video() {
Expand Down Expand Up @@ -43,9 +40,6 @@ function Video() {
return (
<React.Fragment>
<div>
{/*<MiteiruPlayer videoSrc={videoSrc}/>*/}
{/*<ReactPlayer url={videoSrc.src}/>*/}
{/*<VideoReact videoSrc={videoSrc.src}/>*/}
<VideoJS options={videoJsOptions} onReady={handlePlayerReady}/>
<div {...getRootProps()}>
<input {...getInputProps()} />
Expand Down
9 changes: 9 additions & 0 deletions renderer/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,12 @@
@apply text-white font-bold px-4 py-2 rounded bg-blue-600 hover:bg-blue-500;
}
}

.subtitle:hover {
-webkit-text-fill-color: aqua;
}


.subtitle {
-webkit-text-fill-color: green;
}

0 comments on commit 93f2d3e

Please sign in to comment.