GlassPlay · Personalised video for a hyperbaric session

GlassPlay curates videos to watch during a stay in a hyperbaric chamber. Viewers choose what interests them, and the system arranges the content into blocks that aim to fill 60 minutes. Sessions play on the web, and the interface also runs inside the Glassear headset.

GlassPlay showing video results for a search for mindfulness.
GlassPlay search results showing the length and source of each video.

Why GlassPlay exists

A stay in a hyperbaric chamber gives someone time to watch more than a single short video. GlassPlay set out to prepare a viewing session in advance, fit it to the available time and the viewer’s interests, and make it easy to control once the headset is on.

The clinic can supply its own material, such as a welcome or closing video. The viewer chooses a main goal, secondary interests and a preferred clip format. GlassPlay uses those choices to build a playback plan and also supports direct video search by text or voice.

The experience brings together a React app for viewers and clinic staff, a FastAPI service that builds sessions, and a Unity client that brings the web interface into the Glassear headset. The headset uses a reticle to select controls by holding the viewer’s gaze.

Unity · Bringing the web into the headset

Unity hosts the web interface in Vuplex WebView. C# code maps the direction of the viewer’s gaze to a position on the page, displays a reticle and lets viewers activate interface controls. A message bridge carries tutorial and playback events between JavaScript and Unity, and supports recentering and interpupillary distance adjustment.

Frontend · From preferences to playback

The interface uses React, TypeScript and Vite. Onboarding collects the clinic, viewer interests and format preferences. The web app sends the profile to FastAPI and saves the returned plan in local storage so the player can read it and play the blocks in order.

Clinic staff sign in to a separate dashboard via Supabase Auth to manage content and users and view metrics. The project also includes a direct video search experience.

Backend · Turning a catalogue into a session

FastAPI queries a Supabase/PostgreSQL catalogue containing shared videos and clinic-specific material. Selection uses categories, tags, language, duration and viewing history. If the catalogue has too little content, the service can broaden the search to YouTube. The final length depends on what is available.

The database stores the video plan separately from the viewing session that uses it. This lets the system track usage by device and clinic and report it in the dashboard.

The experience in screenshots

These screenshots come from the project and the interface running locally. Select an image to view it at full size.

Setup and preferences

Welcome screen in the mobile tutorial
Welcome screen in the mobile tutorial
Instructions for taking care of the headset
Instructions for taking care of the headset
Headphone connection step
Headphone connection step
Selecting the primary content goal
Selecting the primary content goal

Using the headset

Phone orientation check in the desktop simulator
Phone orientation check in the desktop simulator
Interpupillary distance calibration screen before enabling the camera
Interpupillary distance calibration screen before enabling the camera
Headset tutorial welcome screen
Headset tutorial welcome screen

Search and playback

Search menu with suggested topics and microphone control
Search menu with suggested topics and microphone control
Listening indicator during voice search
Listening indicator during voice search
Video playback with pause, skip and recenter controls
Video playback with pause, skip and recenter controls

Clinic operations

Clinic dashboard using a demo account with no patient data
Clinic dashboard using a demo account with no patient data
Catalogue management using the same demo account
Catalogue management using the same demo account

AI · How the recommender works

GlassPlay contains two recommendation paths. The search backend retrieves videos using embeddings and text matches. The session backend turns a viewer profile into playback blocks, with a fast rule-based path and a separate path that uses a language model for curation.

An example · From interests to videos

Imagine a viewer who chooses sports, adds travel as a secondary interest and prefers short clips. GlassPlay can use that profile to make two different decisions.

  1. Recommend the next video

    The feed retrieves candidates based on the viewer’s interests and profile vector. Lexical search finds direct matches, while vector search can find something like “post-run recovery routine” even when its title lacks the word “sports”. The ranking combines the two signals and gives repetitive content lower priority.

  2. Plan the whole stay

    The fast generator puts the pieces in sequence. A welcome video can come from the clinic’s own catalogue, the main block can cover sports, relaxation can focus on breathing, and lighter interests can include travel. The closing block returns to clinic material when available.

  3. Fit the plan to available videos

    The API tries to cover each block with suitable video lengths. If the first search yields too little content, it broadens the filters and can fall back to YouTube. The returned plan records target time and covered time separately. This example illustrates the logic and does not represent a real viewing session.

Configured block targets in the fast generator. They add up to 59 minutes before the plan is adjusted to available videos.
BlockConfigured targetExample content
Clinic introduction7 minClinic welcome
Main topic13 minSports technique or recovery
Relaxation20 minBreathing or calm music
Lighter interests12 minShort travel videos
Clinic closing7 minClinic closing video

Indexing · From video to vector

Indexing · From video to vector
  1. CatalogueTitle, context and transcript where available
  2. Sentence TransformersBAAI/bge-m3 · normalized vector
  3. PostgreSQL + pgvectorVideo ID and metadata via vecs

The indexer builds one text representation per video and encodes it with Sentence Transformers. The configured default is BAAI/bge-m3, whose dense vector has 1,024 dimensions. Both documents and queries are L2-normalized. The content_embeddings collection is created with the encoder’s output dimension and a cosine-distance index. The ID is later used to retrieve the full record from content_items.

Retrieval · From query to ranking

Retrieval · From query to ranking
  1. Query + clinicFor example, “guided breathing”
  2. Hybrid retrievalText matches + vector neighbours
  3. RRF fusionCombined ranking by position
  4. Video listCatalogue records and scores

Lexical branch. The function is called bm25_search. This checkout uses ILIKE against titles and context and text matching against tags. These matches receive fixed scores of 1.0, 0.8 and 0.6 respectively.

Vector branch. The service encodes the query with the same model and asks vecs for the nearest vectors. For a clinic-scoped query, it overfetches candidates and keeps that clinic’s videos and the shared catalogue. The adapter exposes a similarity proxy derived from position, while nearest-neighbour order comes from the vector query.

Reciprocal Rank Fusion (RRF). The service adds 1 / (60 + rank) for each result list in which a video appears. For example, a candidate ranked first in vector search and third in lexical search scores 1/61 + 1/63 ≈ 0.0323. Using ranks lets the service combine both signals without calibrating their scores. POST /search/ uses a module named rerank_simple that preserves the order and truncates the list. The repository also contains a separate cross-encoder implementation.

Illustrative example. A query for “guided breathing” can retrieve a video titled “Five-minute relaxation exercise” if the video’s context places it near the query in vector space.

Personalizing the feed

The POST /search/personalized endpoint starts from the viewing session. Each search combines the query ranking with nearest neighbours of the profile vector. The recommender passes a 60% query weight and a 40% profile weight to that fusion. The profile vector can be reused for 24 hours if the profile hash still matches. After collecting results across interests, the feed removes duplicates and recently viewed videos, and improves variety by penalizing repeated tags and context.

Session generation · Rules and LLM curation

Session generation · Rules and LLM curation
  1. Profile and durationClinic, interests, format and time target
  2. Selection by blockFilters, history and catalogue
  3. Playback planVideo IDs and duration per block

Fast path — POST /api/v1/sessions/v2/generate-fast. The service queries the catalogue in stages. It starts with stricter filters, relaxes them, and broadens categories through text matching. Where a profile is available, it checks history to reduce repeats and tries to fill each block’s duration. If too few candidates are available, it can fall back to YouTube. Relevance on this path is calculated from metadata and rules.

Curation path — POST /api/v1/sessions/v2/generate. The service configures gpt-4o-mini to propose search terms and filters, evaluate batches of candidates and suggest a sequence. It uses structured responses with Pydantic schemas. The final selection resolves IDs against the candidate batch, so the player receives videos from the catalogue.

Where does RAG fit? The curation path retrieves candidates and supplies their metadata to the LLM as context. It applies the retrieval-and-generation pattern to a recommendation decision. Vector search and LLM curation follow distinct code paths. Embeddings retrieve videos, and the LLM helps select and order existing candidates.