VSRCPlayer with real-time WebSocket chat
cd chat_backend && npm install && npm start from the project root.
Customize the chat appearance by changing the colors below:
This example showcases:
// 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();
chat_backend directorynpm install to install dependenciesnpm start to start the WebSocket server (default port: 8080)You can customize the chat by: