@gcorevideo/player 2.22.28 → 2.22.30

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.
@@ -1,4 +1,5 @@
1
1
  import { UICorePlugin, Browser, Playback, Events, template } from '@clappr/core'
2
+ import { trace } from '@gcorevideo/utils'
2
3
 
3
4
  import { CLAPPR_VERSION } from '../../build.js'
4
5
 
@@ -7,8 +8,10 @@ import '../../../assets/skip-time/style.scss'
7
8
 
8
9
  type Position = 'mid' | 'left' | 'right'
9
10
 
11
+ const T = 'plugins.skip_time'
12
+
10
13
  /**
11
- * `PLUGIN` that adds skip controls to the media control UI.
14
+ * `PLUGIN` that allows skipping time by tapping on the left or right side of the video.
12
15
  * @beta
13
16
  */
14
17
  export class SkipTime extends UICorePlugin {
@@ -24,52 +27,70 @@ export class SkipTime extends UICorePlugin {
24
27
  return this.core && this.core.activeContainer
25
28
  }
26
29
 
27
- get template() {
28
- return template(pluginHtml)
29
- }
30
+ private static readonly template = template(pluginHtml)
30
31
 
32
+ /**
33
+ * @internal
34
+ */
31
35
  override get attributes() {
32
36
  return {
33
- class: this.name + '_plugin',
34
- 'data-skip-time': '',
37
+ class: 'mc-skip-time',
35
38
  }
36
39
  }
37
40
 
38
41
  private position: Position = 'mid'
39
42
 
43
+ /**
44
+ * @internal
45
+ */
40
46
  override get events() {
41
47
  return {
42
- 'click [data-skip-left]': 'setBack',
43
- 'click [data-skip-mid]': 'setMidClick',
44
- 'click [data-skip-right]': 'setForward',
48
+ 'click #mc-skip-left': 'setBack',
49
+ 'click #mc-skip-mid': 'setMidClick',
50
+ 'click #mc-skip-right': 'setForward',
45
51
  }
46
52
  }
47
53
 
54
+ /**
55
+ * @internal
56
+ */
48
57
  override bindEvents() {
49
58
  this.listenTo(this.core, Events.CORE_READY, this.render)
50
- if (!this.container) {
51
- return
52
- }
59
+ this.listenTo(this.core, Events.CORE_ACTIVE_CONTAINER_CHANGED, this.onContainerChanged)
60
+ }
61
+
62
+ private onContainerChanged() {
53
63
  this.listenTo(
54
64
  this.container,
55
65
  Events.CONTAINER_DBLCLICK,
56
66
  this.handleRewindClicks,
57
67
  )
68
+ this.mount()
58
69
  }
59
70
 
60
- setBack() {
71
+ private setBack() {
72
+ trace(`${T} setBack`)
61
73
  this.position = 'left'
62
74
  }
63
75
 
64
- handleRewindClicks() {
76
+ private handleRewindClicks() {
77
+ trace(`${T} handleRewindClicks`, {
78
+ position: this.position,
79
+ })
65
80
  if (
66
81
  this.core.getPlaybackType() === Playback.LIVE &&
67
82
  !this.container.isDvrEnabled()
68
83
  ) {
69
84
  this.toggleFullscreen()
70
-
71
85
  return
72
86
  }
87
+ this.handleSkip()
88
+ }
89
+
90
+ private handleSkip() {
91
+ trace(`${T} handleSkip`, {
92
+ position: this.position,
93
+ })
73
94
  if (Browser.isMobile) {
74
95
  if (this.position === 'left') {
75
96
  const seekPos = this.container.getCurrentTime() - 10
@@ -92,29 +113,35 @@ export class SkipTime extends UICorePlugin {
92
113
  }
93
114
  }
94
115
 
95
- setMidClick() {
116
+ private setMidClick() {
117
+ trace(`${T} setMidClick`)
96
118
  this.position = 'mid'
97
119
  }
98
120
 
99
- setForward() {
121
+ private setForward() {
122
+ trace(`${T} setForward`)
100
123
  this.position = 'right'
101
124
  }
102
125
 
103
- toggleFullscreen() {
126
+ private toggleFullscreen() {
127
+ trace(`${T} toggleFullscreen`)
104
128
  this.trigger(Events.MEDIACONTROL_FULLSCREEN, this.name)
105
129
  this.container.fullscreen()
106
130
  this.core.toggleFullscreen()
107
131
  }
108
132
 
133
+ /**
134
+ * @internal
135
+ */
109
136
  override render() {
110
- this.$el.html(template(pluginHtml))
111
-
112
- if (this.core.activeContainer) {
113
- this.core.activeContainer.$el.append(this.el)
114
- }
115
-
116
- this.bindEvents()
137
+ trace(`${T} render`)
138
+ this.$el.html(SkipTime.template())
117
139
 
118
140
  return this
119
141
  }
142
+
143
+ private mount() {
144
+ trace(`${T} mount`)
145
+ this.core.activeContainer.$el.append(this.el)
146
+ }
120
147
  }