@banou/media-player 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,6 +11,7 @@ type SubtitlesEvents =
11
11
  | { type: 'NEW_SUBTITLE_FRAGMENTS', subtitles: SubtitleFragment[] }
12
12
  | { type: 'NEW_ATTACHMENTS', attachments: Attachment[] }
13
13
  | { type: 'SELECT_SUBTITLE_STREAM', streamIndex: number }
14
+ | { type: 'TIME_UPDATE', currentTime: number }
14
15
 
15
16
  type SubtitlesEmittedEvents =
16
17
  | { type: 'WAITING' }
@@ -137,12 +138,25 @@ export default fromAsyncCallback<SubtitlesEvents, SubtitlesInput, SubtitlesEmitt
137
138
  let appendedSubtitleParts: SubtitlePart[] = []
138
139
  let selectedStreamIndex: number | undefined
139
140
 
141
+ const currentTimeInterval = setInterval(() => {
142
+ if (jassubInstance) {
143
+ jassubInstance.setCurrentTime(video.paused, video.currentTime, video.playbackRate)
144
+ }
145
+ }, 100)
146
+
140
147
  receive((event) => {
148
+ if (event.type === 'TIME_UPDATE' && jassubInstance) {
149
+ jassubInstance.setCurrentTime(video.paused, event.currentTime, video.playbackRate)
150
+ }
141
151
  if (event.type === 'SELECT_SUBTITLE_STREAM') {
142
152
  selectedStreamIndex = event.streamIndex
143
153
  sendBack({ type: 'SELECTED_SUBTITLE_STREAM_UPDATED', streamIndex: event.streamIndex })
144
154
  if (!jassubInstance) return
145
155
  jassubInstance.freeTrack()
156
+ jassubInstance.setCurrentTime(video.paused, video.currentTime, video.playbackRate)
157
+ if (selectedStreamIndex === undefined) {
158
+ return
159
+ }
146
160
  appendedSubtitleParts = []
147
161
  const newSubtitleStreams = subtitlesStreams.get(selectedStreamIndex)
148
162
  if (!newSubtitleStreams) {
@@ -232,6 +246,7 @@ export default fromAsyncCallback<SubtitlesEvents, SubtitlesInput, SubtitlesEmitt
232
246
  }
233
247
  const header = stringify(modifiedHeader)
234
248
  jassubInstance = new JASSUB({
249
+ onDemandRender: false,
235
250
  video,
236
251
  canvas,
237
252
  subContent: header,
@@ -264,6 +279,7 @@ export default fromAsyncCallback<SubtitlesEvents, SubtitlesInput, SubtitlesEmitt
264
279
  })
265
280
 
266
281
  return () => {
282
+ clearInterval(currentTimeInterval)
267
283
  jassubInstance?.destroy()
268
284
  }
269
285
  })
@@ -26,6 +26,10 @@ export const fonts = {
26
26
  font-size: 1.8rem;
27
27
  line-height: 2.2rem;
28
28
  }
29
+ @media (min-width: 2560px) {
30
+ font-size: 2.2rem;
31
+ line-height: 2.6rem;
32
+ }
29
33
  `,
30
34
  extraSmall: `
31
35
  font-weight: 500;
@@ -26,5 +26,5 @@ export const useLocalStorage = <T,>(name: string, defaultValue?: T) => {
26
26
 
27
27
  export default useLocalStorage
28
28
 
29
- export type mediaMutedType = 'true' | 'false' | undefined
29
+ export type booleanType = 'true' | 'false' | undefined
30
30