Skip to content

Commit

Permalink
Merge pull request #1593 from markmatney/enable-mediacontrol-configur…
Browse files Browse the repository at this point in the history
…ation

enable MediaControl configuration after player creation
  • Loading branch information
flavioribeiro committed Mar 14, 2018
2 parents 3491400 + c0de5e3 commit 1e5df5d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/base/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -795,3 +795,9 @@ Events.MEDIACONTROL_NOTPLAYING = 'mediacontrol:notplaying'
* @event MEDIACONTROL_CONTAINERCHANGED
*/
Events.MEDIACONTROL_CONTAINERCHANGED = 'mediacontrol:containerchanged'
/**
* Fired when the options were changed for the mediacontrol
*
* @event MEDIACONTROL_OPTIONS_CHANGE
*/
Events.MEDIACONTROL_OPTIONS_CHANGE = 'mediacontrol:options:change'
1 change: 1 addition & 0 deletions src/components/core/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ export default class Core extends UIObject {
this.containers.forEach((container) => {
container.configure(this.options)
})
this.mediaControl.configure(this.options)
}

appendToParent() {
Expand Down
10 changes: 10 additions & 0 deletions src/components/media_control/media_control.js
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,16 @@ export default class MediaControl extends UIObject {
this.unbindKeyEvents()
}

/**
* enables to configure the media control after its creation
* @method configure
* @param {Object} options all the options to change in form of a javascript object
*/
configure(options) {
this._options = $.extend(this._options, options)
this.trigger(Events.MEDIACONTROL_OPTIONS_CHANGE)
}

render() {
const timeout = 1000
this.$el.html(this.template({ settings: this.settings }))
Expand Down
12 changes: 12 additions & 0 deletions test/components/media_control_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,16 @@ describe('MediaControl', function() {
)
})
})

it('can be configured after its creation', function() {
expect(this.mediaControl._options.hideMediaControl).to.be.undefined
expect(this.mediaControl._options.mediacontrol).to.be.undefined

this.mediaControl.configure({ hideMediaControl: false, mediacontrol: { seekbar: '#E113D3', buttons: '#66B2FF' } })
expect(this.mediaControl._options.hideMediaControl).to.be.false
expect(this.mediaControl._options.mediacontrol).not.to.be.undefined

this.mediaControl.configure({ hideMediaControl: true })
expect(this.mediaControl._options.hideMediaControl).to.be.true
})
})

0 comments on commit 1e5df5d

Please sign in to comment.