import React, { Component } from 'react';
import { PropTypes } from 'prop-types';
import { requireNativeComponent, Platform, View } from 'react-native';

class EnxPlayerView extends Component {
  render() {
    return <ReactPlayer {...this.props} />;
  }
}

const viewPropTypes = View.propTypes;

EnxPlayerView.propTypes = {
  streamId: PropTypes.string.isRequired,
  isLocal: PropTypes.string.isRequired,
  isFrontCamera: PropTypes.bool,
  ...viewPropTypes,
};

EnxPlayerView.defaultProps = {
  isFrontCamera: true,
};

const playerName = Platform.OS === 'ios' ? 'EnxPlayerViewSwift' : 'EnxPlayerViewManager';
const ReactPlayer = requireNativeComponent(playerName, EnxPlayerView);

export default EnxPlayerView;
