Hiyve Components - v1.0.0
    Preparing search index...
    • Hook to access mood analysis functionality.

      Returns MoodAnalysisContextValue

      The mood analysis context value

      This hook must be used within a MoodAnalysisProvider. It provides access to mood states and methods for registering video elements.

      Basic usage:

      function VideoRoom() {
      const { moodStates, addVideo, removeVideo } = useMoodAnalysis();

      // Register a video element when it mounts
      const handleVideoRef = (userId: string) => (el: HTMLVideoElement | null) => {
      if (el) {
      addVideo(userId, el);
      } else {
      removeVideo(userId);
      }
      };

      // Access mood state for a participant
      const participantMood = moodStates.get('user-123');
      console.log(participantMood?.emotion); // 'happy', 'sad', etc.

      return (
      <video ref={handleVideoRef('user-123')} />
      );
      }

      Mapping mood states to VideoGrid participants:

      function VideoRoom() {
      const { moodStates, addVideo, removeVideo, ready } = useMoodAnalysis();
      const [participants, setParticipants] = useState([]);

      // Map mood states to participant data
      const participantsWithMood = participants.map(p => ({
      ...p,
      moodData: moodStates.get(p.userId)
      ? {
      mood: moodStates.get(p.userId)!.emotion,
      confidence: moodStates.get(p.userId)!.confidence,
      timestamp: moodStates.get(p.userId)!.timestamp,
      }
      : undefined,
      }));

      return (
      <VideoGrid
      participants={participantsWithMood}
      showMood={ready}
      />
      );
      }

      Error if used outside of MoodAnalysisProvider