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.

.

Quote from fkapnist on September 10, 2024, 1:13 pm

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:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
FileWrite "[PubDir]bin\video-player-Web\js\main.js" "16" "$App.MP4name = [#34]c:/MyApp/output.mp4[#34];"
FileWrite "[PubDir]bin\video-player-Web\js\main.js" "16" "$App.MP4name = [#34]c:/MyApp/output.mp4[#34];"
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.
https://mostbetbd.asia/register/ is another example of a service where the web interface needs to work smoothly across different devices, so it was interesting to compare the overall browser experience.

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

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

..

That's a clever workaround for getting the two parts of the app to communicate without forcing the user through a file picker every time. The main thing I'd be cautious about is modifying main.js itself, since a fixed line number can become unreliable if the Web pub is updated or the JavaScript gets rebuilt.

If NEO provides any way to pass parameters or communicate between the Win and Web pubs, I'd prefer that long-term. Even something as simple as passing the output filename through a command-line argument, query parameter, or temporary config/JSON file would keep the Web code unchanged.

For a controlled local application, though, your FileWrite approach makes sense and is certainly more convenient than asking the user to manually locate the generated MP4 every time.

fkapnist has reacted to this post.
fkapnist