@pictor-sdk/video-android 0.1.4 → 0.1.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.
package/dist/index.mjs CHANGED
@@ -574,6 +574,7 @@ function useVideoSurface(options) {
574
574
 
575
575
  // src/useCompositionPlayback.ts
576
576
  import { useCallback as useCallback2, useEffect as useEffect2, useMemo, useRef as useRef2, useState as useState2 } from "react";
577
+ import { AppState as AppState2 } from "react-native";
577
578
  import {
578
579
  playIntent,
579
580
  playlistOf as playlistOf2,
@@ -747,7 +748,8 @@ function composedState(snapshot) {
747
748
  */
748
749
  width: 0,
749
750
  height: 0,
750
- error: snapshot.error ?? null
751
+ error: snapshot.error ?? null,
752
+ readinessFailure: snapshot.readinessFailure ?? null
751
753
  };
752
754
  }
753
755
  function useCompositionPlayback(options) {
@@ -795,10 +797,26 @@ function useCompositionPlayback(options) {
795
797
  setUnsupported(
796
798
  refused.map((reason) => ({ clipId: reason.split(":")[0] ?? "", reason }))
797
799
  );
798
- if (spec.items.length === 0) return;
800
+ if (spec.items.length === 0) {
801
+ spikePause();
802
+ return;
803
+ }
799
804
  const started = spikeStart(spec);
800
805
  if (started.ok === true) loaded.current = signature;
801
806
  }, [enabled, signature, surfaceGeneration, project, mix]);
807
+ useEffect2(() => {
808
+ const subscription = AppState2.addEventListener("change", (next) => {
809
+ if (next === "active") {
810
+ lifecycle.resume();
811
+ setLifecycleEpoch(lifecycle.epoch);
812
+ return;
813
+ }
814
+ lifecycle.suspend("background");
815
+ setLifecycleEpoch(lifecycle.epoch);
816
+ setPlaying(false);
817
+ });
818
+ return () => subscription.remove();
819
+ }, [lifecycle]);
802
820
  useEffect2(() => {
803
821
  return () => {
804
822
  lifecycle.teardown("unmount");
@@ -890,7 +908,7 @@ import {
890
908
  windowToProjectTime
891
909
  } from "@pictor-sdk/video-core";
892
910
  import { useCallback as useCallback3, useEffect as useEffect3, useMemo as useMemo2, useRef as useRef3, useState as useState3 } from "react";
893
- import { AppState as AppState2 } from "react-native";
911
+ import { AppState as AppState3 } from "react-native";
894
912
 
895
913
  // src/surfaceRecovery.ts
896
914
  var RECOVERY_GRACE_MS = 1500;
@@ -982,7 +1000,7 @@ function useMedia3Playback(options) {
982
1000
  const lifecycle = lifecycleRef.current;
983
1001
  const [lifecycleEpoch, setLifecycleEpoch] = useState3(lifecycle.epoch);
984
1002
  useEffect3(() => {
985
- const subscription = AppState2.addEventListener("change", (next) => {
1003
+ const subscription = AppState3.addEventListener("change", (next) => {
986
1004
  if (next === "active") {
987
1005
  lifecycle.resume();
988
1006
  setLifecycleEpoch(lifecycle.epoch);