@pictor-sdk/video-android 0.1.4 → 0.1.5

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/dist/index.js CHANGED
@@ -714,6 +714,7 @@ function useVideoSurface(options) {
714
714
 
715
715
  // src/useCompositionPlayback.ts
716
716
  var import_react2 = require("react");
717
+ var import_react_native3 = require("react-native");
717
718
  var import_video_core2 = require("@pictor-sdk/video-core");
718
719
 
719
720
  // src/compositionSpike.ts
@@ -931,10 +932,26 @@ function useCompositionPlayback(options) {
931
932
  setUnsupported(
932
933
  refused.map((reason) => ({ clipId: reason.split(":")[0] ?? "", reason }))
933
934
  );
934
- if (spec.items.length === 0) return;
935
+ if (spec.items.length === 0) {
936
+ spikePause();
937
+ return;
938
+ }
935
939
  const started = spikeStart(spec);
936
940
  if (started.ok === true) loaded.current = signature;
937
941
  }, [enabled, signature, surfaceGeneration, project, mix]);
942
+ (0, import_react2.useEffect)(() => {
943
+ const subscription = import_react_native3.AppState.addEventListener("change", (next) => {
944
+ if (next === "active") {
945
+ lifecycle.resume();
946
+ setLifecycleEpoch(lifecycle.epoch);
947
+ return;
948
+ }
949
+ lifecycle.suspend("background");
950
+ setLifecycleEpoch(lifecycle.epoch);
951
+ setPlaying(false);
952
+ });
953
+ return () => subscription.remove();
954
+ }, [lifecycle]);
938
955
  (0, import_react2.useEffect)(() => {
939
956
  return () => {
940
957
  lifecycle.teardown("unmount");
@@ -1019,7 +1036,7 @@ function useCompositionPlayback(options) {
1019
1036
  // src/useMedia3Playback.ts
1020
1037
  var import_video_core3 = require("@pictor-sdk/video-core");
1021
1038
  var import_react3 = require("react");
1022
- var import_react_native3 = require("react-native");
1039
+ var import_react_native4 = require("react-native");
1023
1040
 
1024
1041
  // src/surfaceRecovery.ts
1025
1042
  var RECOVERY_GRACE_MS = 1500;
@@ -1111,7 +1128,7 @@ function useMedia3Playback(options) {
1111
1128
  const lifecycle = lifecycleRef.current;
1112
1129
  const [lifecycleEpoch, setLifecycleEpoch] = (0, import_react3.useState)(lifecycle.epoch);
1113
1130
  (0, import_react3.useEffect)(() => {
1114
- const subscription = import_react_native3.AppState.addEventListener("change", (next) => {
1131
+ const subscription = import_react_native4.AppState.addEventListener("change", (next) => {
1115
1132
  if (next === "active") {
1116
1133
  lifecycle.resume();
1117
1134
  setLifecycleEpoch(lifecycle.epoch);