OpenVR WebSocket API
Overview
Section titled “Overview”OpenVR exposes a local WebSocket server for remote control and playback updates. You can connect, read the handshake, send commands, and listen for playback events.
Connect
Section titled “Connect”Default URL:
ws://127.0.0.1:8086The port can be changed in the app. If it is changed, use that port instead.
Message format
Section titled “Message format”All messages are JSON objects sent as text frames.
The type field tells you what the message is.
Handshake (server -> client)
Section titled “Handshake (server -> client)”Sent once right after a client connects.
{ "type": "handshake", "server": "openvr", "version": "1.0", "timestamp": 1712878340.123, "playbackState": { "url": "https://example.com/video.mp4", "preferredName": "Example Video", "position": 12.34, "isPlaying": false, "rate": 1.0 }}Fields:
timestampis seconds since the Unix epoch.playbackStatecan be an empty object{}when nothing is loaded.- Any field inside
playbackStatecan benullif unknown.
Commands (client -> server)
Section titled “Commands (client -> server)”Commands are routed to the app’s command center.
{ "type": "command", "command": "seek", "payload": { "position": 3.0 } }{ "type": "command", "command": "play" }{ "type": "command", "command": "pause" }Load media
Section titled “Load media”{ "type": "command", "command": "loadMedia", "payload": { "url": "https://example.com/stream.m3u8", "preferredName": "Example Stream" }}Playback events (server -> client)
Section titled “Playback events (server -> client)”Playback updates are sent as type: "playback" events.
mediaPathChanged
Section titled “mediaPathChanged”{ "type": "playback", "event": "mediaPathChanged", "payload": { "url": "https://example.com/video.mp4", "preferredName": "Example Video" }}isPlaying
Section titled “isPlaying”{ "type": "playback", "event": "isPlaying", "payload": { "isPlaying": true, "position": 12.34 }}rateChanged
Section titled “rateChanged”{ "type": "playback", "event": "rateChanged", "payload": { "rate": 1.5 }}seeked
Section titled “seeked”{ "type": "playback", "event": "seeked", "payload": { "position": 3.0 }}Notes:
url,preferredName, andpositioncan benullwhen not available.