diff --git a/FyneApp.toml b/FyneApp.toml
index c073603..8bbf6c0 100644
--- a/FyneApp.toml
+++ b/FyneApp.toml
@@ -4,5 +4,5 @@ Website = "https://gitlab.com/codegoy/obs-drops-overlay"
Icon = "Icon.png"
Name = "OBS-drops-overlay"
ID = "codegoy.obs.overlay"
- Version = "1"
+ Version = "4"
Build = 1
diff --git a/control.html b/control.html
index 591fcb3..cff376f 100644
--- a/control.html
+++ b/control.html
@@ -73,25 +73,23 @@
Audio
- Stop audio
- Audio Volume
+ Stop
+ Volume
- playbackRate 1.0 [1.0]
+ PlaybackRate 1.0 [1.0]
- Echo:
- Delay:
+ Echo
+ Delay
- Video Loop
+ VideoLoop
- start
- stop
- next
-
-
-
+ Start
+ Stop
+ Next
+
@@ -137,13 +142,38 @@ Music
let testOverlay = () => {
if (!document.getElementById('test')) {
console.log("opening test frame");
- document.body.insertAdjacentHTML('beforeend', `close
`);
+ document.body.insertAdjacentHTML('beforeend', `close
`);
+ let testDiv = document.getElementById('test');
+ let initResize = () => {
+ window.addEventListener('mousemove', Resize, false);
+ window.addEventListener('mouseup', stopResize, false);
+ }
+ let Resize = (e) => {
+ testDiv.style.width = (e.clientX + testDiv.offsetLeft) + 'px';
+ let nh = (window.innerHeight - e.clientY) + 'px';
+ console.log("resize Height: " + nh)
+ testDiv.style.height = nh;
+ }
+ let stopResize = () => {
+ window.removeEventListener('mousemove', Resize, false);
+ window.removeEventListener('mouseup', stopResize, false);
+ }
+ let resizer = document.createElement('div');
+ resizer.className = 'resizer';
+ resizer.style.width = '10px';
+ resizer.style.height = '10px';
+ resizer.style.background = 'red';
+ resizer.style.position = 'absolute';
+ resizer.style.right = '0';
+ resizer.style.top = '0';
+ resizer.style.cursor = "ne-resize";
+ testDiv.appendChild(resizer);
+ resizer.addEventListener('mousedown', initResize, false);
} else {
console.log("testing frame already open");
}
};
console.log("Version: {{ .Version }}");
- // TODO : clean up vars
let ws;
let host = location.host;
let overlayStatus = false;
@@ -166,17 +196,18 @@ Music
let musicCurrentFilename = document.getElementById("musicCurrentFilename");
let musicProgressIntEm = document.getElementById("musicProgressIntEm");
let musicProgress = document.getElementById("musicProgress");
+ let musicAnnounce = document.getElementById("musicAnnounce");
let musicProgressInteraction;
let musicEm = document.getElementById("music");
let musicProgressDuration;
let musicProgressCurrent;
- let musicInterval;
+ let musicInterval = null;
let audioDropEm = document.getElementById("dropsAudio");
let audioFiles = [];
let next = false;
let openUpload = () => {
document.getElementById("rightEM").insertAdjacentHTML("beforeend",`
- close
+ close
`)
};
@@ -197,10 +228,14 @@ Music
next = false;
musicCurrentFilename.innerText = `${audioFiles[position]}`;
sendControlMessage('music', 'play', `music/${audioFiles[position]}`);
+ if (musicAnnounce.checked) {
+ sendControlMessage('music', 'announce', `${audioFiles[position].substring(0, audioFiles[position].lastIndexOf('.'))}`);
+ }
musicInterval = setInterval(() => {
- if (musicProgressCurrent+3 > musicProgressDuration || next) {
+ if (musicProgressCurrent+2 > musicProgressDuration || next) {
next = false;
clearInterval(musicInterval);
+ musicInterval = null;
position++;
if (position > audioFiles.length-1) {
position = 0;
@@ -306,9 +341,6 @@ Music
let setEchoDelay = (delay) => {
sendControlMessage("audio", "echoDelay", delay);
}
- let sendVideo = (url) => {
- sendControlMessage("video", "play", url);
- };
let setStatus = () => {
try {
if (connectionStatus) {
@@ -338,9 +370,6 @@ Music
sendControlMessage("audio", "play", url);
}
};
- let stopAudio = (type) => {
- sendControlMessage("audio", "stop", type);
- }
let setVolume = (level, type) => {
sendControlMessage("volume", type, level);
};
@@ -348,13 +377,13 @@ Music
let filenameExt = filename.substring(filename.length - 4);
switch (filenameExt) {
case ".mp3":
- audioDropEm.insertAdjacentHTML("beforeend", `${filename.substring(0, filename.lastIndexOf('.'))} `);
+ audioDropEm.insertAdjacentHTML("beforeend", `${filename.substring(0, filename.lastIndexOf('.'))} `);
break;
case ".mp4":
- videoDropEm.insertAdjacentHTML("beforeend", `${filename.substring(0, filename.lastIndexOf('.'))} `);
+ videoDropEm.insertAdjacentHTML("beforeend", `${filename.substring(0, filename.lastIndexOf('.'))} `);
break;
case ".mkv":
- videoDropEm.insertAdjacentHTML("beforeend", `${filename.substring(0, filename.lastIndexOf('.'))} `);
+ videoDropEm.insertAdjacentHTML("beforeend", `${filename.substring(0, filename.lastIndexOf('.'))} `);
break;
}
};
@@ -369,11 +398,21 @@ Music
console.log("error", err);
});
};
- let addMusic = (filename) => {
+ let addMusic = (filename, n) => {
let filenameExt = filename.substring(filename.length - 4);
if (filenameExt === ".mp3") {
audioFiles.push(filename);
- musicEm.insertAdjacentHTML("beforeend", `${filename.substring(0, filename.lastIndexOf('.'))} `);
+ musicEm.insertAdjacentHTML("beforeend", `${filename.substring(0, filename.lastIndexOf("."))} `);
}
};
let loadMusic = () => {
@@ -381,9 +420,10 @@ Music
fetch(`${listUrl}music`).then(response => {
return response.json();
}).then(data => {
- data["files"].forEach((value) => {
- addMusic(value);
- })
+ let df = data["files"];
+ for (let i = 0; i < df.length; i++) {
+ addMusic(df[i], i);
+ }
}).catch(err => {
console.log("error", err);
});
@@ -399,21 +439,31 @@ Music
let ce = document.getElementById(rmExt)
ce.style.color = "green";
}
+ let videoRepeat = false;
+ let setVideoRepeat = (em) => {
+ if (em.checked) {
+ videoRepeat = true;
+ ws.send(JSON.stringify({a: "video", k: "loop", v: "true"}));
+ } else {
+ videoRepeat = false;
+ ws.send(JSON.stringify({a: "video", k: "loop", v: "false"}));
+ }
+
+ }
let loopVideoSwitch = false;
let playLoopVideo = (index) => {
if (loopVideoSwitch) {
- sendVideo(`videoLoop/${videoLoopTitles[index]}`);
+ sendControlMessage('video', 'play', `videoLoop/${videoLoopTitles[index]}`)
playingColor(videoLoopTitles[index]);
setTimeout(() => { // wait for video to begin playing before starting loop interval
videoLoopInterval = setInterval(() => {
- if ( videoProgressCurrent > 1 && (videoProgressDuration-videoProgressCurrent < 0.1 || videoLoopNext)) {
+ if ( videoProgressCurrent > 1 && (videoProgressDuration-videoProgressCurrent < 0.2 || videoLoopNext)) {
clearInterval(videoLoopInterval);
videoLoopNext = false;
if (index===videoLoopTitles.length-1 ) {
playLoopVideo(0);
} else {
- let newIndex = index + 1;
- playLoopVideo(newIndex);
+ playLoopVideo(index + 1);
}
}
}, 100)
@@ -471,7 +521,7 @@ Music
loadMusic();
loadLoopVideoTitles();
};
- window.addEventListener('load', function() {
+ window.addEventListener('load', () => {
console.log('All assets are loaded');
connect();
load();
diff --git a/gui.go b/gui.go
new file mode 100644
index 0000000..b7698d9
--- /dev/null
+++ b/gui.go
@@ -0,0 +1,35 @@
+//go:build windows
+
+package main
+
+import (
+ "fmt"
+ "fyne.io/fyne/v2"
+ "fyne.io/fyne/v2/app"
+ "fyne.io/fyne/v2/driver/desktop"
+ "fyne.io/fyne/v2/widget"
+)
+
+func systray() {
+ a := app.NewWithID("codegoy.obs.overlay")
+ version = a.Metadata().Version
+ a.SetIcon(fyne.NewStaticResource("icon", icon))
+ if desk, ok := a.(desktop.App); ok {
+ a.SetIcon(fyne.NewStaticResource("icon", icon))
+ w := a.NewWindow(fmt.Sprintf("OBS-drops-overlay v%s", version))
+ w.SetFixedSize(true)
+ m := fyne.NewMenu("links",
+ fyne.NewMenuItem("Links", func() {
+ w.Show()
+ }),
+ )
+ desk.SetSystemTrayMenu(m)
+ w.SetContent(widget.NewRichTextFromMarkdown(fmt.Sprintf(`# Links
+* [%s](%s)
+* [%s](%s)`, controlLink, controlLink, overlayLink, overlayLink)))
+ w.SetCloseIntercept(func() {
+ w.Hide()
+ })
+ a.Run()
+ }
+}
diff --git a/main.go b/main.go
index 3fa93a3..31be753 100644
--- a/main.go
+++ b/main.go
@@ -5,10 +5,6 @@ import (
"encoding/json"
"flag"
"fmt"
- "fyne.io/fyne/v2"
- "fyne.io/fyne/v2/app"
- "fyne.io/fyne/v2/driver/desktop"
- "fyne.io/fyne/v2/widget"
"github.com/gorilla/websocket"
"html/template"
"io"
@@ -22,7 +18,7 @@ import (
var (
//go:embed upload.html
- uploadHTML []byte
+ uploadHTML string
//go:embed control.html
controlHTML string
//go:embed overlay.html
@@ -34,11 +30,11 @@ var (
controlLink string
overlayLink string
mediaExt = []string{".mp4", ".mkv", ".mp3"}
- version = "1"
+ version = "4"
)
type Server struct {
- websocketUpgrayeddr websocket.Upgrader
+ websocketUpgrayddr websocket.Upgrader
overlayWebsocketConnections map[string]*websocket.Conn
port string
controlChan chan []byte
@@ -127,13 +123,13 @@ func (s *Server) start() {
http.ServeFile(w, r, fmt.Sprintf("%sassets/%s", assetsLocation, r.FormValue("file")))
})
http.HandleFunc("/uploadAsset", func(w http.ResponseWriter, r *http.Request) {
- if _, err := w.Write(uploadHTML); err != nil {
- log.Panicf("%v\n", err)
+ if err := s.applyTemplate(uploadHTML, w); err != nil {
+ log.Fatalf("%v", err)
}
})
http.HandleFunc("/upload", func(w http.ResponseWriter, r *http.Request) {
uploadLocation := r.FormValue("loc")
- fmt.Printf("/upload->Method:%s\n", r.Method)
+ //fmt.Printf("/upload->Method:%s\n", r.Method)
if err := r.ParseMultipartForm(32 << 20); err != nil {
log.Panicf("r.FormFile(): %v\n", err)
}
@@ -147,7 +143,7 @@ func (s *Server) start() {
}
}()
uploadTargetLocation := fmt.Sprintf("%sassets/%s/%s", assetsLocation, uploadLocation, handler.Filename)
- fmt.Println("uploadTargetLocation", uploadTargetLocation)
+ //fmt.Println("uploadTargetLocation", uploadTargetLocation)
f, err := os.OpenFile(uploadTargetLocation, os.O_WRONLY|os.O_CREATE, 0666)
if err != nil {
log.Panicf("%v\n", err)
@@ -161,7 +157,7 @@ func (s *Server) start() {
log.Printf("%v\n", err)
}
response := fmt.Sprintf("Received File: %s", handler.Filename)
- log.Printf(response)
+ //log.Printf(response)
if _, err := w.Write([]byte(response)); err != nil {
log.Printf("%v\n", err)
}
@@ -177,24 +173,24 @@ func (s *Server) start() {
}
})
http.HandleFunc("/overlayWS", func(w http.ResponseWriter, r *http.Request) {
- s.websocketUpgrayeddr.CheckOrigin = func(r *http.Request) bool { return true }
- conn, err := s.websocketUpgrayeddr.Upgrade(w, r, nil)
+ s.websocketUpgrayddr.CheckOrigin = func(r *http.Request) bool { return true }
+ conn, err := s.websocketUpgrayddr.Upgrade(w, r, nil)
if err != nil {
log.Printf("%v\n", err)
}
s.overlayWebsocketConnections[r.RemoteAddr] = conn
defer func() {
- fmt.Println("closing /overlayWS websocket connection")
+ //fmt.Println("closing /overlayWS websocket connection")
if err := s.overlayWebsocketConnections[r.RemoteAddr].Close(); err != nil {
log.Printf("Error closing /overlayWS connection: %v\n", err)
}
delete(s.overlayWebsocketConnections, r.RemoteAddr)
- fmt.Printf("websocket connections: %d -> %v\n", len(s.overlayWebsocketConnections), s.overlayWebsocketConnections)
+ //fmt.Printf("websocket connections: %d -> %v\n", len(s.overlayWebsocketConnections), s.overlayWebsocketConnections)
}()
for {
_, msg, err := s.overlayWebsocketConnections[r.RemoteAddr].ReadMessage()
if err != nil {
- log.Printf("/overlayWS: %v\n", err)
+ //log.Printf("/overlayWS: %v\n", err)
if err := s.overlayWebsocketConnections[r.RemoteAddr].Close(); err != nil {
log.Printf("Error closing /overlayWS connection: %v\n", err)
}
@@ -204,14 +200,14 @@ func (s *Server) start() {
}
})
http.HandleFunc("/controlWS", func(w http.ResponseWriter, r *http.Request) {
- fmt.Printf("controlWS: %v\n", r.RemoteAddr)
- s.websocketUpgrayeddr.CheckOrigin = func(r *http.Request) bool { return true }
- conn, err := s.websocketUpgrayeddr.Upgrade(w, r, nil)
+ //fmt.Printf("controlWS: %v\n", r.RemoteAddr)
+ s.websocketUpgrayddr.CheckOrigin = func(r *http.Request) bool { return true }
+ conn, err := s.websocketUpgrayddr.Upgrade(w, r, nil)
if err != nil {
log.Printf("%v\n", err)
}
defer func() {
- fmt.Println("closing /controlWS websocket connection")
+ //fmt.Println("closing /controlWS websocket connection")
if err := conn.Close(); err != nil {
log.Printf("Error closing /controlWS connection: %v\n", err)
}
@@ -220,7 +216,7 @@ func (s *Server) start() {
for {
_, msg, err := conn.ReadMessage()
if err != nil {
- log.Printf("/controlWS: %v\n", err)
+ //log.Printf("/controlWS: %v\n", err)
return
}
s.controlChan <- msg
@@ -234,7 +230,7 @@ func (s *Server) start() {
})
log.Printf("Serving @ %s %s\n", overlayLink, controlLink)
if err := http.ListenAndServe(":"+s.port, nil); err != nil {
- log.Printf("Error:: listenAndServe():: %v\n", err)
+ log.Printf("listenAndServe():: %v\n", err)
}
}
@@ -247,36 +243,12 @@ func makeDir(path string) error {
return nil
}
-func (s *Server) systray() {
- a := app.NewWithID("codegoy.obs.overlay")
- version = a.Metadata().Version
- a.SetIcon(fyne.NewStaticResource("icon", icon))
- if desk, ok := a.(desktop.App); ok {
- a.SetIcon(fyne.NewStaticResource("icon", icon))
- w := a.NewWindow(fmt.Sprintf("OBS-drops-overlay v%s", version))
- w.SetFixedSize(true)
- m := fyne.NewMenu("links",
- fyne.NewMenuItem("Links", func() {
- w.Show()
- }),
- )
- desk.SetSystemTrayMenu(m)
- w.SetContent(widget.NewRichTextFromMarkdown(fmt.Sprintf(`# Links
-* [%s](%s)
-* [%s](%s)`, controlLink, controlLink, overlayLink, overlayLink)))
- w.SetCloseIntercept(func() {
- w.Hide()
- })
- a.Run()
- }
-}
-
func main() {
var port string
var enableGui bool
flag.StringVar(&port, "port", "8605", "port to listen on")
flag.StringVar(&assetsLocationOverride, "path", "", "override file location")
- flag.BoolVar(&enableGui, "systray", false, "show systray (runs headless by default)")
+ flag.BoolVar(&enableGui, "systray", false, "show systray (Windows only)")
flag.Parse()
ip := func() string {
adders, err := net.InterfaceAddrs()
@@ -299,7 +271,7 @@ func main() {
controlLink = fmt.Sprintf("http://%s:%s/control", ip, port)
overlayLink = fmt.Sprintf("http://%s:%s/overlay", ip, port)
s := Server{
- websocketUpgrayeddr: websocket.Upgrader{ReadBufferSize: 1024, WriteBufferSize: 1024},
+ websocketUpgrayddr: websocket.Upgrader{ReadBufferSize: 1024, WriteBufferSize: 1024},
port: port,
controlChan: make(chan []byte),
statusChan: make(chan []byte),
@@ -317,7 +289,7 @@ func main() {
go func() {
s.start()
}()
- s.systray()
+ systray()
} else {
s.start()
}
diff --git a/nix.go b/nix.go
new file mode 100644
index 0000000..9314f72
--- /dev/null
+++ b/nix.go
@@ -0,0 +1,7 @@
+//go:build linux
+
+package main
+
+func systray() {
+ return
+}
diff --git a/overlay.html b/overlay.html
index e0806d0..2ca25d3 100644
--- a/overlay.html
+++ b/overlay.html
@@ -11,6 +11,7 @@
overflow: hidden;
}
#videoDiv {
+ z-index: 1;
background-color: #000000;
width: 100vw;
height: 100vh;
@@ -19,6 +20,7 @@
left: 0;
}
video {
+ z-index: 2;
width: 100vw;
max-height: 100vh;
background-color: #000000;
@@ -33,7 +35,17 @@
}
.hide {
opacity: 0;
- transition: opacity 150ms linear;
+ transition: opacity 170ms linear;
+ }
+ #musicAnnounce {
+ padding: 15px;
+ position: relative;
+ max-width: fit-content;
+ margin-left: auto;
+ margin-right: auto;
+ z-index: 2147483647;
+ border: 1px solid red;
+ background-color: black;
}
@@ -41,14 +53,18 @@
+