Skip to content

Commit

Permalink
feat: add SUBSCRIPTION_READY event
Browse files Browse the repository at this point in the history
fix: event in messageProvider
  • Loading branch information
zhangyue04 authored and ambar committed Sep 1, 2021
1 parent ec4a259 commit 53d28d4
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 31 deletions.
43 changes: 22 additions & 21 deletions packages/griffith-message/README-zh-Hans.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,27 +62,28 @@ dispatchMessage(targetWindow, messageName, data)

从播放器接收到的事件

| `messageName` | 说明 | `data` |
| ---------------------------------- | ---------------------- | ------------------------------------------------ |
| `EVENTS.DOM.PLAY` | 播放 | 见下表 |
| `EVENTS.DOM.PLAYING` | 从暂停或缓冲中恢复播放 | 见下表 |
| `EVENTS.DOM.PAUSE` | 暂停 | 见下表 |
| `EVENTS.DOM.ENDED` | 停止 | 见下表 |
| `EVENTS.DOM.TIMEUPDATE` | 进度更新 | 见下表 |
| `EVENTS.DOM.ERROR` | 错误 | 见下表 |
| `EVENTS.DOM.WAITING` | 缓冲 | 见下表 |
| `EVENTS.PLAYER.REQUEST_PLAY` | 用户触发播放 ||
| `EVENTS.PLAYER.QUALITY_CHANGE` | 清晰度切换 | `{quality: string, prevQuality: string}` |
| `EVENTS.PLAYER.PLAY_COUNT` | 播放一次 ||
| `EVENTS.PLAYER.PLAY_FAILED` | 播放失败 | `{currentTime: number}` |
| `EVENTS.PLAYER.ENTER_FULLSCREEN` | 进入全屏 ||
| `EVENTS.PLAYER.EXIT_FULLSCREEN` | 退出全屏 ||
| `EVENTS.PLAYER.ENTER_PIP` | 进入画中画 ||
| `EVENTS.PLAYER.EXIT_PIP` | 退出画中画 ||
| `EVENTS.PLAYER.SHOW_CONTROLLER` | 显示播放器进度条控件 ||
| `EVENTS.PLAYER.HIDE_CONTROLLER` | 隐藏播放器进度条控件 ||
| `EVENTS.PLAYER.HOVER_PROGRESS_DOT` | 鼠标 hover 播放节点 | `{startTime: number, left: number, top: number}` |
| `EVENTS.PLAYER.LEAVE_PROGRESS_DOT` | 鼠标离开播放节点 ||
| `messageName` | 说明 | `data` |
| ---------------------------------- | ---------------------------------- | ------------------------------------------------ |
| `EVENTS.DOM.PLAY` | 播放 | 见下表 |
| `EVENTS.DOM.PLAYING` | 从暂停或缓冲中恢复播放 | 见下表 |
| `EVENTS.DOM.PAUSE` | 暂停 | 见下表 |
| `EVENTS.DOM.ENDED` | 停止 | 见下表 |
| `EVENTS.DOM.TIMEUPDATE` | 进度更新 | 见下表 |
| `EVENTS.DOM.ERROR` | 错误 | 见下表 |
| `EVENTS.DOM.WAITING` | 缓冲 | 见下表 |
| `EVENTS.PLAYER.REQUEST_PLAY` | 用户触发播放 ||
| `EVENTS.PLAYER.QUALITY_CHANGE` | 清晰度切换 | `{quality: string, prevQuality: string}` |
| `EVENTS.PLAYER.PLAY_COUNT` | 播放一次 ||
| `EVENTS.PLAYER.PLAY_FAILED` | 播放失败 | `{currentTime: number}` |
| `EVENTS.PLAYER.ENTER_FULLSCREEN` | 进入全屏 ||
| `EVENTS.PLAYER.EXIT_FULLSCREEN` | 退出全屏 ||
| `EVENTS.PLAYER.ENTER_PIP` | 进入画中画 ||
| `EVENTS.PLAYER.EXIT_PIP` | 退出画中画 ||
| `EVENTS.PLAYER.SHOW_CONTROLLER` | 显示播放器进度条控件 ||
| `EVENTS.PLAYER.HIDE_CONTROLLER` | 隐藏播放器进度条控件 ||
| `EVENTS.PLAYER.HOVER_PROGRESS_DOT` | 鼠标 hover 播放节点 | `{startTime: number, left: number, top: number}` |
| `EVENTS.PLAYER.LEAVE_PROGRESS_DOT` | 鼠标离开播放节点 ||
| `EVENTS.PLAYER.SUBSCRIPTION_READY` | 播放器事件注册完成,可监听 ACTIONS ||

#### DOM 类 data

Expand Down
19 changes: 10 additions & 9 deletions packages/griffith-message/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,13 @@ Events received from the player

Event sent to the player

| `messageName` | Description | `data` | Status |
| --------------------------------- | ---------------- | ----------------------------------------------------------- | --------- |
| `ACTIONS.PLAYER.PLAY` | Play | `{applyOnFullScreen: boolean}` Applied to full screen video | SUPPORTED |
| `ACTIONS.PLAYER.PAUSE` | Pause | Applied to full screen video | SUPPORTED |
| `ACTIONS.PLAYER.SET_VOLUME` | Set the volume | `{volume: number}` Volume value from 0 to 1 | SUPPORTED |
| `ACTIONS.PLAYER.ENTER_FULLSCREEN` | Enter fullScreen | null | SUPPORTED |
| `ACTIONS.PLAYER.EXIT_FULLSCREEN` | Exit fullscreen | null | SUPPORTED |
| `ACTIONS.PLAYER.TIME_UPDATE` | Set current time | `{currentTime: number} Set the currentTime` | SUPPORTED |
| `ACTIONS.PLAYER.SHOW_CONTROLLER` | Show Controller | null | SUPPORTED |
| `messageName` | Description | `data` | Status |
| ---------------------------------- | ------------------------- | ----------------------------------------------------------- | --------- |
| `ACTIONS.PLAYER.PLAY` | Play | `{applyOnFullScreen: boolean}` Applied to full screen video | SUPPORTED |
| `ACTIONS.PLAYER.PAUSE` | Pause | Applied to full screen video | SUPPORTED |
| `ACTIONS.PLAYER.SET_VOLUME` | Set the volume | `{volume: number}` Volume value from 0 to 1 | SUPPORTED |
| `ACTIONS.PLAYER.ENTER_FULLSCREEN` | Enter fullScreen | null | SUPPORTED |
| `ACTIONS.PLAYER.EXIT_FULLSCREEN` | Exit fullscreen | null | SUPPORTED |
| `ACTIONS.PLAYER.TIME_UPDATE` | Set current time | `{currentTime: number} Set the currentTime` | SUPPORTED |
| `ACTIONS.PLAYER.SHOW_CONTROLLER` | Show Controller | null | SUPPORTED |
| `EVENTS.PLAYER.SUBSCRIPTION_READY` | Action subscription ready | null |
1 change: 1 addition & 0 deletions packages/griffith-message/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ declare const EVENTS: {
HIDE_CONTROLLER: string
HOVER_PROGRESS_DOT: string
LEAVE_PROGRESS_DOT: string
SUBSCRIPTION_READY: string
}
}

Expand Down
1 change: 1 addition & 0 deletions packages/griffith-message/src/constants/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ export const PLAYER = {
HIDE_CONTROLLER: 'event/player/hide-controller',
HOVER_PROGRESS_DOT: 'event/player/hover-progress-dot',
LEAVE_PROGRESS_DOT: 'event/player/leave-progress-dot',
SUBSCRIPTION_READY: 'event/player/subscription-ready',
}
6 changes: 5 additions & 1 deletion packages/griffith/src/contexts/Message/MessageContext.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import PropTypes from 'prop-types'
import EventEmitter from 'eventemitter3'
import {createMessageHelper} from 'griffith-message'
import {EVENTS, createMessageHelper} from 'griffith-message'

const EVENT_TYPE = 'event'
const ACTION_TYPE = 'action'
Expand Down Expand Up @@ -47,6 +47,10 @@ export class MessageProvider extends React.PureComponent {
if (this.props.dispatchRef) {
this.props.dispatchRef.current = this.externalContextValue.dispatchAction
}

Promise.resolve().then(() =>
props.onEvent(EVENTS.PLAYER.SUBSCRIPTION_READY)
)
}

componentDidMount() {
Expand Down

0 comments on commit 53d28d4

Please sign in to comment.