12345678910111213141516171819202122232425262728 |
- ; (function (window) {
- var target = null;
- function initByIframeId(iframeId) {
- var iframe = window.document.getElementById(iframeId);
- if (!!iframe) {
- target = iframe.contentWindow.rtmpCapturer;
- var result = target.init("main_view");
- // 这里必须指定类型,不然dart callMethod返回结果都是JSObject
- return Array.from(result);
- } else {
- return [0, 0];
- }
- }
- window.rtmpCapturer = {
- init: initByIframeId,
- setClipSize: function (width, height) {
- target.setClipSize(width, height);
- },
- captureOne: async function () {
- var result = await target.captureOne();
- // 指定类型 Uint8Array
- return new Uint8Array(result);
- },
- release: function () {
- target.release();
- },
- };
- })(window);
|