@stream-io/video-react-sdk 1.0.12 → 1.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/index.cjs.js +24 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +25 -3
- package/dist/index.es.js.map +1 -1
- package/dist/src/wrappers/LivestreamPlayer/LivestreamPlayer.d.ts +16 -0
- package/dist/src/wrappers/LivestreamPlayer/index.d.ts +1 -0
- package/dist/src/wrappers/index.d.ts +1 -0
- package/index.ts +1 -0
- package/package.json +1 -1
- package/src/wrappers/LivestreamPlayer/LivestreamPlayer.tsx +49 -0
- package/src/wrappers/LivestreamPlayer/index.ts +1 -0
- package/src/wrappers/index.ts +1 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { LivestreamLayoutProps } from '../../core';
|
|
2
|
+
export type LivestreamPlayerProps = {
|
|
3
|
+
/**
|
|
4
|
+
* The call type. Usually `livestream`.
|
|
5
|
+
*/
|
|
6
|
+
callType: string;
|
|
7
|
+
/**
|
|
8
|
+
* The call ID.
|
|
9
|
+
*/
|
|
10
|
+
callId: string;
|
|
11
|
+
/**
|
|
12
|
+
* The props for the {@link LivestreamLayout} component.
|
|
13
|
+
*/
|
|
14
|
+
layoutProps?: LivestreamLayoutProps;
|
|
15
|
+
};
|
|
16
|
+
export declare const LivestreamPlayer: (props: LivestreamPlayerProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './LivestreamPlayer';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './LivestreamPlayer';
|
package/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { Call } from '@stream-io/video-client';
|
|
3
|
+
import { useStreamVideoClient } from '@stream-io/video-react-bindings';
|
|
4
|
+
import {
|
|
5
|
+
LivestreamLayout,
|
|
6
|
+
LivestreamLayoutProps,
|
|
7
|
+
StreamCall,
|
|
8
|
+
} from '../../core';
|
|
9
|
+
|
|
10
|
+
export type LivestreamPlayerProps = {
|
|
11
|
+
/**
|
|
12
|
+
* The call type. Usually `livestream`.
|
|
13
|
+
*/
|
|
14
|
+
callType: string;
|
|
15
|
+
/**
|
|
16
|
+
* The call ID.
|
|
17
|
+
*/
|
|
18
|
+
callId: string;
|
|
19
|
+
/**
|
|
20
|
+
* The props for the {@link LivestreamLayout} component.
|
|
21
|
+
*/
|
|
22
|
+
layoutProps?: LivestreamLayoutProps;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const LivestreamPlayer = (props: LivestreamPlayerProps) => {
|
|
26
|
+
const { callType, callId, layoutProps } = props;
|
|
27
|
+
const client = useStreamVideoClient();
|
|
28
|
+
const [call, setCall] = useState<Call>();
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
if (!client) return;
|
|
31
|
+
const myCall = client.call(callType, callId);
|
|
32
|
+
setCall(myCall);
|
|
33
|
+
myCall.join().catch((e) => {
|
|
34
|
+
console.error('Failed to join call', e);
|
|
35
|
+
});
|
|
36
|
+
return () => {
|
|
37
|
+
myCall.leave().catch((e) => {
|
|
38
|
+
console.error('Failed to leave call', e);
|
|
39
|
+
});
|
|
40
|
+
setCall(undefined);
|
|
41
|
+
};
|
|
42
|
+
}, [callId, callType, client]);
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<StreamCall call={call}>
|
|
46
|
+
<LivestreamLayout {...layoutProps} />
|
|
47
|
+
</StreamCall>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './LivestreamPlayer';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './LivestreamPlayer';
|