combining both NEO Win and NEO Web? - Forum

Forum Navigation
You need to log in to create posts and topics.

combining both NEO Win and NEO Web?

Making a hybrid app that combines both NEO Win and NEO Web pubs as a single Windows desktop program?

Let's say you perform a function (like editing a video) with NEO Win, and you want the result to be automatically loaded into a Rectangle containing a NEO Web video player. But since NEO Web runs in a browser, it won't let JavaScript access the user's hardware (drives, etc.) without user intervention, which is usually a File Open prompt (and then the user might not select the correct file for your operation to complete.)

I found a solution for that - JavaScript injection.

Locate the line number with the filename you want to change in your NEO Web "./js/main.js" file.

and use this NEO Win Action:

FileWrite "[PubDir]bin\video-player-Web\js\main.js" "16" "$App.MP4name = [#34]c:/MyApp/output.mp4[#34];"

 

After FileWrite changes the desired filename, NEO Web will open the video automatically without any user intervention.

.............

If you know of an easier way, please let me know!

..

@fkapnist your solution should work but it's probably easier to write a separate file with your VisualNEO Web app options that's loaded at startup or whenever necessary. A simple JSON file will do the work:

{
  "appName": "MyApp",
  "appIcon": "https://example.com/icon.png",
  "appDescription": "This is a sample description of the app, highlighting its main features and purpose.",
  "videoURL": "c:/MyApp/output.mp4"
}

Then this file is loaded and parsed into your VisualNEO Web app to get every field value inside a variable.

fkapnist has reacted to this post.
fkapnist
Quote from luishp on September 10, 2024, 1:37 pm

@fkapnist your solution should work but it's probably easier to write a separate file with your VisualNEO Web app options that's loaded at startup or whenever necessary. A simple JSON file will do the work:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
{
"appName": "MyApp",
"appIcon": "https://example.com/icon.png",
"appDescription": "This is a sample description of the app, highlighting its main features and purpose.",
"videoURL": "c:/MyApp/output.mp4"
}
{ "appName": "MyApp", "appIcon": "https://example.com/icon.png", "appDescription": "This is a sample description of the app, highlighting its main features and purpose.", "videoURL": "c:/MyApp/output.mp4" }
{
  "appName": "MyApp",
  "appIcon": "https://example.com/icon.png",
  "appDescription": "This is a sample description of the app, highlighting its main features and purpose.",
  "videoURL": "c:/MyApp/output.mp4"
}

Then this file is loaded and parsed into your VisualNEO Web app to get every field value inside a variable.

 

Quote from luishp on September 10, 2024, 1:37 pm

@fkapnist your solution should work but it's probably easier to write a separate file with your VisualNEO Web app options that's loaded at startup or whenever necessary. A simple JSON file will do the work:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
{
"appName": "MyApp",
"appIcon": "https://example.com/icon.png",
"appDescription": "This is a sample description of the app, highlighting its main features and purpose.",
"videoURL": "c:/MyApp/output.mp4"
}
{ "appName": "MyApp", "appIcon": "https://example.com/icon.png", "appDescription": "This is a sample description of the app, highlighting its main features and purpose.", "videoURL": "c:/MyApp/output.mp4" }
{
  "appName": "MyApp",
  "appIcon": "https://example.com/icon.png",
  "appDescription": "This is a sample description of the app, highlighting its main features and purpose.",
  "videoURL": "c:/MyApp/output.mp4"
}

Then this file is loaded and parsed into your VisualNEO Web app to get every field value inside a variable.

@luishp So you can use the FileWrite action in NEO Win to change the contents of a line in either json or main.js of NEO Web. and json is probably less messy...

.

@luishp But if I change the json contents, don't I have to restart or refresh the NEO Web browser for any changes to take effect?

.

@luishp  You mention json "loaded at startup or whenever necessary." How can I load the startup json whenever I want? Won't the user have to refresh their browser and possibly lose unsaved data? My solution with main.js doesn't require refreshing the browser.

.

I think this will load json whenever its needed along with a matching subroutine. Must it be an URL or will a local text file (or variable) also load?

 

LoadAsyncJSON

Purpose:

Load a JSON file from a URL asynchronously and sends the data to a subroutine once loaded

Thanks

.

Must it be an URL or will a local text file (or variable) also load?

@fkapnist you can store a URL in a variable and it will work as a parameter for LoadAsyncJSON.
Not sure if it will work for local absolute paths when working on a not secure context, but you can try.

Quote from luishp on September 11, 2024, 12:50 pm

Must it be an URL or will a local text file (or variable) also load?

@fkapnist you can store a URL in a variable and it will work as a parameter for LoadAsyncJSON.
Not sure if it will work for local absolute paths when working on a not secure context, but you can try.

Since my project is in fact a Windows desktop app, NEO Web  must have access to absolute paths (as determined by NEO Win vars). Five lines of code plus an extra subroutine seem like a lot of baggage to select a filename without user intervention. My solution is easier with just one line of code. Thanks.

.