UNPKG

@polygonjs/polygonjs

Version:

node-based WebGL 3D engine https://polygonjs.com

82 lines (81 loc) 2.5 kB
"use strict"; import { dummyReadRefVal } from "../../core/reactivity/CoreReactivity"; import { VIDEO_EVENTS } from "../../core/VideoEvent"; import { NodeContext } from "../poly/NodeContext"; import { CopType } from "../poly/registers/nodes/types/Cop"; import { NamedFunction1, NamedFunction3 } from "./_Base"; function _getVideoNode(scene, nodePath) { const node = scene.node(nodePath); if (!node) { return; } if (node.context() != NodeContext.COP) { return; } if (node.type() != CopType.VIDEO) { return; } const videoNode = node; return videoNode; } export class addVideoEventListener extends NamedFunction3 { static type() { return "addVideoEventListener"; } func(nodePath, listeners, evaluator) { const videoNode = _getVideoNode(this.scene, nodePath); if (!videoNode) { return; } for (let eventName of VIDEO_EVENTS) { const listener = listeners[eventName]; videoNode.addEventListener(eventName, listener); } evaluator.onDispose(() => { for (let eventName of VIDEO_EVENTS) { const listener = listeners[eventName]; videoNode.removeEventListener(eventName, listener); } }); } } export class getVideoPropertyCurrentTime extends NamedFunction1 { static type() { return "getVideoPropertyCurrentTime"; } func(nodePath) { var _a; dummyReadRefVal(this.timeController.timeUniform().value); return ((_a = _getVideoNode(this.scene, nodePath)) == null ? void 0 : _a.videoCurrentTime()) || 0; } } export class getVideoPropertyDuration extends NamedFunction1 { static type() { return "getVideoPropertyDuration"; } func(nodePath) { var _a; dummyReadRefVal(this.timeController.timeUniform().value); return ((_a = _getVideoNode(this.scene, nodePath)) == null ? void 0 : _a.videoDuration()) || 0; } } export class getVideoPropertyPlaying extends NamedFunction1 { static type() { return "getVideoPropertyPlaying"; } func(nodePath) { var _a; dummyReadRefVal(this.timeController.timeUniform().value); return ((_a = _getVideoNode(this.scene, nodePath)) == null ? void 0 : _a.videoStatePlaying()) || false; } } export class getVideoPropertyMuted extends NamedFunction1 { static type() { return "getVideoPropertyMuted"; } func(nodePath) { var _a; dummyReadRefVal(this.timeController.timeUniform().value); return ((_a = _getVideoNode(this.scene, nodePath)) == null ? void 0 : _a.videoStateMuted()) || false; } }