Skip to content
This repository was archived by the owner on Sep 28, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 6 additions & 16 deletions src/playbacks/html5_video/html5_video.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export default class HTML5Video extends Playback {
get name() { return 'html5_video' }
get supportedVersion() { return { min: VERSION } }
get tagName() { return this.isAudioOnly ? 'audio' : 'video' }
get template() { return template(tracksHTML) }

get isAudioOnly() {
const resourceUrl = this.options.src
Expand Down Expand Up @@ -230,6 +231,7 @@ export default class HTML5Video extends Playback {
}

_onLoadedMetadata(e) {
this._ready()
this._handleBufferingEvents()
this.trigger(Events.PLAYBACK_LOADEDMETADATA, { duration: e.target.duration, data: e })
this._updateSettings()
Expand Down Expand Up @@ -565,8 +567,7 @@ export default class HTML5Video extends Playback {
}

_ready() {
if (this._isReadyState)
return
if (this._isReadyState) return

this._isReadyState = true
this.trigger(Events.PLAYBACK_READY, this.name)
Expand Down Expand Up @@ -649,24 +650,13 @@ export default class HTML5Video extends Playback {
})
}

get template() { return template(tracksHTML) }

render() {
if (this.options.playback.disableContextMenu) {
this.$el.on('contextmenu', () => {
return false
})
}

if (this._externalTracks && this._externalTracks.length > 0) {
this.$el.html(this.template({
tracks: this._externalTracks,
}))
}
this.options.playback.disableContextMenu && this.$el.on('contextmenu', () => { return false })
this._externalTracks && this._externalTracks.length > 0 && this.$el.html(this.template({ tracks: this._externalTracks }))

this._ready()
const style = Styler.getStyleFor(HTML5VideoStyle.toString(), { baseUrl: this.options.baseUrl })
this.$el.append(style[0])

return this
}
}
Expand Down
10 changes: 10 additions & 0 deletions src/playbacks/html5_video/html5_video.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -609,4 +609,14 @@ describe('HTML5Video playback', function() {
expect(html5Video._updateDvr).toHaveBeenCalledWith(true)
})
})

describe('_onLoadedMetadata callback', () => {
test('calls _ready method', () => {
const playback = new HTML5Video({ src: '/test/fixtures/SampleVideo_360x240_1mb.mp4' })
jest.spyOn(playback, '_ready')
playback.el.dispatchEvent(new Event('loadedmetadata'))

expect(playback._ready).toHaveBeenCalledTimes(1)
})
})
})