-
Notifications
You must be signed in to change notification settings - Fork 38
Notify parent frame about kernel status #117
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
Changes from 3 commits
be40f7a
3127b65
9c21668
147b97b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -260,8 +260,15 @@ | |||||||
| // Add a watcher so that when we are connected we can set the resolution from query params | ||||||||
| @Watch('connected', { immediate: true }) | ||||||||
| onConnected(value: boolean) { | ||||||||
| if (value) { | ||||||||
| this.applyQueryResolution() | ||||||||
| try { | ||||||||
| if (value) { | ||||||||
| this.applyQueryResolution() | ||||||||
| if (window.parent !== window) { | ||||||||
| window.parent.postMessage({ type: 'KERNEL_CONNECTED', connected: true }, '*') | ||||||||
| } | ||||||||
| } | ||||||||
| } catch (e) { | ||||||||
| console.error('Failed to post message to parent', e) | ||||||||
|
||||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
|
|
@@ -326,5 +333,26 @@ | |||||||
| get connected() { | ||||||||
| return this.$accessor.connected | ||||||||
| } | ||||||||
|
|
||||||||
| get playing() { | ||||||||
| return this.$accessor.video.playing | ||||||||
| } | ||||||||
|
|
||||||||
| @Watch('playing') | ||||||||
| onPlaying(value: boolean) { | ||||||||
| try { | ||||||||
| if (window.parent === window) return | ||||||||
|
|
||||||||
| if (value) { | ||||||||
| window.parent.postMessage({ type: 'KERNEL_PLAYING', playing: true }, '*') | ||||||||
|
||||||||
| window.parent.postMessage({ type: 'KERNEL_PLAYING', playing: true }, '*') | |
| const parentOrigin = document.referrer ? new URL(document.referrer).origin : '*' | |
| window.parent.postMessage({ type: 'KERNEL_PLAYING', playing: true }, parentOrigin) |
Outdated
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.
Same targetOrigin point for the paused case:
| window.parent.postMessage({ type: 'KERNEL_PAUSED', playing: false }, '*') | |
| const parentOrigin = document.referrer ? new URL(document.referrer).origin : '*' | |
| window.parent.postMessage({ type: 'KERNEL_PAUSED', playing: false }, parentOrigin) |
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.
Minor: the
try/catchcurrently wrapsapplyQueryResolution()too, so the error message can be misleading (and it can swallow a real resolution bug).