-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: added API to set media keys directly #61
Merged
Changes from 14 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
312b048
feat: added API to set media keys directly
3adb995
renamed method, merge options, added note
b93d9c2
added test, cleaned up reinit
1471c5f
added initDataType
fd383d9
review comments
4f1109d
added usage to readme
bd151fb
update tests
fc14190
typo
e79cdff
update comments
9c163e9
added chromium bug ticket note
68d5e2e
update readme
a28a2e9
undo plugin function change
619b03c
skip test in Safari
e97b895
add callback to API
771cc6b
remove comment
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,9 +37,23 @@ QUnit.module('videojs-contrib-eme', { | |
this.video = document.createElement('video'); | ||
this.fixture.appendChild(this.video); | ||
this.player = videojs(this.video); | ||
|
||
this.origRequestMediaKeySystemAccess = window.navigator.requestMediaKeySystemAccess; | ||
|
||
window.navigator.requestMediaKeySystemAccess = (keySystem, options) => { | ||
return Promise.resolve({ | ||
keySystem: 'org.w3.clearkey', | ||
createMediaKeys: () => { | ||
return { | ||
createSession: () => new videojs.EventTarget() | ||
}; | ||
} | ||
}); | ||
}; | ||
}, | ||
|
||
afterEach() { | ||
window.navigator.requestMediaKeySystemAccess = this.origRequestMediaKeySystemAccess; | ||
this.player.dispose(); | ||
this.clock.restore(); | ||
} | ||
|
@@ -82,6 +96,62 @@ QUnit.test('exposes options', function(assert) { | |
'exposes publisherId'); | ||
}); | ||
|
||
// skip test for Safari | ||
if (!window.WebKitMediaKeys) { | ||
QUnit.test('initializeMediaKeys standard', function(assert) { | ||
const done = assert.async(); | ||
const initData = new Uint8Array([1, 2, 3]).buffer; | ||
|
||
this.player.eme(); | ||
|
||
// testing the rejection path because this isn't a real session | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can delete this now! |
||
this.player.eme.initializeMediaKeys({ | ||
keySystems: { | ||
'org.w3.clearkey': { | ||
pssh: initData | ||
} | ||
} | ||
}, () => { | ||
const sessions = this.player.eme.sessions; | ||
|
||
assert.equal(sessions.length, 1, 'created a session when keySystems in options'); | ||
assert.deepEqual(sessions[0].initData, initData, 'captured initData in the session'); | ||
done(); | ||
}); | ||
}); | ||
} | ||
|
||
QUnit.test('initializeMediaKeys ms-prefix', function(assert) { | ||
const done = assert.async(); | ||
// stub setMediaKeys | ||
const setMediaKeys = this.player.tech_.el_.setMediaKeys; | ||
|
||
this.player.tech_.el_.setMediaKeys = null; | ||
this.player.tech_.el_.msSetMediaKeys = () => {}; | ||
|
||
const initData = new Uint8Array([1, 2, 3]).buffer; | ||
|
||
this.player.eme(); | ||
|
||
this.player.eme.initializeMediaKeys({ | ||
keySystems: { | ||
'com.microsoft.playready': { | ||
pssh: initData | ||
} | ||
} | ||
}, () => { | ||
const sessions = this.player.eme.sessions; | ||
|
||
assert.equal(sessions.length, 1, 'created a session when keySystems in options'); | ||
assert.deepEqual(sessions[0].initData, initData, 'captured initData in the session'); | ||
|
||
done(); | ||
}); | ||
|
||
this.player.tech_.el_.msSetMediaKeys = null; | ||
this.player.tech_.el_.setMediaKeys = setMediaKeys; | ||
}); | ||
|
||
QUnit.module('plugin guard functions', { | ||
beforeEach() { | ||
this.options = { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This worked for me:
to be clear, I'm trying to avoid an anonymous function being the plugin factory here