Unreal Notifications & Annotations Guide
This guide was written as a quick reference step by step guide for setting up a simple Unreal notification/annotation. For more in depth information on each step please check the documentation at https://www.genvidtech.com/for-developers/sdk-latest/
Blueprint Implementation
On your GenvidStreams blueprint create 2 boolean variables. One called “ShouldSendNotification” and the other called “ShouldSendAnnotation”
Create another variable of type integer called “PreviousUsedSecond”
In the event graph add the following code:
-
GenvidStreams Code
Make sure the Tick event used is actually ticking (there will be one that won’t actually tick)
This flips both booleans created above to true the first tick that the current second is 0, 15, 30, or 45. We also save the second value that flipped the booleans
In BeginPlay add the following:
-
GenvidStreamsCode
We add annotation and notification streams to the built in streams property
-
ClockNotification collapsed graph
ClockNotification creates a genvid stream called “ClockNotification” with FrameRate value 30 and binds it to a new event
The new event only proceeds with the boolean created above is true
We send the second that flipped the boolean as a notification
Note that SubmitNotification exists on the GenvidSession and not the GenvidStream
We flip the boolean to make sure it fires only once
-
Function in GenvidStreams that forms the JSON
We form the JSON string using the second that flipped the boolean
ClockAnnotation will work similarly:
-
ClockAnnotation CollapsedGraph
The main differences is SubmitAnnotation is on GenvidStream, we name the GenvidStream “ClockAnnotation”, we flip the proper boolean, and we call a different function to form the JSON string
-
Forming a JSON string again
The new function works exactly the same way and can be combined into one if desired
Web Implementation
Go back to your Web/public folder. Open index.html
Add two divs. One for notification and one for annotation:
<div class="child" id="notification"></div> <div class="child" id="annotation"></div>
Open overlay.js. Create two new functions. One called notificationUpdate and one the other called annotationUpdate. Both take in a parameter called data:
function notificationUpdate(data) { document.getElementById("notification").innerHTML = "Notification: " + Math.round(data.second); } function annotationUpdate(data) { document.getElementById("annotation").innerHTML = "Annotation: " + Math.round(data.second); }
We set the divs created with the second value we sent in the above steps
In the existing genvidClient.onDraw function add the following code after the existing “ClockTime” stream code:
if ("ClockAnnotation" in frame.annotations && frame.annotations["ClockAnnotation"].length) { for (let gameAnnotation of frame.annotations["ClockAnnotation"]) { if (gameAnnotation && gameAnnotation.user) { annotationUpdate(gameAnnotation.user); } } }
We check to see if a ClockAnnotation data value exists. If we pass the parsed JSON value to annotationUpdate. (It is already being parsed in onStreamsRecieved)
Similarly to genvidClient.onDraw we will define another function on genvidClient called “onNotificationsReceived” that triggers whenever a notification is sent:
genvidClient.onNotificationsReceived(function (notifications) { for (let notification of notifications.notifications) { try { notification.user = JSON.parse(notification.data); notificationUpdate(notification.user); } catch (e) { console.log(e, notification); } } });
We parse the notification received and pass in the data to notificationUpdate
Putting it all together
Package your project making sure that .exe ends up in the same location as before so that it can be picked up by the web code
If you need to - recreate your bastion instance, setup the genvid-sdk, and load using the python script
Open up your genvid monitor page using genvid-sdk monitor. Hit start all and open up your stream
Note that the annotation updates in sync with the video whenever the seconds hand hits a 15 second interval
Note that the notification updates out of sync with the video ASAP when the second hand hits a 15 second interval
