You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

StartLiveStreamDialog.native.js 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. // @flow
  2. import React from 'react';
  3. import { View } from 'react-native';
  4. import { connect } from 'react-redux';
  5. import { translate } from '../../../base/i18n';
  6. import { setLiveStreamKey } from '../../actions';
  7. import AbstractStartLiveStreamDialog, {
  8. _mapStateToProps,
  9. type Props
  10. } from './AbstractStartLiveStreamDialog';
  11. import StreamKeyForm from './StreamKeyForm';
  12. /**
  13. * A React Component for requesting a YouTube stream key to use for live
  14. * streaming of the current conference.
  15. */
  16. class StartLiveStreamDialog extends AbstractStartLiveStreamDialog {
  17. /**
  18. * Constructor of the component.
  19. *
  20. * @inheritdoc
  21. */
  22. constructor(props: Props) {
  23. super(props);
  24. // Bind event handlers so they are only bound once per instance.
  25. this._onInitializeGoogleApi = this._onInitializeGoogleApi.bind(this);
  26. this._onStreamKeyChangeNative
  27. = this._onStreamKeyChangeNative.bind(this);
  28. this._renderDialogContent = this._renderDialogContent.bind(this);
  29. }
  30. _onInitializeGoogleApi: () => Promise<*>
  31. /**
  32. * Loads the Google client application used for fetching stream keys.
  33. * If the user is already logged in, then a request for available YouTube
  34. * broadcasts is also made.
  35. *
  36. * @private
  37. * @returns {Promise}
  38. */
  39. _onInitializeGoogleApi() {
  40. // This is a placeholder method for the Google feature.
  41. return Promise.resolve();
  42. }
  43. _onStreamKeyChange: string => void
  44. _onStreamKeyChangeNative: string => void;
  45. /**
  46. * Callback to handle stream key changes.
  47. *
  48. * FIXME: This is a temporary method to store the streaming key on mobile
  49. * for easier use, until the Google sign-in is implemented. We don't store
  50. * the key on web for security reasons (e.g. we don't want to have the key
  51. * stored if the used signed out).
  52. *
  53. * @private
  54. * @param {string} streamKey - The new key value.
  55. * @returns {void}
  56. */
  57. _onStreamKeyChangeNative(streamKey) {
  58. this.props.dispatch(setLiveStreamKey(streamKey));
  59. this._onStreamKeyChange(streamKey);
  60. }
  61. _renderDialogContent: () => React$Component<*>
  62. /**
  63. * Renders the platform specific dialog content.
  64. *
  65. * @returns {React$Component}
  66. */
  67. _renderDialogContent() {
  68. return (
  69. <View>
  70. <StreamKeyForm
  71. onChange = { this._onStreamKeyChangeNative }
  72. value = { this.props._streamKey } />
  73. </View>
  74. );
  75. }
  76. }
  77. export default translate(connect(_mapStateToProps)(StartLiveStreamDialog));