Skip to content

Commit d9e84df

Browse files
committed
docs: Update README.md with detailed project information
1 parent 6860d20 commit d9e84df

1 file changed

Lines changed: 103 additions & 1 deletion

File tree

README.md

Lines changed: 103 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,106 @@ Welcome to `@interactive-video-labs/react` — a lightweight React wrapper aroun
1717

1818
This wrapper makes it easy to embed interactive video players in React apps using familiar props and event handlers, while keeping close to the core API.
1919

20-
---
20+
---
21+
22+
## Introduction
23+
24+
`@interactive-video-labs/react` is a thin React component that provides a convenient way to integrate interactive video experiences into your React applications. It leverages the powerful `@interactive-video-labs/core` engine, allowing you to easily manage video playback, cue points, and analytics within a familiar React paradigm.
25+
26+
## Features
27+
28+
* **Easy Integration**: Seamlessly embed interactive videos into your React components.
29+
* **Cue Point Management**: Load and manage cue points for dynamic video interactions.
30+
* **Analytics Events**: Receive detailed analytics events from the video player to track user engagement.
31+
* **Localization**: Support for player localization through translations.
32+
* **Direct Core API Access**: Provides a React-friendly interface while maintaining close alignment with the core IVLabsPlayer API.
33+
34+
## Installation
35+
36+
You can install the package using npm or pnpm:
37+
38+
```bash
39+
pnpm add @interactive-video-labs/react @interactive-video-labs/core react react-dom
40+
# or
41+
npm install @interactive-video-labs/react @interactive-video-labs/core react react-dom
42+
```
43+
44+
## Usage
45+
46+
To use the `InteractiveVideo` component, simply import it and pass the necessary props. The `videoUrl` prop is mandatory.
47+
48+
```tsx
49+
import React from 'react';
50+
import { InteractiveVideo } from '@interactive-video-labs/react';
51+
52+
const MyVideoPlayer = () => {
53+
return (
54+
<div style={{ width: '100%', maxWidth: '800px', margin: '0 auto' }}>
55+
<InteractiveVideo
56+
videoUrl="https://interactive-video-labs.github.io/interactive-video-demos/videos/big_buck_bunny.mp4"
57+
autoplay={true}
58+
loop={false}
59+
controls={true}
60+
onAnalyticsEvent={(event, payload) => {
61+
console.log('Analytics Event:', event, payload);
62+
// Handle analytics events, e.g., send to a tracking service
63+
}}
64+
cues={[
65+
{ time: 10, id: 'intro-cue', type: 'pause' },
66+
{ time: 25, id: 'question-cue', type: 'custom', data: { question: 'What is your favorite color?' } },
67+
]}
68+
translations={{
69+
en: {
70+
play: 'Play Video',
71+
pause: 'Pause Video',
72+
},
73+
}}
74+
/>
75+
</div>
76+
);
77+
};
78+
79+
export default MyVideoPlayer;
80+
```
81+
82+
## Props
83+
84+
The `InteractiveVideo` component accepts the following props:
85+
86+
* `videoUrl` (string, **required**): The URL of the video to be played.
87+
* `onAnalyticsEvent` (function, optional): A callback function that is triggered when an analytics event occurs. It receives the `event` name and an optional `payload`.
88+
* `event`: `PLAYER_LOADED`, `VIDEO_STARTED`, `VIDEO_PAUSED`, `VIDEO_ENDED`, `CUE_TRIGGERED`, `INTERACTION_COMPLETED`, `ERROR`.
89+
* `payload`: An object containing event-specific data.
90+
* `cues` (CuePoint[], optional): An array of cue points to load into the player. Each `CuePoint` object should conform to the `@interactive-video-labs/core` `CuePoint` interface.
91+
* `translations` (Translations, optional): An object containing translations for player localization. This should conform to the `@interactive-video-labs/core` `Translations` interface.
92+
* `...restOptions` (PlayerConfig, optional): Any other valid `PlayerConfig` options from `@interactive-video-labs/core` (excluding `videoUrl`, `cues`, and `translations`). This allows for direct pass-through of core player configurations like `autoplay`, `loop`, `controls`, `locale`, etc.
93+
94+
## Development
95+
96+
To set up the development environment:
97+
98+
1. Clone the repository.
99+
2. Install dependencies:
100+
```bash
101+
pnpm install
102+
```
103+
3. Build the project:
104+
```bash
105+
pnpm build
106+
```
107+
4. Run tests:
108+
```bash
109+
pnpm test
110+
```
111+
5. Run examples:
112+
```bash
113+
pnpm serve-examples
114+
```
115+
116+
## Contributing
117+
118+
We welcome contributions! Please see our [CONTRIBUTING.md](CONTRIBUTING.md) for more details.
119+
120+
## License
121+
122+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

0 commit comments

Comments
 (0)