@pictor-sdk/video-android 0.1.3 → 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/android/src/main/java/dev/pictor/video/CompositionSeek.kt +8 -0
- package/android/src/main/java/dev/pictor/video/CompositionSpike.kt +23 -13
- package/android/src/main/java/dev/pictor/video/CompositionVideoItem.kt +16 -0
- package/android/src/main/java/dev/pictor/video/CompositionWindow.kt +17 -0
- package/android/src/main/java/dev/pictor/video/FrameClock.kt +6 -1
- package/dist/index.d.mts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +23 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/compositionSpike.ts +9 -0
- 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,
|
|
@@ -586,6 +587,7 @@ function compositionSpikeSpec(project, mix, resolve) {
|
|
|
586
587
|
const playlist = playlistOf(project);
|
|
587
588
|
const items = [];
|
|
588
589
|
const unsupported = playlist.unsupported.map((u) => `${u.clipId}: ${u.reason}`);
|
|
590
|
+
const clips = new Map(project.clips.map((clip) => [clip.id, clip]));
|
|
589
591
|
for (const item of playlist.items) {
|
|
590
592
|
const uri = resolve(item.source);
|
|
591
593
|
if (uri === null) {
|
|
@@ -596,6 +598,8 @@ function compositionSpikeSpec(project, mix, resolve) {
|
|
|
596
598
|
uri,
|
|
597
599
|
startUs: Number(item.startUs),
|
|
598
600
|
endUs: Number(item.endUs),
|
|
601
|
+
sourceDurationUs: clips.get(item.clipId)?.metadata.duration,
|
|
602
|
+
timelineEndUs: Number(item.timelineEndUs),
|
|
599
603
|
speed: item.speed
|
|
600
604
|
});
|
|
601
605
|
}
|
|
@@ -792,10 +796,26 @@ function useCompositionPlayback(options) {
|
|
|
792
796
|
setUnsupported(
|
|
793
797
|
refused.map((reason) => ({ clipId: reason.split(":")[0] ?? "", reason }))
|
|
794
798
|
);
|
|
795
|
-
if (spec.items.length === 0)
|
|
799
|
+
if (spec.items.length === 0) {
|
|
800
|
+
spikePause();
|
|
801
|
+
return;
|
|
802
|
+
}
|
|
796
803
|
const started = spikeStart(spec);
|
|
797
804
|
if (started.ok === true) loaded.current = signature;
|
|
798
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]);
|
|
799
819
|
useEffect2(() => {
|
|
800
820
|
return () => {
|
|
801
821
|
lifecycle.teardown("unmount");
|
|
@@ -887,7 +907,7 @@ import {
|
|
|
887
907
|
windowToProjectTime
|
|
888
908
|
} from "@pictor-sdk/video-core";
|
|
889
909
|
import { useCallback as useCallback3, useEffect as useEffect3, useMemo as useMemo2, useRef as useRef3, useState as useState3 } from "react";
|
|
890
|
-
import { AppState as
|
|
910
|
+
import { AppState as AppState3 } from "react-native";
|
|
891
911
|
|
|
892
912
|
// src/surfaceRecovery.ts
|
|
893
913
|
var RECOVERY_GRACE_MS = 1500;
|
|
@@ -979,7 +999,7 @@ function useMedia3Playback(options) {
|
|
|
979
999
|
const lifecycle = lifecycleRef.current;
|
|
980
1000
|
const [lifecycleEpoch, setLifecycleEpoch] = useState3(lifecycle.epoch);
|
|
981
1001
|
useEffect3(() => {
|
|
982
|
-
const subscription =
|
|
1002
|
+
const subscription = AppState3.addEventListener("change", (next) => {
|
|
983
1003
|
if (next === "active") {
|
|
984
1004
|
lifecycle.resume();
|
|
985
1005
|
setLifecycleEpoch(lifecycle.epoch);
|