From 1211fc9edd84358a9542f17c7881abacae8fa903 Mon Sep 17 00:00:00 2001 From: iceyrazor Date: Sun, 25 Aug 2024 04:33:03 -0500 Subject: [PATCH] init --- LICENSE | 21 ++++ config.json | 49 ++++++++++ main.js | 80 +++++++++++++++ package.json | 20 ++++ src/index.css | 128 ++++++++++++++++++++++++ src/index.html | 260 +++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 558 insertions(+) create mode 100644 LICENSE create mode 100644 config.json create mode 100644 main.js create mode 100644 package.json create mode 100644 src/index.css create mode 100644 src/index.html diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..115d8fa --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 iceyrazor + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/config.json b/config.json new file mode 100644 index 0000000..d0edf05 --- /dev/null +++ b/config.json @@ -0,0 +1,49 @@ +{ + "airtime_data": { + "stream_url": "https://radiosidewinder.out.airtime.pro:8000/radiosidewinder_b?_ga=1.133037898.513622194.1447957646/;stream.mp3", + "api_url": "https://radiosidewinder.airtime.pro/api/live-info?type=interval&limit=5&_=1646343267200" + }, + "volumes": [ + { + "default": 0.15 + }, + { + "lookfor": [ + [ + "currentShow", + 0, + "name" + ], + "Galnet News" + ], + "volume": 0.3 + }, + { + "lookfor": [ + [ + "currentShow", + 0, + "name" + ], + "Clan Ads" + ], + "volume": 0.3 + }, + { + "lookfor": [ + [ + "currentShow", + 0, + "name" + ], + "Commercial Break" + ], + "volume": 0.05 + } + ], + "read_cmd_file": "false", + "default_size": [ + 0, + 0 + ] +} \ No newline at end of file diff --git a/main.js b/main.js new file mode 100644 index 0000000..20b78bf --- /dev/null +++ b/main.js @@ -0,0 +1,80 @@ +const electron = require('electron'), + {app,BrowserWindow,Menu,Tray,ipcMain} = require('electron'), + fs=require('fs'), + path=require('path'); + +myWindow=null; +global.tray=null; +app.whenReady().then(()=>{ + + //get display. if default config isnt too small. use configs size. + let primaryscreen=electron.screen.getPrimaryDisplay() + let config=JSON.parse(fs.readFileSync(path.join(__dirname,"config.json"))); + let setsize=[] + if(config["default_size"][0]<150&config["default_size"][1]<150){ + setsize=[Math.round(primaryscreen.bounds.width/2.8),Math.round(primaryscreen.bounds.height/1.2)] + } else { + setsize=config["default_size"] + } + + myWindow=new BrowserWindow({ + width: setsize[0], + height: setsize[1], + frame: false, + transparent:true, + resizable:true, + useContentSize: true, + webPreferences:{ + nodeIntegration: true, + contextIsolation: false, + enableRemoteModule: false, + } + }); + myWindow.loadFile('src/index.html'); + + //change default size on delay so config isnt spammed + let window_size_forc=myWindow.getSize() + myWindow.on('resize', function () { + window_size_forc = myWindow.getSize(); + + if(typeof window_size_forc[0]=="object"|typeof window_size_forc[0]=="array"){ + window_size_forc=window_size_forc[0] + } + }); + + function set_conf_size_loop(){ + let config=JSON.parse(fs.readFileSync(path.join(__dirname,"config.json"))); + + if(config["default_size"][0]!=window_size_forc[0]|config["default_size"][1]!=window_size_forc[1]){ + config["default_size"]=window_size_forc + fs.writeFileSync(path.join(__dirname,"config.json"),JSON.stringify(config,null,2)) + } + + setTimeout(set_conf_size_loop,3000) + } + set_conf_size_loop() +}); + +stop_cursor=false +let win_size=[] +ipcMain.on("setpos",(req,data)=>{ + stop_cursor=false + win_size=myWindow.getSize(); + function move_loop(){ + if(stop_cursor==true){ + return + } + let cursor_pos=electron.screen.getCursorScreenPoint() + + myWindow.setPosition(cursor_pos.x-data.x,cursor_pos.y-data.y) + myWindow.setSize(win_size[0],win_size[1]) + setTimeout(move_loop,20) + } + move_loop() +}) + +ipcMain.on("stoppos",(req,data)=>{ + stop_cursor=true + myWindow.setSize(win_size[0],win_size[1]) +}) + diff --git a/package.json b/package.json new file mode 100644 index 0000000..4d55663 --- /dev/null +++ b/package.json @@ -0,0 +1,20 @@ +{ + "name": "stream-volumizer", + "version": "0.0.0", + "description": "a little peice of software that allows you to have differnt volume levels during different parts of a Airtime stream", + "main": "main.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "start": "electron ." + }, + "keywords": [ + "volume", + "auto", + "control" + ], + "author": "iceyrazor", + "license": "MIT", + "dependencies": { + "electron": "^17.1.0" + } +} diff --git a/src/index.css b/src/index.css new file mode 100644 index 0000000..497da7d --- /dev/null +++ b/src/index.css @@ -0,0 +1,128 @@ +#raw_json{ + display: none; + overflow-y: scroll; + height: 400px; + width: 90%; + border: 2px solid black; + white-space: pre-wrap; +} + + +#volumes_control{ + position: relative; + overflow-y: scroll; + max-width: 600px; + height: 500px; + border: 2px solid black; + padding: 10px; +} +#volumes_control > div{ + display: flex; + background-color: rgb(230,230,230); + margin-bottom: 3px; + align-content: flex-start; + justify-content: center; + grid-gap: 3px; + padding: 3px; +} +#volumes_control textarea{ + border: 2px inset rgb(120,120,120); + font-size: 15px; + width: 180px; + height: 15px; + resize: none; + overflow: hidden; +} +#volumes_control button{ + height: 20px; + min-width: 20px; + align-items: center; + justify-items: center; +} +#volume_wrap{ + position: relative; + max-width: 600px; +} +#vol_update_button{ + background-color: rgb(200,200,200); + border: 2px solid black; + position: absolute; + display: block; + width: 100px; + height: 15px; + padding: 3px; + bottom: 3px; + left: calc(50% - 50px); + user-select: none; +} +#vol_update_button:hover{ + background-color: rgb(190,190,190); +} + +.vol_update_button_tooltip{ + visibility: hidden; + position: absolute; + width: 120px; + left: calc(50% - (120px/2)); + bottom: 50px; + border: 2px solid black; + padding: 3px; + background-color: rgb(260,260,260); + border-radius: 10px; +} +.vol_update_button_wrap:hover .vol_update_button_tooltip{ + visibility: visible; +} + +#vol_add_button{ + background-color: rgb(200,200,200); + border: 2px solid black; + position: absolute; + display: block; + width: 50px; + height: 15px; + padding: 3px; + bottom: 3px; + left: 65%; + user-select: none; +} + + +.play_grid,.show_grid{ + display: grid; + grid-template-columns: 1fr 1fr; + border: 2px solid black; + padding: 4px; +} +#airtime_next,#airtime_next_show{ + border-left: 2px dashed rgb(120,120,120); + padding-left: 10px; +} +#airtime_np,#airtime_np_show{ + padding-right: 5px; +} + +#move_button{ + position: absolute; + padding: 3px; + top: 5px; + right: 5px; + user-select: none; + border: 2px solid black; +} + +#background_plate{ + position: fixed; + left: 0px; + top: 0px; + width: 100vw; + height: 100vh; + background-color: rgba(255,255,255,1); + z-index: -1; +} + +#error_box{ + display: none; + padding: 4px; + background-color: rgba(255,50,50); +} \ No newline at end of file diff --git a/src/index.html b/src/index.html new file mode 100644 index 0000000..8ea032f --- /dev/null +++ b/src/index.html @@ -0,0 +1,260 @@ + + + + + + + + + +
+
+ + +
click to drag
+ +
+
+
+
+
+
+
+
+
+ +
+

volumes for different things

+
+
+
+
+ update +
+ please dont spam this button +
add
+
+
+ +

+

+
+ + + +