Skip to content

Commit 1541d68

Browse files
Merge pull request #17 from clappr/feature/video-ad-source-handler
Feature: Improve the playback with get and set methods to use and change some properties
2 parents 09acc5e + 11e1e22 commit 1541d68

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ Group all DRM-related config. The currently available configs are:
8585
| `playback.minimumDvrSizeConfig` | Returns `options.playback.minimumDvrSize` if is configured and is a valid value. | `{Number}` |
8686
| `playback.dvrSize` | Returns `playback.minimumDvrSizeConfig` if is a valid value or one default value. (Currently, is 60 seconds) | `{Number}` |
8787
| `playback.dvrEnabled` | Indicates whether the live media is on DVR state. | `{Boolean}` |
88+
| `playback.playbackType` | Returns if the type of media when this property was not change the value is `live` or `vod`. | `{String}` |
89+
| `playback.sourceMedia` | Returns a media url in use. | `{String}` |
90+
91+
| setter | description | parameter |
92+
|--------|-------------|----------|
93+
| `playback.playbackType` | Set the new value of playback.playbackType property. | `{String}` |
8894

8995
## Types
9096
#### `AudioTrack`

src/html5_playback.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,22 @@ export default class HTML5TVsPlayback extends Playback {
104104
}
105105
}
106106

107+
get playbackType() {
108+
return this._playbackType
109+
}
110+
111+
set playbackType(newPlaybackType) {
112+
this._playbackType = newPlaybackType
113+
}
114+
115+
get sourceMedia() {
116+
return this._src
117+
}
118+
107119
constructor(options, i18n, playerError) {
108120
super(options, i18n, playerError)
109121
this._onAudioTracksUpdated = this._onAudioTracksUpdated.bind(this)
122+
this._playbackType = this.mediaType
110123

111124
this._drmConfigured = false
112125
this._isReady = false

src/html5_playback.test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,22 @@ describe('HTML5TVsPlayback', function() {
198198
expect(this.playback.buffering).toEqual(this.playback._isBuffering)
199199
})
200200

201+
test('playbackType getter returns mediaType property when is not changed', () => {
202+
this.playback.el = { duration: 0 }
203+
204+
expect(this.playback.playbackType).toEqual(this.playback.mediaType)
205+
})
206+
207+
test('playbackType setter updates playbackType with new value', () => {
208+
this.playback.playbackType = 'new value'
209+
210+
expect(this.playback.playbackType).toEqual('new value')
211+
})
212+
213+
test('sourceMedia getter returns returns src property', () => {
214+
expect(this.playback.sourceMedia).toBe(this.playback._src)
215+
})
216+
201217
test('adds event listeners to the audioTrack object of the media element', () => {
202218
expect(this.playback.el.audioTracks.addEventListener).toHaveBeenCalledWith('addtrack', this.playback._onAudioTracksUpdated)
203219
expect(this.playback.el.audioTracks.addEventListener).toHaveBeenCalledWith('removetrack', this.playback._onAudioTracksUpdated)

0 commit comments

Comments
 (0)