@ioiotv/io-react
Advanced tools
Comparing version 0.2.2 to 1.0.0
{ | ||
"name": "@ioiotv/io-react", | ||
"version": "0.2.2", | ||
"version": "1.0.0", | ||
"description": "Player for ioio.tv services", | ||
@@ -5,0 +5,0 @@ "keywords": [], |
@@ -17,3 +17,3 @@ import { findDOMNode } from "react-dom" | ||
let Icon; // Themes Icons library | ||
let Icon, STAGE; // Themes Icons library | ||
@@ -34,19 +34,2 @@ | ||
const | ||
STAGE = { | ||
'WAITING_EPG' : 0 | ||
, 'EPG' : 1 | ||
, 'WAITING_CHANNEL' : 2 | ||
, 'CHANNEL_START' : 3 | ||
, 'CHANNEL_PLAY' : 4 | ||
, 'CHANNEL_PAUSED' : 5 | ||
, 'CHANNEL_ERROR' : 6 // internalState.brokenChannel is used at the moment (At the moment no render needed). | ||
, 'FULLSCREEN' : 7 | ||
, 'INFO' : 8 | ||
} | ||
; | ||
class IoReact extends React.PureComponent { | ||
@@ -60,2 +43,3 @@ | ||
Icon = deps.Icon | ||
STAGE = deps.STAGE | ||
ioServices.setup ( Config ) | ||
@@ -231,8 +215,18 @@ config.set ( Config ) | ||
me = this | ||
, { eBus } = me.dependencies | ||
, { eBus,STAGE } = me.dependencies | ||
; | ||
return { | ||
// Remote control on player | ||
pushPlay : () => me.setState ({ playing:true }) | ||
, pushPause : () => me.setState ({ playing: false }) | ||
pushPlay : fn => { | ||
if ( me.state.render !== STAGE.CHANNEL_PAUSED ) return | ||
if ( typeof fn === 'function' ) eBus.once ( 'playing', () => fn () ) | ||
me.setState ({ | ||
playing:true | ||
, render : STAGE.CHANNEL_PLAY | ||
}) | ||
} | ||
, pushPause : () => me.setState ({ | ||
playing: false | ||
, render : STAGE.CHANNEL_PAUSED | ||
}) | ||
, pushGuide : () => me.toggleOverlay () | ||
@@ -247,2 +241,4 @@ , pushFullscreen : () => me.onClickFullscreen(this)() | ||
, muted : () => me.state.muted | ||
, info : () => me.state.render === STAGE.INFO | ||
, guide : () => me.state.render === STAGE.EPG | ||
, fullscreen : () => me.state.render === STAGE.FULLSCREEN | ||
@@ -254,5 +250,21 @@ , volume : () => me.state.volume | ||
, setVolume : v => me.setState ({ volume:v }) | ||
, setUrl : url => { | ||
me.setState ({url}) | ||
} | ||
, setUrl : (url,fn) => { | ||
if ( typeof fn === 'function' ) eBus.once ( 'playing', () => fn() ) | ||
if ( me.captionTrack ) me.captionTrack.mode = 'hidden' | ||
me.update ({ | ||
nowPlayingTitle: null | ||
, nowPlayingChannelTitle: channel.name | ||
, nowPlayingChannelId: channel.guid | ||
, withLoader : true | ||
}) | ||
me.setState ({ | ||
url | ||
, render : STAGE.CHANNEL_START | ||
, played: 0 | ||
, loaded: 0 | ||
, pip: false | ||
, playing: true | ||
, captionsActive : false | ||
}) | ||
} // setUrl func. | ||
@@ -265,2 +277,3 @@ // Listen for ... | ||
// ioio.tv API data | ||
, refresh : () => this.loadChannelsSchedules () | ||
, channels : () => me.internalState.channels | ||
@@ -299,7 +312,7 @@ , epg : () => me.internalState.channelsListings | ||
const | ||
dayInMs = config.get ( 'dayInMs') | ||
, beforeNowLoadedMs = config.get ( 'beforeNowLoadedMs') | ||
, loadedPeriodInMs = dayInMs + beforeNowLoadedMs // 30 hours | ||
, startLoadTime = this.getStartStampWithMsAdjusted(beforeNowLoadedMs) | ||
, endLoadTime = this.getEndStampWithMsAdjusted(dayInMs) | ||
timeRequest = config.get ( 'epgRequestTime') | ||
, timePrefix = config.get ( 'epgRequestTimePrefix') | ||
, loadedPeriodInMs = timeRequest + timePrefix // 26 hours | ||
, startLoadTime = this.getStartStampWithMsAdjusted ( timePrefix ) | ||
, endLoadTime = this.getEndStampWithMsAdjusted ( timeRequest ) | ||
, dependencies = { startLoadTime, endLoadTime } | ||
@@ -458,3 +471,9 @@ ; | ||
onDuration = duration => this.update ({ duration }) | ||
onPlay = () => { | ||
const { eBus } = this.dependencies; | ||
eBus.emit ( 'playing' ) | ||
} | ||
@@ -464,2 +483,3 @@ | ||
onSeekMouseUp = e => { | ||
@@ -789,2 +809,3 @@ this.setState ({ seeking: false }) | ||
onEnded={this.onEnded} | ||
onPlay={this.onPlay} | ||
onError={e => this.onError(this,e) } | ||
@@ -791,0 +812,0 @@ onDuration={this.onDuration} |
@@ -13,6 +13,6 @@ function getDefaultDependencies () { | ||
, timeout: 3000 | ||
, dayInMs: 86400000 // 24 hours | ||
, beforeNowLoadedMs: 7200000 // 2 hours | ||
, epg : true | ||
, epgRequestTime : 86400000 // 24 hours in ms | ||
, epgRequestTimePrefix: 7200000 // 2 hours in ms | ||
, epgTimelineControls : false | ||
@@ -19,0 +19,0 @@ , epgTimelineHours : false |
@@ -9,2 +9,17 @@ import React from "react" | ||
const STAGE = { // io-react player stages | ||
'WAITING_EPG' : 0 | ||
, 'EPG' : 1 | ||
, 'WAITING_CHANNEL' : 2 | ||
, 'CHANNEL_START' : 3 | ||
, 'CHANNEL_PLAY' : 4 | ||
, 'CHANNEL_PAUSED' : 5 | ||
, 'CHANNEL_ERROR' : 6 // internalState.brokenChannel is used at the moment (At the moment no render needed). | ||
, 'FULLSCREEN' : 7 | ||
, 'INFO' : 8 | ||
} | ||
; | ||
function init ( dependencies ) { | ||
@@ -15,3 +30,3 @@ let | ||
, eBus = new EventEmitter () | ||
, App = reactApp ({ ...dependencies, eBus }) // { eBus, Config, Icon } | ||
, App = reactApp ({ ...dependencies, eBus, STAGE }) // { eBus, Config, Icon } | ||
, task = new Promise ( (resolve,reject) => eBus.on ( 'startIoReact', API => resolve(API) )) | ||
@@ -33,8 +48,14 @@ ; | ||
const states={}; // TODO: take it from IoReact component | ||
const API = { | ||
getDefaultDependencies // Returns ready to use dependencies object { Config, Icon } | ||
, states // | ||
, init // Will start new instance of ioPlayer and will return an API to control it | ||
} | ||
const | ||
states = () => Object.assign ( {}, STAGE ) | ||
, API = { | ||
getDefaultDependencies // Returns ready to use dependencies object { Config, Icon } | ||
, states // Returns io-react player states | ||
, init // Will start new instance of ioPlayer and will return an API to control it | ||
} | ||
; | ||
@@ -41,0 +62,0 @@ |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
716147
2603
2