picture_in_picture.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // @ts-check
  2. export const PICTURE_IN_PICTURE_DEPLOY = 'PICTURE_IN_PICTURE_DEPLOY';
  3. export const PICTURE_IN_PICTURE_REMOVE = 'PICTURE_IN_PICTURE_REMOVE';
  4. /**
  5. * @typedef MediaProps
  6. * @property {string} src
  7. * @property {boolean} muted
  8. * @property {number} volume
  9. * @property {number} currentTime
  10. * @property {string} poster
  11. * @property {string} backgroundColor
  12. * @property {string} foregroundColor
  13. * @property {string} accentColor
  14. */
  15. /**
  16. * @param {string} statusId
  17. * @param {string} accountId
  18. * @param {string} playerType
  19. * @param {MediaProps} props
  20. * @returns {object}
  21. */
  22. export const deployPictureInPicture = (statusId, accountId, playerType, props) => {
  23. // @ts-expect-error
  24. return (dispatch, getState) => {
  25. // Do not open a player for a toot that does not exist
  26. if (getState().hasIn(['statuses', statusId])) {
  27. dispatch({
  28. type: PICTURE_IN_PICTURE_DEPLOY,
  29. statusId,
  30. accountId,
  31. playerType,
  32. props,
  33. });
  34. }
  35. };
  36. };
  37. /*
  38. * @return {object}
  39. */
  40. export const removePictureInPicture = () => ({
  41. type: PICTURE_IN_PICTURE_REMOVE,
  42. });