Skip to main content

Documentation Index

Fetch the complete documentation index at: https://learn.social.plus/llms.txt

Use this file to discover all available pages before exploring further.

Advanced Broadcasting Features

Take your live streaming to the next level with social.plus SDK’s advanced broadcasting features. This guide covers professional-grade capabilities for creating engaging, high-quality streaming experiences.

Multi-streaming

Broadcast to Multiple Platforms

Stream simultaneously to multiple platforms and social networks:
import { SocialPlusVideo } from '@social-plus/video-sdk';

const broadcaster = new SocialPlusVideo({
  apiKey: 'your-api-key',
  mode: 'broadcaster'
});

// Configure multiple streaming destinations
await broadcaster.configureMultiStream([
  {
    platform: 'youtube',
    streamKey: 'your-youtube-stream-key',
    rtmpUrl: 'rtmp://a.rtmp.youtube.com/live2'
  },
  {
    platform: 'facebook',
    streamKey: 'your-facebook-stream-key',
    rtmpUrl: 'rtmps://live-api-s.facebook.com:443/rtmp'
  },
  {
    platform: 'socialplus',
    streamKey: 'auto-generated',
    rtmpUrl: 'auto-configured'
  }
]);

// Start multi-streaming
await broadcaster.startMultiStream();

Custom RTMP Endpoints

// Add custom RTMP destinations
await broadcaster.addRTMPDestination({
  name: 'Custom Platform',
  rtmpUrl: 'rtmp://custom.streaming.platform/live',
  streamKey: 'your-custom-stream-key',
  maxBitrate: 6000,
  maxResolution: '1080p'
});

Screen Sharing

Desktop Screen Sharing

// Start screen sharing (Web)
await broadcaster.startScreenShare({
  includeAudio: true,
  cursor: 'always', // 'always', 'motion', 'never'
  displaySurface: 'monitor' // 'monitor', 'window', 'application'
});

// Picture-in-picture with camera
await broadcaster.enablePictureInPicture({
  position: 'bottom-right',
  size: 'small', // 'small', 'medium', 'large'
  cameraEnabled: true
});

Mobile Screen Recording

// iOS Screen Recording
await broadcaster.startScreenRecording({
  includeAudio: true,
  microphoneEnabled: true,
  cameraOverlay: {
    enabled: true,
    position: 'top-right',
    size: 'small'
  }
});

// Android Screen Capture
await broadcaster.startScreenCapture({
  mediaProjection: true,
  audioCapture: true,
  notification: {
    title: 'Live Streaming',
    text: 'Screen is being shared'
  }
});

Audio Management

Advanced Audio Features

// Audio mixing and effects
await broadcaster.configureAudio({
  // Noise suppression
  noiseSuppression: true,
  
  // Echo cancellation
  echoCancellation: true,
  
  // Auto gain control
  autoGainControl: true,
  
  // Audio effects
  effects: {
    reverb: 0.2,
    bass: 0.1,
    treble: 0.1
  },
  
  // Multiple audio sources
  sources: [
    { type: 'microphone', gain: 1.0 },
    { type: 'system', gain: 0.7 },
    { type: 'music', gain: 0.5 }
  ]
});

Background Music

// Add background music
await broadcaster.addBackgroundMusic({
  url: 'https://example.com/background-music.mp3',
  volume: 0.3,
  loop: true,
  fadeIn: 2000, // 2 seconds fade in
  fadeOut: 2000 // 2 seconds fade out
});

// Control music during stream
await broadcaster.adjustMusicVolume(0.5);
await broadcaster.pauseBackgroundMusic();
await broadcaster.resumeBackgroundMusic();

Interactive Features

Live Chat Integration

// Enable live chat
await broadcaster.enableLiveChat({
  moderation: true,
  wordFilter: true,
  slowMode: 5, // 5 seconds between messages
  subscriberOnly: false,
  emotesEnabled: true
});

// Handle chat events
broadcaster.on('chatMessage', (message) => {
  console.log(`${message.user}: ${message.text}`);
  
  // Moderate message
  if (containsSpam(message.text)) {
    broadcaster.moderateMessage(message.id, 'delete');
  }
});

// Send broadcaster messages
await broadcaster.sendChatMessage('Thanks for watching!');

Live Polls and Q&A

// Create live poll
const poll = await broadcaster.createPoll({
  question: 'What content would you like to see next?',
  options: ['Gaming', 'Tutorials', 'Music', 'Art'],
  duration: 60000, // 1 minute
  allowMultiple: false
});

// Handle poll results
broadcaster.on('pollVote', (vote) => {
  console.log(`Vote for ${vote.option}: ${vote.count} total votes`);
});

// Create Q&A session
await broadcaster.startQA({
  moderatedQuestions: true,
  allowAnonymous: false,
  questionLimit: 100
});

Viewer Interactions

// Handle viewer reactions
broadcaster.on('reaction', (reaction) => {
  // Show reaction animation
  showReactionAnimation(reaction.type, reaction.count);
});

// Enable viewer participation
await broadcaster.enableViewerFeatures({
  reactions: true,
  superChat: true,
  donations: true,
  follows: true,
  subscriptions: true
});

Stream Overlays and Graphics

Custom Overlays

// Add custom overlay
await broadcaster.addOverlay({
  type: 'image',
  src: 'https://example.com/overlay.png',
  position: { x: 10, y: 10 },
  size: { width: 200, height: 100 },
  opacity: 0.8,
  animation: 'fadeIn'
});

// Add text overlay
await broadcaster.addTextOverlay({
  text: 'Live from Conference 2024',
  position: 'bottom-center',
  style: {
    fontSize: 24,
    color: '#ffffff',
    backgroundColor: 'rgba(0,0,0,0.7)',
    padding: 10,
    borderRadius: 5
  }
});

Dynamic Overlays

// Viewer count overlay
await broadcaster.addDynamicOverlay({
  type: 'viewer-count',
  template: '👥 {count} viewers',
  position: 'top-right',
  updateInterval: 5000
});

// Stream statistics
await broadcaster.addDynamicOverlay({
  type: 'stream-stats',
  data: ['bitrate', 'fps', 'duration'],
  position: 'top-left',
  style: 'minimal'
});

Recording and VOD

Local Recording

// Start local recording
await broadcaster.startRecording({
  format: 'mp4',
  quality: '1080p',
  bitrate: 8000,
  localPath: '/recordings/stream-{timestamp}.mp4'
});

// Cloud recording
await broadcaster.startCloudRecording({
  provider: 'aws-s3',
  bucket: 'my-stream-recordings',
  format: 'mp4',
  segments: true, // Create segments for highlights
  thumbnails: true
});

Highlights and Clips

// Create highlight during stream
await broadcaster.createHighlight({
  duration: 30, // 30 seconds
  title: 'Epic Moment',
  description: 'Something amazing happened',
  tags: ['gaming', 'epic', 'funny']
});

// Allow viewers to create clips
await broadcaster.enableViewerClips({
  maxDuration: 60,
  cooldown: 300, // 5 minute cooldown
  moderation: true
});

Analytics and Insights

Real-time Analytics

// Get real-time stream analytics
const analytics = await broadcaster.getAnalytics();
console.log({
  viewers: analytics.currentViewers,
  peakViewers: analytics.peakViewers,
  avgWatchTime: analytics.averageWatchTime,
  engagement: analytics.engagementRate,
  quality: analytics.streamQuality
});

// Set up analytics events
broadcaster.on('analyticsUpdate', (data) => {
  updateDashboard(data);
});

Custom Metrics

// Track custom events
await broadcaster.trackEvent('game_started', {
  game: 'Minecraft',
  mode: 'survival',
  difficulty: 'hard'
});

await broadcaster.trackEvent('viewer_milestone', {
  count: 1000,
  timestamp: Date.now()
});

Advanced Stream Configuration

Adaptive Bitrate Streaming

// Configure ABR
await broadcaster.configureABR({
  profiles: [
    { resolution: '1080p', bitrate: 6000, fps: 60 },
    { resolution: '720p', bitrate: 3000, fps: 30 },
    { resolution: '480p', bitrate: 1500, fps: 30 },
    { resolution: '360p', bitrate: 800, fps: 30 }
  ],
  adaptationLogic: 'bandwidth', // 'bandwidth', 'buffer', 'hybrid'
  switchingStrategy: 'smooth' // 'smooth', 'aggressive', 'conservative'
});

Low Latency Configuration

// Ultra-low latency setup
await broadcaster.configureLowLatency({
  mode: 'ultra-low', // 'standard', 'low', 'ultra-low'
  bufferSize: 0.5, // seconds
  keyFrameInterval: 1, // seconds
  protocol: 'webrtc', // 'webrtc', 'srt', 'rtmp'
  prioritizeLatency: true
});

Custom Streaming Protocols

WebRTC Streaming

// Configure WebRTC
await broadcaster.configureWebRTC({
  iceServers: [
    { urls: 'stun:stun.l.google.com:19302' },
    { 
      urls: 'turn:your-turn-server.com:3478',
      username: 'user',
      credential: 'pass'
    }
  ],
  sdpSemantics: 'unified-plan',
  bundlePolicy: 'max-bundle'
});

SRT Streaming

// Configure SRT (Secure Reliable Transport)
await broadcaster.configureSRT({
  mode: 'caller', // 'caller', 'listener'
  latency: 120, // milliseconds
  encryption: true,
  passphrase: 'your-encryption-key',
  streamid: 'your-stream-id'
});

Error Recovery and Resilience

Automatic Recovery

// Configure automatic recovery
await broadcaster.configureRecovery({
  reconnection: {
    enabled: true,
    maxAttempts: 5,
    backoffStrategy: 'exponential',
    baseDelay: 1000
  },
  
  networkFailure: {
    detection: true,
    bufferThreshold: 5000,
    qualityDegradation: true
  },
  
  streamHealth: {
    monitoring: true,
    alertThreshold: 0.95,
    autoRestart: true
  }
});

Redundant Streaming

// Set up redundant streams
await broadcaster.configureRedundancy({
  primary: {
    server: 'primary.streaming.server',
    priority: 1
  },
  backup: [
    {
      server: 'backup1.streaming.server',
      priority: 2,
      failoverDelay: 5000
    },
    {
      server: 'backup2.streaming.server',
      priority: 3,
      failoverDelay: 10000
    }
  ]
});

Next Steps