@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 +20 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/useCompositionPlayback.ts +55 -1
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,
|
|
@@ -795,10 +796,26 @@ function useCompositionPlayback(options) {
|
|
|
795
796
|
setUnsupported(
|
|
796
797
|
refused.map((reason) => ({ clipId: reason.split(":")[0] ?? "", reason }))
|
|
797
798
|
);
|
|
798
|
-
if (spec.items.length === 0)
|
|
799
|
+
if (spec.items.length === 0) {
|
|
800
|
+
spikePause();
|
|
801
|
+
return;
|
|
802
|
+
}
|
|
799
803
|
const started = spikeStart(spec);
|
|
800
804
|
if (started.ok === true) loaded.current = signature;
|
|
801
805
|
}, [enabled, signature, surfaceGeneration, project, mix]);
|
|
806
|
+
useEffect2(() => {
|
|
807
|
+
const subscription = AppState2.addEventListener("change", (next) => {
|
|
808
|
+
if (next === "active") {
|
|
809
|
+
lifecycle.resume();
|
|
810
|
+
setLifecycleEpoch(lifecycle.epoch);
|
|
811
|
+
return;
|
|
812
|
+
}
|
|
813
|
+
lifecycle.suspend("background");
|
|
814
|
+
setLifecycleEpoch(lifecycle.epoch);
|
|
815
|
+
setPlaying(false);
|
|
816
|
+
});
|
|
817
|
+
return () => subscription.remove();
|
|
818
|
+
}, [lifecycle]);
|
|
802
819
|
useEffect2(() => {
|
|
803
820
|
return () => {
|
|
804
821
|
lifecycle.teardown("unmount");
|
|
@@ -890,7 +907,7 @@ import {
|
|
|
890
907
|
windowToProjectTime
|
|
891
908
|
} from "@pictor-sdk/video-core";
|
|
892
909
|
import { useCallback as useCallback3, useEffect as useEffect3, useMemo as useMemo2, useRef as useRef3, useState as useState3 } from "react";
|
|
893
|
-
import { AppState as
|
|
910
|
+
import { AppState as AppState3 } from "react-native";
|
|
894
911
|
|
|
895
912
|
// src/surfaceRecovery.ts
|
|
896
913
|
var RECOVERY_GRACE_MS = 1500;
|
|
@@ -982,7 +999,7 @@ function useMedia3Playback(options) {
|
|
|
982
999
|
const lifecycle = lifecycleRef.current;
|
|
983
1000
|
const [lifecycleEpoch, setLifecycleEpoch] = useState3(lifecycle.epoch);
|
|
984
1001
|
useEffect3(() => {
|
|
985
|
-
const subscription =
|
|
1002
|
+
const subscription = AppState3.addEventListener("change", (next) => {
|
|
986
1003
|
if (next === "active") {
|
|
987
1004
|
lifecycle.resume();
|
|
988
1005
|
setLifecycleEpoch(lifecycle.epoch);
|