rtmp_video_capture_wrapper.js 908 B

12345678910111213141516171819202122232425262728
  1. ; (function (window) {
  2. var target = null;
  3. function initByIframeId(iframeId) {
  4. var iframe = window.document.getElementById(iframeId);
  5. if (!!iframe) {
  6. target = iframe.contentWindow.rtmpCapturer;
  7. var result = target.init("main_view");
  8. // 这里必须指定类型,不然dart callMethod返回结果都是JSObject
  9. return Array.from(result);
  10. } else {
  11. return [0, 0];
  12. }
  13. }
  14. window.rtmpCapturer = {
  15. init: initByIframeId,
  16. setClipSize: function (width, height) {
  17. target.setClipSize(width, height);
  18. },
  19. captureOne: async function () {
  20. var result = await target.captureOne();
  21. // 指定类型 Uint8Array
  22. return new Uint8Array(result);
  23. },
  24. release: function () {
  25. target.release();
  26. },
  27. };
  28. })(window);