Quantcast
Viewing all articles
Browse latest Browse all 981

General Discussion • HTML & Meta Information Audio/Video Files

Wow, quite a creative thread here, isn't it nice when folks write the code using their native language so that nobody understands what the buttons or the comments mean? Image may be NSFW.
Clik here to view.
:lol:


Anyway, joking aside, tass_co is correct, CORS is really a pain in the a... when trying to use local resources in a local site in Javascript. I've experienced the same in my Earth skin, where I also had to create a local server to use whatever images and clips related to my skin. The only difference is that I used the HTTP Server extension of NPM to run the server within the Node.js environment (though you can do it using Python as well, like tass_co did)...
I even made myself a .bat file like:

Code:

@echo off@echo -------------------------------------------------------@echo Node.JS must be installed from https://nodejs.org first@echo -------------------------------------------------------@echo To test Node.JS by getting its version use: serve -test@echo To install the server globally via npm use: serve -inst@echo To start server http://localhost:8080/ use: serve -star@echo To stop server via using CTRL+C in CMD use: serve -stop@echo -------------------------------------------------------IF [%1]==[] (goto -none) else (goto %1):-testnode -v:-instnpm install -g http-server:-starhttp-server -a localhost -p 8080 -c-1 --cors:-stoptaskkill /F /IM node.exe:-noneREM [No argument given to the batch file thus no action done]
if I ever wanted to manually start and stop the server by using parameters on the .bat file. In the end it wasn't really necessary, as I just create and stop the server automatically at skin load and unload, via a RunCommand and an OnRefreshAction like (the approach can be adapten for Python too):

Code:

[Rainmeter]...OnRefreshAction=[!CommandMeasure Serve "Run"]...---Measures---; INSTALL NODE.JS = https://nodejs.org/  |  TEST NODE.JS = node -v  |  INSTALL GLOBAL SERVER = npm install -g http-server  |  START SERVER = http-server -a localhost -p 8080 -c-1 --cors  |  STOP SERVER = taskkill /F /IM node.exe; The measure below automatically starts a CORS disabled server at skin refresh, so no action is required from the user, assuming he already installed Node.js and its global server in the usual standard locations on his computer[Serve]Measure=PluginPlugin=RunCommandStartInFolder=#@#Program=nodeParameter=%APPDATA%/npm/node_modules/http-server/bin/http-server -a localhost -p 8080 -c-1 --corsState=HideOutputType=ANSI...[WebView]......
Stopping the server when not needed is recommended, at least in my case, as it isn't that safe to always run a CORS disabled local server on your machine with all kinds of hackers lurking around (well, assuming you're unlucky enough to be their target in the first place, which isn't that likely to be fair). Also, like in tass_co Javascript code, the files must be prepended with http://localhost:8080/ or whatever port other than 8080 you prefer in order to be fully used.
As for audio metadata like covers and such, maybe this can help:
https://stackoverflow.com/questions/29881237/how-can-i-get-the-cover-of-an-mp3-file
If you like videos, this is an example:
https://forum.rainmeter.net/viewtopic.php?t=44937#p231218
Some references:
https://www.w3schools.com/html/html5_audio.asp
https://www.w3schools.com/html/html5_video.asp

Notice that using a local server should generally be needed if defining those resources in Javascript, as the video example above needs no local server to use the video file directly but defined in HTML. I guess you could create all the layout and navigation without any resources in the HTML, then dynamically write the resources from the plain .ini or from a .lua script into the HTML as you navigate the list, followed by updating the WebView measure to reload the page, but that would be kind of a questionable approach, and I'm not 100% sure it will work and avoid CORS for all cases.

Statistics: Posted by Yincognito — Today, 3:55 am — Replies 7 — Views 132



Viewing all articles
Browse latest Browse all 981

Trending Articles