screen-capture.mdx 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. ---
  2. sidebar_position: 2
  3. slug: /screen-capture
  4. ---
  5. import Tabs from '@theme/Tabs';
  6. import TabItem from '@theme/TabItem';
  7. import UppyCdnExample from '/src/components/UppyCdnExample';
  8. # Screen capture
  9. The `@uppy/screen-capture` plugin can record your screen or an application and
  10. save it as a video.
  11. :::tip
  12. [Try out the live example](/examples) or take it for a spin in
  13. [CodeSandbox](https://codesandbox.io/s/uppy-dashboard-xpxuhd).
  14. :::
  15. ## When should I use this?
  16. When you want users record their screen on their computer. This plugin only
  17. works on desktop browsers which support
  18. [`getDisplayMedia API`](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getDisplayMedia).
  19. If no support for the API is detected, Screen Capture won’t be installed, so you
  20. don’t have to do anything.
  21. :::note
  22. To use the screen capture plugin in a Chromium-based browser,
  23. [your site must be served over https](https://developers.google.com/web/updates/2015/10/chrome-47-webrtc#public_service_announcements).
  24. This restriction does not apply on `localhost`, so you don’t have to jump
  25. through many hoops during development.
  26. :::
  27. ## Install
  28. <Tabs>
  29. <TabItem value="npm" label="NPM" default>
  30. ```shell
  31. npm install @uppy/screen-capture
  32. ```
  33. </TabItem>
  34. <TabItem value="yarn" label="Yarn">
  35. ```shell
  36. yarn add @uppy/screen-capture
  37. ```
  38. </TabItem>
  39. <TabItem value="cdn" label="CDN">
  40. <UppyCdnExample>
  41. {`
  42. import { Uppy, Dashboard, ScreenCapture } from "{{UPPY_JS_URL}}"
  43. const uppy = new Uppy()
  44. uppy.use(Dashboard, { inline: true, target: 'body' })
  45. uppy.use(ScreenCapture, { target: Uppy.Dashboard })
  46. `}
  47. </UppyCdnExample>
  48. </TabItem>
  49. </Tabs>
  50. ## Use
  51. ```js {3,7,11} showLineNumbers
  52. import Uppy from '@uppy/core';
  53. import Dashboard from '@uppy/dashboard';
  54. import ScreenCapture from '@uppy/screen-capture';
  55. import '@uppy/core/dist/style.min.css';
  56. import '@uppy/dashboard/dist/style.min.css';
  57. import '@uppy/screen-capture/dist/style.min.css';
  58. new Uppy()
  59. .use(Dashboard, { inline: true, target: 'body' })
  60. .use(ScreenCapture, { target: Dashboard });
  61. ```
  62. ### API
  63. ### Options
  64. #### `id`
  65. A unique identifier for this plugin (`string`, default: `'ScreenCapture'`).
  66. #### `title`
  67. Configures the title / name shown in the UI, for instance, on Dashboard tabs
  68. (`string`, default: `'Screen Capture'`).
  69. #### `target`
  70. DOM element, CSS selector, or plugin to place the screen capture into (`string`
  71. or `Element`, default: `null`).
  72. #### `displayMediaConstraints`
  73. Options passed to
  74. [`MediaDevices.getDisplayMedia()`](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getDisplayMedia)
  75. (`Object`, default: `null`).
  76. See the
  77. [`MediaTrackConstraints`](https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints)
  78. for a list of options.
  79. #### `userMediaConstraints`
  80. Options passed to
  81. [`MediaDevices.getUserMedia()`](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia)
  82. (`Object`, default: `null`).
  83. See the
  84. [`MediaTrackConstraints`](https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints)
  85. for a list of options.
  86. #### `preferredVideoMimeType`
  87. Set the preferred mime type for video recordings, for example `'video/webm'`
  88. (`string`, default: `null`).
  89. If the browser supports the given mime type, the video will be recorded in this
  90. format. If the browser does not support it, it will use the browser default.
  91. If no preferred video mime type is given, the ScreenCapture plugin will prefer
  92. types listed in the [`allowedFileTypes` restriction](/docs/uppy/#restrictions),
  93. if any.
  94. #### `locale`
  95. ```js
  96. export default {
  97. strings: {
  98. startCapturing: 'Begin screen capturing',
  99. stopCapturing: 'Stop screen capturing',
  100. submitRecordedFile: 'Submit recorded file',
  101. streamActive: 'Stream active',
  102. streamPassive: 'Stream passive',
  103. micDisabled: 'Microphone access denied by user',
  104. recording: 'Recording',
  105. },
  106. };
  107. ```