Has anyone used soundjs within a node webkit application using local mp3 files?
Can it be done? If so I will keep researching.
I have test apps that work through a browser (Chrome) playing my MP3 library with it but I cannot update my local library within javascript in an HTML5 page in my browser. As browsers block that.
So to get persistence I moved to a local app with node webkit and can do everything I want except successfully install soundjs.
Can it be done? If so I will keep researching.
The soundjs I am talking about is the one at http://createjs.com/Docs/SoundJS/modules/CreateJS.html
not the soundjs you install with npm. That is a module to access Soundcloud.
PS this is hobby fun stuff not real world stuff.
PPS I am working on Windows 8.1 just to make it harder!
Related
Chromium takes too long to get compiled, like 7 hours on a regular powerful desktop. I'm thinking of some where to get a pre-built Chromium, with which I will be able to compile again only some files to re-link to make a new Chromium binary.
Possible to compile just some source code files and re-link (re-link object files)?
It's hard to build Chromium from source but it's every easy to build a new browser based on Chromium.
With GitHub Electron, any app based on it is a real Chromium browser, and developers may create custom UI for their Electron-based browsers.
However, modern browsers would require having servers for storing users' sync data, this might not be easily affordable for 1-man development army to create a new browser for the mass.
Electron app is a pack of Chromium sandbox, and Node.js backend, the 2 communicate thru' IPC as Node.js will be able to access all resources.
GitHub Electron:
https://electronjs.org
Environment
I am using Chromium 78.0.3904.108 Built on Raspbian running on Raspbian 10 on a Raspberry 3b+.
I am opening up a bundled VueJs app via file:// protocol directly in the browser. The app files are locally available on the machine. Until now everything works as expected. The app displays and works fine !
Problem
The website files contain a html <video> tag to play mp4 video files, which are locally available as well. However, a console error is telling me Not allowed to load local resource: file:///home/path/to/the/video/file/abc.mp4
I am very aware of this issue, it's an inbuilt security feature of the browser. However, the machine will only load content owned by me, so I guess I should be safe ignoring the warning.
Expected behaviour
By passing --allow-file-access-from-files to chromium-browser I expected it would disable this security feature. Doesn't work. I tried --disable-web-security as well. Same result.
I tested the same vue app bundled into an electron executable and having the electron option "webSecurity" set to false, the content is able to play without the warning. However, since the playback performance in electron is notable lower than compared the chromium-browser directly, I was trying to use the browser directly.
first, the "facts" that I know:
reactJS is frontend framework, after compiling it'll generate a bundle of html/js/css files that can be recognized by modern browsers, so the browser straightforward request the web host server for these static html files ;
nodeJS is a server-side environment, or sometimes people call it a backend framework, browsers don't understand nodeJS but have to request the web host server to interpret it and to send back the html response.
according to wiki, npm is a package manager for the JavaScript programming language. It is the default package manager for the JavaScript runtime environment Node.js.
my question is:
is my understanding correct
why reactJS also using npm and includes node_module, does it have something to do with nodeJS
Javascript is the programming language used in both Node.js and in the browser, but that's about as far as the similarities goes. Node uses the V8 engine, which is the same running in the chrome browser.
Even though they use the same engine, they are quite different. They both have plenty of APIs - most notably, the browser has the DOM (which allows you to render stuff to the screen). In Node.js you do not have the DOM, but there are other APIs, for accessing the filesystem for instance.
Since both are running JavaScript, you can try to run the same program both in node and in the browser, but it will sometimes fail. React is a front-end framework which uses the DOM, so if you try to run React in node, it will crash because in Node there is no DOM (Node has no screen to render to). If you try to run a program suited for Node.js in the browser, it will crash if it uses some Node-specific API.
The confusing bit is that npm is a package manager for JavaScript, not necessarily node (even though node is in the name..). Therefore, we can use npm also for web applications. (If we do, we need to use a bundler like webpack though).
Some npm modules might work both in the browser and in node, but some will only work on one of them. If the npm module requires some platform-spcific API (DOM for the browser for example) then it will not work for the other platform.
Hope that clears things out! I understand that it's a bit of a mess..
I would like to create an electron app that can do some web automation based on user input into a GUI. In my research it seems my two best bets are Phantom and Selenium+Chromedriver.
The thing I'd like to do is have an app that someone else could download and run without any additional setup. It seems with Chromedriver and Phantom that I'd need to have others download and add these things to their PATH. In order to get things functioning.
Is there a way around this? Or is there another approach I should be taking? Any advice is appreciated. Thanks!
First off, you should have a look at Nightmare.js which is like PhantomJS in many ways, but uses Electron under the hood (and that's good, because Chromium in Electron is very fresh compared to PhantomJS engine).
If you still want to use PhantomJS in Electron that's quite fine too. You may bundle it with your application or install npm module as a dependency and require that in your script. The main thing is - PhantomJS will be installed together with your app and you know the path to that folder.
I have a nodejs app with modules, views etc..
Is it possible to open this app with node-webkit instead of opening it in the browser ?
Thanks.
Yes, it is. Node-WebKit is a package with browser + node web server. But I believe you will probably want to change your architecture, because you don't need the client-server style. If you run your app without any changes, node-WebKit will act just like node server and you still need a browser to access the app. There is no reason to use node-WebKit instead of pure node in this case.
To use node-WebKit embedded browser you should know that there are no need to start node server. The browser's JavaScript environment is already connected to node and you can execute node commands and packages direct from the JavaScript files (eg.: access file system from the browser, a dream to every web developer). It's like you are running a browser inside the server, without the need of make requests and receive responses... For this reason you don't need to use packages as socket.io, cause the communication is already established. But you can use the fact of node is a server to easily establish communication between different machines, for example.