@gcorevideo/player 2.22.31 → 2.23.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.
@@ -2,7 +2,7 @@ import { Container, Events, UICorePlugin, $, template } from '@clappr/core'
2
2
  import { trace } from '@gcorevideo/utils'
3
3
  import assert from 'assert'
4
4
 
5
- import { TimeProgress } from '../../playback.types.js'
5
+ import { TimeProgress, TimeValue } from '../../playback.types.js'
6
6
  import type { ZeptoResult } from '../../types.js'
7
7
  import '../../../assets/clips/clips.scss'
8
8
  import { ClipDesc } from './types.js'
@@ -117,6 +117,15 @@ export class Clips extends UICorePlugin {
117
117
  return super.enable()
118
118
  }
119
119
 
120
+ /**
121
+ * Get the text of the clip at the given time
122
+ * @param time - The time to get the text for
123
+ * @returns The text of the clip at the given time
124
+ */
125
+ getText(time: TimeValue): string | undefined {
126
+ return this.clips.find((clip) => clip.start <= time && clip.end >= time)?.text
127
+ }
128
+
120
129
  private onCoreReady() {
121
130
  trace(`${T} onCoreReady`)
122
131
  const mediaControl = this.core.getPlugin('media_control')
@@ -279,8 +279,8 @@ export class MediaControl extends UICorePlugin {
279
279
  }
280
280
 
281
281
  /**
282
+ * Use in mediacontrol-based plugins to access the active container
282
283
  * @internal
283
- * @deprecated Use core.activeContainer directly
284
284
  */
285
285
  get container() {
286
286
  return this.core.activeContainer
@@ -645,18 +645,17 @@ export class MediaControl extends UICorePlugin {
645
645
  }
646
646
 
647
647
  private mousemoveOnSeekBar(event: MouseEvent) {
648
+ const offset = MediaControl.getPageX(event) -
649
+ (this.$seekBarContainer.offset().left ?? 0) // TODO check if the result can be negative
650
+ const hoverOffset =
651
+ offset -
652
+ (this.$seekBarHover.width() ?? 0) / 2
653
+ const pos = offset ? Math.min(1, Math.max(offset / this.$seekBarContainer.width(), 0)) : 0
648
654
  if (this.settings.seekEnabled) {
649
- // assert.ok(this.$seekBarHover && this.$seekBarContainer, 'seek bar elements must be present');
650
- if (this.$seekBarHover && this.$seekBarContainer) {
651
- const offsetX =
652
- MediaControl.getPageX(event) -
653
- this.$seekBarContainer.offset().left -
654
- this.$seekBarHover.width() / 2
655
-
656
- this.$seekBarHover.css({ left: offsetX })
657
- }
655
+ // TODO test that it works when the element does not exist
656
+ this.$seekBarHover.css({ left: hoverOffset })
658
657
  }
659
- this.trigger(Events.MEDIACONTROL_MOUSEMOVE_SEEKBAR, event)
658
+ this.trigger(Events.MEDIACONTROL_MOUSEMOVE_SEEKBAR, event, pos)
660
659
  }
661
660
 
662
661
  private mouseleaveOnSeekBar(event: MouseEvent) {
@@ -1194,19 +1193,9 @@ export class MediaControl extends UICorePlugin {
1194
1193
  } else {
1195
1194
  panel.append(element)
1196
1195
  }
1197
- return
1198
1196
  }
1199
1197
  }
1200
1198
 
1201
- /**
1202
- * @deprecated Use {@link MediaControl.mount} instead
1203
- * @param name
1204
- * @param element
1205
- */
1206
- putElement(name: MediaControlElement, element: ZeptoResult) {
1207
- this.mount(name, element)
1208
- }
1209
-
1210
1199
  /**
1211
1200
  * Toggle the visibility of a media control element
1212
1201
  * @param name - The name of the media control element