decord/source/components_native/common/NativePortalView.tsx

152 lines
4.8 KiB
TypeScript
Raw Normal View History

// Module ID: 8398
// Function ID: 8399
// Name: NativePortalView
// Dependencies: [19, 17, 21, 4638, 1364, 8399, 8400, 2]
2026-07-20 16:05:17 +00:00
// Exports: createPortalControls, isPortalExpired, markPortalAlive
// Module 8398 (NativePortalView)
import PortalViewNativeComponentDefault from "PortalViewNativeComponent" /* 8399 */;
import noop from "module_19" /* 19 */;
2026-07-23 10:11:24 +00:00
const require = fn;
get_ActivityIndicator = fn(17);
2026-07-29 08:29:29 +00:00
({ NativeModules, requireNativeComponent, NativeEventEmitter } = get_ActivityIndicator);
const jsx = fn(21).jsx;
const createStyles = fn(4638);
let closure_5 = createStyles.createStyles({ base: { overflow: "hidden" } });
const PlatformUtils = fn(1364);
if (PlatformUtils.isAndroid()) {
let importDefaultResult = PortalViewNativeComponentDefault;
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
importDefaultResult = requireNativeComponent("DCDPortalView");
2026-07-20 16:05:17 +00:00
}
const metroRequire = importDefaultResult;
2026-07-20 16:05:17 +00:00
const MediaPlayerManager = NativeModules.MediaPlayerManager;
const DCDPortalViewManager = NativeModules.DCDPortalViewManager;
const nativeEventEmitter = new NativeEventEmitter(MediaPlayerManager);
const set = new Set();
const size = fn(2);
const result = size.fileFinishedImporting("components_native/common/NativePortalView.tsx");
2026-07-23 10:11:24 +00:00
export default noop.memo((paused) => {
2026-07-29 08:29:29 +00:00
paused = paused.paused;
const muted = paused.muted;
const onLoad = paused.onLoad;
({ style, children } = paused);
const merged = Object.assign(paused, Object.assign({ style: 0, children: 0, paused: 0, muted: 0, onLoad: 0 }));
2026-07-29 08:29:29 +00:00
if (null != children) {
2026-07-20 16:05:17 +00:00
const _Error = Error;
const error = new Error("The <NativePortalView> component cannot contain children.");
2026-07-20 16:05:17 +00:00
throw error;
} else {
const items = [merged.portal, paused];
2026-07-23 10:11:24 +00:00
const layoutEffect = merged.useLayoutEffect(() => {
2026-07-20 16:05:17 +00:00
if (null != merged.portal) {
MediaPlayerManager.toggle(tmp.portal, !paused);
2026-07-20 16:05:17 +00:00
}
}, items);
const items1 = [merged.portal, muted];
2026-07-23 10:11:24 +00:00
const layoutEffect1 = merged.useLayoutEffect(() => {
2026-07-20 16:05:17 +00:00
if (null != merged.portal) {
MediaPlayerManager.setMuted(tmp.portal, muted);
2026-07-20 16:05:17 +00:00
}
}, items1);
const items2 = [onLoad, merged.portal];
2026-07-23 10:11:24 +00:00
const layoutEffect2 = merged.useLayoutEffect(() => {
2026-07-29 08:29:29 +00:00
if (!obj.isAndroid()) {
if (onLoad != null) {
onLoad();
}
2026-07-20 16:05:17 +00:00
}
MediaPlayerManager.setLoopPlayback(merged.portal, true);
2026-07-20 16:05:17 +00:00
return () => {
loopPlayback.setLoopPlayback(portal.portal, false);
2026-07-20 16:05:17 +00:00
if (obj.isAndroid()) {
muted(onLoad[6]).unregisterView(tmp.portal);
const obj2 = muted(onLoad[6]);
2026-07-20 16:05:17 +00:00
} else {
DCDPortalViewManager.unregisterView(tmp.portal);
2026-07-20 16:05:17 +00:00
}
set.add(portal.portal);
2026-07-20 16:05:17 +00:00
};
}, items2);
const items3 = [onLoad, merged.portal];
2026-07-29 08:29:29 +00:00
const callback = merged.useCallback((nativeEvent) => {
2026-07-20 16:05:17 +00:00
if (merged.portal === nativeEvent.nativeEvent.portal) {
2026-07-29 08:29:29 +00:00
if (onLoad != null) {
tmp();
2026-07-20 16:05:17 +00:00
}
}
}, items3);
let obj2 = {};
const obj = paused(onLoad[4]);
2026-07-29 08:29:29 +00:00
const merged1 = Object.assign(merged);
const items4 = [tmp2.base, style];
obj2.style = items4;
2026-07-29 08:29:29 +00:00
if (isAndroidResult) {
obj2.onPortalViewLoaded = callback;
let tmp17Result = tmp17(tmp18, obj2);
2026-07-20 16:05:17 +00:00
} else {
tmp17Result = tmp17(tmp18, obj2);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return tmp17Result;
2026-07-20 16:05:17 +00:00
}
});
2026-07-29 08:29:29 +00:00
export function createPortalControls(portal) {
2026-08-24 06:08:38 +00:00
closure_0 = portal;
2026-07-20 16:05:17 +00:00
return {
seek(arg0) {
MediaPlayerManager.changeProgress(closure_0, arg0);
2026-07-20 16:05:17 +00:00
},
pause(arg0) {
MediaPlayerManager.toggle(closure_0, !arg0);
2026-07-20 16:05:17 +00:00
},
useSubscribe(arg0, arg1, arg2) {
2026-08-24 06:08:38 +00:00
closure_1 = arg0;
closure_2 = arg1;
closure_3 = arg2;
2026-07-29 08:29:29 +00:00
const items = [closure_0, arg1, arg0, arg2];
const effect = noop.useEffect(() => {
2026-08-24 06:08:38 +00:00
closure_0 = closure_1_9.addListener("MediaPlayerProgress", (duration) => {
2026-07-29 08:29:29 +00:00
duration = duration.duration;
let tmp = duration.id === closure_0;
if (tmp) {
tmp = duration > 0;
}
if (tmp) {
closure_1(duration.time, duration);
2026-07-29 08:29:29 +00:00
}
});
2026-08-24 06:08:38 +00:00
closure_1 = closure_1_9.addListener("MediaPlayerDownloadProgress", (id) => {
2026-07-29 08:29:29 +00:00
let tmp2 = id.id === closure_0;
if (tmp2) {
tmp2 = tmp > 0;
}
if (tmp2) {
tmp2 = null != closure_1_3;
2026-07-29 08:29:29 +00:00
}
if (tmp2) {
closure_1_3(id.progressPercent);
2026-07-29 08:29:29 +00:00
}
});
2026-08-24 06:08:38 +00:00
closure_2 = closure_1_9.addListener("MediaPlayerPause", (id) => {
2026-07-29 08:29:29 +00:00
if (id.id === closure_0) {
closure_2(tmp);
2026-07-29 08:29:29 +00:00
}
});
return () => {
closure_0.remove();
closure_1.remove();
closure_2.remove();
2026-07-29 08:29:29 +00:00
};
}, items);
2026-07-20 16:05:17 +00:00
}
};
2026-07-29 08:29:29 +00:00
}
2026-07-20 16:05:17 +00:00
export const markPortalAlive = function markPortalAlive(portal) {
set.delete(portal);
};
export const isPortalExpired = function isPortalExpired(portal) {
return set.has(portal);
};