Author Topic: HTML output for OBS Browser Source overlay?  (Read 928 times)

Robertsmania

  • Newbie
  • *
  • Posts: 46
HTML output for OBS Browser Source overlay?
« on: February 25, 2022, 02:55:38 PM »
I want to have some data in VoiceAttack that I would like to display on my stream.

The easiest thing I can think of with what I see in the documentation is to use the Write Text to a File command and write out an HTML file.  But is there anything else in place to do this sort of thing?

Experimenting with it, it does work and shows up fine in OBS.  The only trick is getting it to update the browser source when the content of the file changes. 
« Last Edit: February 25, 2022, 08:34:32 PM by Robertsmania »

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: HTML output for OBS Browser Source overlay?
« Reply #1 on: February 25, 2022, 10:24:36 PM »
There is no native method for displaying arbitrary text on screen, aside from the log on the main window, no.

Given that you have access to a browser, you could look into using JavaScript to periodically reload your content for you.

Robertsmania

  • Newbie
  • *
  • Posts: 46
Re: HTML output for OBS Browser Source overlay?
« Reply #2 on: February 25, 2022, 10:56:03 PM »
Okay, so it turns out this is a lot easier than I was imagining.  I'll share what I found here in case anyone else wants to do something similar in the future and stumbles on this post.

I'm sure there are a lot of ways to accomplish this, but what I've found is Ajax and the XMLHttpRequest Object.
This tutorial helped me get going:
https://www.w3schools.com/xml/ajax_xmlhttprequest_create.asp

So basically all I need is an HTML page that includes a simple script to read in data from a file and update a segment of the page periodically.  It doesnt need to be on a web server, can just be a local file.

VoiceAttack can write out the values I want to show on the overlay to the PitGirl_data.txt file.  The next cycle when the script loads the file, it appears on the overlay.

What a time to be alive!

Robertsmania

  • Newbie
  • *
  • Posts: 46
Re: HTML output for OBS Browser Source overlay?
« Reply #3 on: February 27, 2022, 01:22:46 AM »
What is the maximum string length you can use with the Write Text to a File and vaProxy.Command.Execute?

In my proof of concept yesterday I just sent a simple string literal to see the overlay update and show the value.

In moving forward today it seems like sending XML makes the most sense and keeps the commands in between simple.  My C# can build the XML and send it as a string, then the JavaScript in the overlay html can decode it and work with all the variables.

Right now I’m not sending much data, but there are situations where I can see wanting to send quite a bit.  I’d like to know what the limit is so I can check and break it up into multiple chunks if necessary.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: HTML output for OBS Browser Source overlay?
« Reply #4 on: February 27, 2022, 05:35:09 AM »
The theoretical limit for the String datatype is in the hundred millions to billions of characters. It is quite unlikely that you'll encounter it under normal circumstances.