@@ -9,18 +9,23 @@ import { parseSubs } from 'frazy-parser'
9
9
import { useRef , useEffect } from 'react'
10
10
import useCaptions from './useCaptions'
11
11
import usePlayer from './usePlayer'
12
+ import peaks from './peaks'
13
+ import initWavesurfer from '../wavesurfer'
12
14
13
15
const VideoInfo = props => {
14
16
const {
15
17
title,
16
18
keywords,
17
- captionTracks,
19
+ captionTracks : captionTracksYoutube ,
18
20
urlVideo,
19
21
urlAudio,
20
22
thumbnails,
21
23
description,
22
24
image : poster ,
23
25
setDisplayMode,
26
+ displayMode
27
+ } = props
28
+
24
29
const {
25
30
captionTracks,
26
31
captions,
@@ -32,6 +37,29 @@ const VideoInfo = props => {
32
37
} = useCaptions ( captionTracksYoutube )
33
38
34
39
const mediaRef = useRef ( null )
40
+ const audioRef = useRef ( null )
41
+ const waveformRef = useRef ( null )
42
+ const timelineRef = useRef ( null )
43
+ const wavesurferRef = useRef ( null )
44
+
45
+ const { phrases : mainPhrases } = captions [ selectedLangs [ 0 ] || 'en' ] || { }
46
+
47
+ useEffect ( ( ) => {
48
+ const initWavesurfer0 = async ( ) => {
49
+ const wavesurfer = await initWavesurfer ( {
50
+ waveformContainer : waveformRef . current ,
51
+ timelineContainer : timelineRef . current ,
52
+ regions : mainPhrases ,
53
+ mediaElement : mediaRef . current ,
54
+ peaks
55
+ } )
56
+ wavesurferRef . current = wavesurfer
57
+ console . log ( 'wavesurfer' )
58
+ console . log ( wavesurfer )
59
+ }
60
+ initWavesurfer0 ( )
61
+ } , [ ] )
62
+
35
63
const { onTimeUpdate, currentPhraseNum } = usePlayer ( {
36
64
media : mediaRef . current ,
37
65
waveformContainer : waveformRef . current ,
@@ -57,6 +85,8 @@ const VideoInfo = props => {
57
85
ref = { mediaRef }
58
86
controls
59
87
src = { urlVideo }
88
+ // src='http://localhost:3000/videoplayback.m4a'
89
+ // src='http://localhost:3000/nevzuk.mp4'
60
90
poster = { poster }
61
91
style = { { width : '100%' } }
62
92
onTimeUpdate = { onTimeUpdate }
@@ -65,7 +95,7 @@ const VideoInfo = props => {
65
95
66
96
const audioBlock = (
67
97
< div style = { styles . block } >
68
- < audio controls src = { urlAudio } style = { { width : '100%' } } />
98
+ < audio ref = { audioRef } controls src = { urlAudio } style = { { width : '100%' } } />
69
99
</ div >
70
100
)
71
101
@@ -153,6 +183,9 @@ const VideoInfo = props => {
153
183
>
154
184
{ videoBlock }
155
185
</ div >
186
+ < div > { currentPhraseNum } </ div >
187
+ < div ref = { waveformRef } />
188
+ < div ref = { timelineRef } />
156
189
< div style = { styles . block } >
157
190
< ShowingModeSwitcher
158
191
displayMode = { displayMode }
0 commit comments