Suggestion with JS system architecture

Asked

Viewed 58 times

0

Hello, all good?

Currently I have a system made in AS2 that has the functionality to run videos and images. It works with a concept similar to finite state machine.

How is the code done? It runs inside an enterframe, running various things every "pass" of the loop, validating whether the video is ending, etc.

With the "death" of Flash and other issues, we need to migrate (basically create from 0) this system to JS, however, I can’t think of an architecture that can do this.

Using something like setInterval everywhere in the code doesn’t seem like an elegant solution at all. How can I have multiple tasks being performed multiple times?

In general, what my application has to do is analyze all the time if there is something to do, is run a download, display a video, etc..

Well, I hope I have made my doubt clear. Thanks in advance.

Edit: The project will be a video player. While playing, I need to keep doing other tasks.

How does this work today? I have a C project that controls all hardware, displays videos, and manages download.

My need is now to have a JS project that from time to time runs routines, such as see if there is something new to download from the server, have a video display and during this, analyze if it is to end, etc.

What I don’t know how to do is how to create this cycle of tasks, like how to do it, you did my tasks every X period. In FLASH we use Onenterframe, only it consumes a lot of performance since it will always run the whole code and validate if it is time to do some task.

  • Talk more about your business need because it’s not very clear what you need.

  • Okay, I added some more information.

  • 1

    The exit is the setInterval() even. setInterval() and setTimeout() are the only ways to execute parallel processes in Javascript. As for the player you can use HTML5. The HTML5 Javascript API is very broad and allows a series of checks on the execution of the media.

  • These setInterval and setTimeout they have some absurd memory consumption or even memory Leak? Is the implementation of these resources made by Angularjs better, worse or the same? I’m doing tests, initially using this setInterval same, with Angularjs, but I’m afraid to choose wrong paths.. Good, thanks in advance for your attention

  • I don’t know the implications of using Angular, but the performance is reasonable. If you don’t have many parallel processes and the interval isn’t too small the impact is almost imperceptible. I’ve never heard of Javascript Leak.

  • I would have a setInterval analyzing only the video displayed, with a maximum interval of 1s and another for other operations

  • 1

    Tranquil. Up to 300ms is practically flawless the change in performance, as long as it does not alter too much the DOM or CSSOM, provoking a very large redesign of the screen.

  • Got it.. friend, thank you so much for your tips! Regarding DOM and CSSOM (I will still research to know what it is), I will follow your advice. Thank you so much for your help!

Show 3 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.