1.6.13 • Published 4 years ago

griffith-message-justcome v1.6.13

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

griffith-message

English | 简体中文

Griffith message communication plugin

Usage

import {EVENTS, ACTIONS, createMessageHelper} from 'griffith-message'

createMessageHelper

Cross-window communication

const {subscribeMessage, dispatchMessage} = createMessageHelper(
  id,
  targetOrigin,
  validateId
)
NameTypeDescription
idstring \| numberUnique identifier, each message will contain this id, the receiver can be used to verify.
targetOriginobjectThe targetOrigin parameter when sending a message. If it is not empty, it will check if the origin of the sent message is the same.
validateIdbooleanWill check if the id of the incoming message is the same as the id of the first parameter.

subscribeMessage

const subscription = subscribeMessage((messageName, data, sourceWindow) => {
  // do something
})

subscription.unsubscribe()
NameTypeDescription
messageNamestringMessage Name
dataobjectMessage attached data
sourceWindowMessageEventSourceMessage Event Source

dispatchMessage

dispatchMessage(targetWindow, messageName, data)
NameTypeDescription
targetWindowWindowTarget Window
messageNamestringMessage Name
dataobjectMessage attached data

EVENTS

Events received from the player

messageNameDescriptiondata
EVENTS.DOM.PLAYPlaysee DOM type data table
EVENTS.DOM.PLAYINGResume playback from pause or buffersee DOM type data table
EVENTS.DOM.PAUSEPausesee DOM type data table
EVENTS.DOM.ENDEDEndedsee DOM type data table
EVENTS.DOM.TIMEUPDATETimeupdatesee DOM type data table
EVENTS.DOM.ERRORErrorsee DOM type data table
EVENTS.DOM.WAITINGBuffersee DOM type data table
EVENTS.PLAYER.REQUEST_PLAYUser starts playbacknull
EVENTS.PLAYER.QUALITY_CHANGEPlay quality switching{quality: string, prevQuality: string}
EVENTS.PLAYER.PLAY_COUNTPlaybacknull
EVENTS.PLAYER.PLAY_FAILEDPlay failed{currentTime: number}
EVENTS.PLAYER.ENTER_FULLSCREENEnter fullScreennull
EVENTS.PLAYER.EXIT_FULLSCREENExit fullscreennull

DOM type data

NameTypeDescription
currentTimenumberCurrent time
durationnumberTotal video duration
error{code: number, message: string, name: stirng} or nullHTMLMediaElement.error

ACTIONS

Event sent to the player

messageNameDescriptiondataStatus
ACTIONS.PLAYER.PLAYPlay{applyOnFullScreen: boolean} Applied to full screen videoTODO
ACTIONS.PLAYER.PAUSEPauseApplied to full screen videoSUPPORTED
ACTIONS.PLAYER.SET_VOLUMESet the volume{volume: number} Volume value from 0 to 1TODO
ACTIONS.PLAYER.ENTER_FULLSCREENEnter fullScreennullTODO
ACTIONS.PLAYER.EXIT_FULLSCREENExit fullscreennullTODO