@conference-kit/react 0.0.5 → 0.0.6

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.
@@ -1 +1 @@
1
- {"version":3,"file":"VideoPlayer.d.ts","sourceRoot":"","sources":["../../src/components/VideoPlayer.tsx"],"names":[],"mappings":"AAEA,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,GAAG;IAC3E,MAAM,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;CAC7B,CAAC;AAEF,wBAAgB,WAAW,CAAC,EAC1B,MAAM,EACN,QAAe,EACf,WAAkB,EAClB,KAAK,EACL,GAAG,KAAK,EACT,EAAE,gBAAgB,2CAoBlB"}
1
+ {"version":3,"file":"VideoPlayer.d.ts","sourceRoot":"","sources":["../../src/components/VideoPlayer.tsx"],"names":[],"mappings":"AAEA,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,GAAG;IAC3E,MAAM,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;CAC7B,CAAC;AAEF,wBAAgB,WAAW,CAAC,EAC1B,MAAM,EACN,QAAe,EACf,WAAkB,EAClB,KAAK,EACL,GAAG,KAAK,EACT,EAAE,gBAAgB,2CAsClB"}
@@ -2,13 +2,27 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useEffect, useRef } from "react";
3
3
  export function VideoPlayer({ stream, autoPlay = true, playsInline = true, muted, ...props }) {
4
4
  const ref = useRef(null);
5
+ const prevStream = useRef(null);
5
6
  useEffect(() => {
6
- if (!ref.current || !stream)
7
+ const el = ref.current;
8
+ if (!el)
7
9
  return;
8
- ref.current.srcObject = stream;
10
+ // Avoid resetting srcObject if the exact same MediaStream instance is already attached.
11
+ if (stream && prevStream.current !== stream) {
12
+ el.srcObject = stream;
13
+ prevStream.current = stream;
14
+ }
15
+ // Kick playback on mobile where autoplay can be flaky even when muted.
16
+ if (stream) {
17
+ el.play().catch(() => {
18
+ /* ignore autoplay rejection; user gesture will resume */
19
+ });
20
+ }
9
21
  return () => {
10
- if (ref.current)
11
- ref.current.srcObject = null;
22
+ if (el) {
23
+ el.srcObject = null;
24
+ prevStream.current = null;
25
+ }
12
26
  };
13
27
  }, [stream]);
14
28
  return (_jsx("video", { ref: ref, autoPlay: autoPlay, playsInline: playsInline, muted: muted ?? stream == null, ...props }));
@@ -1 +1 @@
1
- {"version":3,"file":"VideoPlayer.js","sourceRoot":"","sources":["../../src/components/VideoPlayer.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAM1C,MAAM,UAAU,WAAW,CAAC,EAC1B,MAAM,EACN,QAAQ,GAAG,IAAI,EACf,WAAW,GAAG,IAAI,EAClB,KAAK,EACL,GAAG,KAAK,EACS;IACjB,MAAM,GAAG,GAAG,MAAM,CAA0B,IAAI,CAAC,CAAC;IAElD,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,GAAG,CAAC,OAAO,IAAI,CAAC,MAAM;YAAE,OAAO;QACpC,GAAG,CAAC,OAAO,CAAC,SAAS,GAAG,MAAM,CAAC;QAC/B,OAAO,GAAG,EAAE;YACV,IAAI,GAAG,CAAC,OAAO;gBAAE,GAAG,CAAC,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;QAChD,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,OAAO,CACL,gBACE,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,KAAK,IAAI,MAAM,IAAI,IAAI,KAC1B,KAAK,GACT,CACH,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"VideoPlayer.js","sourceRoot":"","sources":["../../src/components/VideoPlayer.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAM1C,MAAM,UAAU,WAAW,CAAC,EAC1B,MAAM,EACN,QAAQ,GAAG,IAAI,EACf,WAAW,GAAG,IAAI,EAClB,KAAK,EACL,GAAG,KAAK,EACS;IACjB,MAAM,GAAG,GAAG,MAAM,CAA0B,IAAI,CAAC,CAAC;IAClD,MAAM,UAAU,GAAG,MAAM,CAAqB,IAAI,CAAC,CAAC;IAEpD,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC;QACvB,IAAI,CAAC,EAAE;YAAE,OAAO;QAEhB,wFAAwF;QACxF,IAAI,MAAM,IAAI,UAAU,CAAC,OAAO,KAAK,MAAM,EAAE,CAAC;YAC5C,EAAE,CAAC,SAAS,GAAG,MAAM,CAAC;YACtB,UAAU,CAAC,OAAO,GAAG,MAAM,CAAC;QAC9B,CAAC;QAED,uEAAuE;QACvE,IAAI,MAAM,EAAE,CAAC;YACX,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE;gBACnB,yDAAyD;YAC3D,CAAC,CAAC,CAAC;QACL,CAAC;QAED,OAAO,GAAG,EAAE;YACV,IAAI,EAAE,EAAE,CAAC;gBACP,EAAE,CAAC,SAAS,GAAG,IAAI,CAAC;gBACpB,UAAU,CAAC,OAAO,GAAG,IAAI,CAAC;YAC5B,CAAC;QACH,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,OAAO,CACL,gBACE,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,KAAK,IAAI,MAAM,IAAI,IAAI,KAC1B,KAAK,GACT,CACH,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@conference-kit/react",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -12,12 +12,30 @@ export function VideoPlayer({
12
12
  ...props
13
13
  }: VideoPlayerProps) {
14
14
  const ref = useRef<HTMLVideoElement | null>(null);
15
+ const prevStream = useRef<MediaStream | null>(null);
15
16
 
16
17
  useEffect(() => {
17
- if (!ref.current || !stream) return;
18
- ref.current.srcObject = stream;
18
+ const el = ref.current;
19
+ if (!el) return;
20
+
21
+ // Avoid resetting srcObject if the exact same MediaStream instance is already attached.
22
+ if (stream && prevStream.current !== stream) {
23
+ el.srcObject = stream;
24
+ prevStream.current = stream;
25
+ }
26
+
27
+ // Kick playback on mobile where autoplay can be flaky even when muted.
28
+ if (stream) {
29
+ el.play().catch(() => {
30
+ /* ignore autoplay rejection; user gesture will resume */
31
+ });
32
+ }
33
+
19
34
  return () => {
20
- if (ref.current) ref.current.srcObject = null;
35
+ if (el) {
36
+ el.srcObject = null;
37
+ prevStream.current = null;
38
+ }
21
39
  };
22
40
  }, [stream]);
23
41