react-jw-player
Advanced tools
Comparing version 1.17.0 to 1.18.0
@@ -6,2 +6,9 @@ 'use strict'; | ||
}); | ||
var _getEventNameFromProp = require('./get-event-name-from-prop'); | ||
var _getEventNameFromProp2 = _interopRequireDefault(_getEventNameFromProp); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function initialize(_ref) { | ||
@@ -18,21 +25,26 @@ var component = _ref.component, | ||
player.on('beforePlay', _onBeforePlay); | ||
player.on('ready', component.props.onReady); | ||
player.on('setupError', component.props.onSetupError); | ||
player.on('error', component.props.onError); | ||
player.on('adPlay', component.eventHandlers.onAdPlay); | ||
player.on('adPause', component.props.onAdPause); | ||
player.on('adSkipped', component.props.onAdSkipped); | ||
player.on('adComplete', component.props.onAdComplete); | ||
player.on('fullscreen', component.eventHandlers.onFullScreen); | ||
player.on('pause', component.props.onPause); | ||
player.on('play', component.eventHandlers.onPlay); | ||
player.on('mute', component.eventHandlers.onMute); | ||
player.on('playlistItem', component.eventHandlers.onVideoLoad); | ||
player.on('time', component.eventHandlers.onTime); | ||
player.on('beforeComplete', component.props.onOneHundredPercent); | ||
player.on('buffer', component.props.onBuffer); | ||
player.on('bufferChange', component.props.onBufferChange); | ||
var eventsToInitialize = {}; | ||
Object.keys(component.props).forEach(function (prop) { | ||
var eventName = (0, _getEventNameFromProp2.default)(prop); | ||
if (eventName) { | ||
eventsToInitialize[eventName] = component.props[prop]; | ||
} | ||
}); | ||
eventsToInitialize.adPlay = component.eventHandlers.onAdPlay; | ||
eventsToInitialize.beforeComplete = component.props.onOneHundredPercent; | ||
eventsToInitialize.beforePlay = _onBeforePlay; | ||
eventsToInitialize.fullscreen = component.eventHandlers.onFullScreen; | ||
eventsToInitialize.mute = component.eventHandlers.onMute; | ||
eventsToInitialize.play = component.eventHandlers.onPlay; | ||
eventsToInitialize.playlistItem = component.eventHandlers.onVideoLoad; | ||
eventsToInitialize.time = component.eventHandlers.onTime; | ||
Object.keys(eventsToInitialize).forEach(function (event) { | ||
player.on(event, eventsToInitialize[event]); | ||
}); | ||
} | ||
exports.default = initialize; |
{ | ||
"name": "react-jw-player", | ||
"version": "1.17.0", | ||
"version": "1.18.0", | ||
"description": "A React component for launching JW Player instances on the client.", | ||
@@ -5,0 +5,0 @@ "main": "dist/react-jw-player.js", |
@@ -13,3 +13,3 @@ # react-jw-player :movie_camera: [](https://travis-ci.com/micnews/react-jw-player) | ||
* [Configuration](#optional-configuration-props) | ||
* Event Hooks | ||
* [Event Hooks](#event-hooks) | ||
* [Advertising](#optional-advertising-event-hook-props) | ||
@@ -145,2 +145,12 @@ * [Player Events](#optional-player-event-hook-props) | ||
# Event Hooks | ||
`react-jw-player` dynamically supports all events in JW Player. Simply preface the event name with `on` and pass it in as a prop. | ||
Examples: | ||
* `ready` => `onReady` | ||
* `setupError` => `onSetupError` | ||
`react-jw-player` has layered some different functionality on some of these events, so please check the docs below if you find any unexpected behavior! | ||
## Optional Advertising Event Hook Props | ||
@@ -147,0 +157,0 @@ * `onAdPause(event)` |
34708
23
528
386