🎬 Live Chat Example

VSRCPlayer with real-time WebSocket chat

Live Stream with Chat

Description: This example demonstrates VSRCPlayer with an integrated live chat feature. The chat uses WebSockets for real-time messaging and features a configurable color palette.
Note: Make sure the chat backend server is running on port 8080. Run cd chat_backend && npm install && npm start from the project root.
Status: Initializing...

Configuration

To change the server URL, modify the chat initialization code

Color Palette

Customize the chat appearance by changing the colors below:

About This Example

This example showcases:

Code Example:

// Initialize the video player with integrated chat
const player = new VSRCPlayer('#chat-player', {
    type: 'live',
    mediaId: 'demo-live-stream-789',
    chat: {
        element: '#chat-container',
        serverUrl: 'ws://localhost:8080',
        username: 'User123',
        colors: {
            background: '#1f1f1f',
            inputBackground: '#2a2a2a',
            userMessage: '#0e4c92',
            otherMessage: '#2a2a2a',
            systemMessage: '#666',
            text: '#ffffff',
            border: '#3a3a3a'
        },
        onMessage: (data) => {
            console.log('New message:', data);
        },
        onConnect: () => {
            console.log('Connected to chat');
        }
    },
    onReady: (player) => {
        console.log('Player ready');
    }
});

// Access chat via player
const chat = player.getChat();

Setup Instructions

  1. Navigate to the chat_backend directory
  2. Run npm install to install dependencies
  3. Run npm start to start the WebSocket server (default port: 8080)
  4. Open this HTML file in multiple browser windows to test the chat
  5. Messages sent in one window will appear in all other windows

Customization

You can customize the chat by: