Local Overrides Sample: Add Hotkeys for Switching Cameras - bp2008/ui3 GitHub Wiki

This script will add some hotkeys to switch the video player to your choice of camera or group. Edit it however you like to suit your own needs.

To learn more about ui3-local-overrides, see: Local Overrides Scripts and Styles

This example script does not use UI3's hotkey system, instead just using a basic keydown event handler.

ui3-local-overrides.js

$(document).keydown(function (e)
{
	var char = String.fromCharCode(e.which);
	if (char === "A")
	{
		OpenCameraWithName("mailbox");
	}
	else if (char === "B")
	{
		OpenCameraWithName("segarageptz");
	}
	else if (char === "C")
	{
		OpenCameraWithName("frontwide");
	}
	else if (char === "Z")
	{
		OpenCameraWithName("Index"); // All cameras
	}
});
function OpenCameraWithName(name)
{
	var camera = cameraListLoader.GetCameraWithId(name);
	if (camera)
		videoPlayer.LoadLiveCamera(camera);
	else
		toaster.Error("Could not find camera: " + name);
}