@shopify/react-native-skia 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. package/android/cpp/rnskia-android/RNSkAndroidVideo.cpp +13 -0
  2. package/android/cpp/rnskia-android/RNSkAndroidVideo.h +1 -0
  3. package/android/src/main/java/com/shopify/reactnative/skia/RNSkVideo.java +9 -1
  4. package/cpp/api/JsiVideo.h +7 -0
  5. package/cpp/rnskia/RNSkVideo.h +1 -0
  6. package/ios/RNSkia-iOS/RNSkiOSVideo.h +2 -0
  7. package/ios/RNSkia-iOS/RNSkiOSVideo.mm +22 -2
  8. package/lib/commonjs/external/reanimated/useVideo.d.ts +8 -11
  9. package/lib/commonjs/external/reanimated/useVideo.js +34 -64
  10. package/lib/commonjs/external/reanimated/useVideo.js.map +1 -1
  11. package/lib/commonjs/external/reanimated/video.d.ts +16 -0
  12. package/lib/commonjs/external/reanimated/video.js +54 -0
  13. package/lib/commonjs/external/reanimated/video.js.map +1 -0
  14. package/lib/commonjs/skia/types/Video/Video.d.ts +1 -0
  15. package/lib/commonjs/skia/types/Video/Video.js.map +1 -1
  16. package/lib/commonjs/skia/types/index.d.ts +1 -0
  17. package/lib/commonjs/skia/types/index.js +11 -0
  18. package/lib/commonjs/skia/types/index.js.map +1 -1
  19. package/lib/module/external/reanimated/useVideo.d.ts +8 -11
  20. package/lib/module/external/reanimated/useVideo.js +35 -65
  21. package/lib/module/external/reanimated/useVideo.js.map +1 -1
  22. package/lib/module/external/reanimated/video.d.ts +16 -0
  23. package/lib/module/external/reanimated/video.js +46 -0
  24. package/lib/module/external/reanimated/video.js.map +1 -0
  25. package/lib/module/skia/types/Video/Video.d.ts +1 -0
  26. package/lib/module/skia/types/Video/Video.js.map +1 -1
  27. package/lib/module/skia/types/index.d.ts +1 -0
  28. package/lib/module/skia/types/index.js +1 -0
  29. package/lib/module/skia/types/index.js.map +1 -1
  30. package/lib/typescript/src/external/reanimated/useVideo.d.ts +8 -11
  31. package/lib/typescript/src/external/reanimated/video.d.ts +16 -0
  32. package/lib/typescript/src/skia/types/Video/Video.d.ts +1 -0
  33. package/lib/typescript/src/skia/types/index.d.ts +1 -0
  34. package/package.json +1 -1
  35. package/src/external/reanimated/useVideo.ts +37 -85
  36. package/src/external/reanimated/video.ts +82 -0
  37. package/src/skia/types/Video/Video.ts +1 -0
  38. package/src/skia/types/index.ts +1 -0
@@ -67,6 +67,7 @@ double RNSkAndroidVideo::duration() {
67
67
  }
68
68
  return env->CallDoubleMethod(_jniVideo.get(), mid);
69
69
  }
70
+
70
71
  double RNSkAndroidVideo::framerate() {
71
72
  JNIEnv *env = facebook::jni::Environment::current();
72
73
  jclass cls = env->GetObjectClass(_jniVideo.get());
@@ -89,4 +90,16 @@ void RNSkAndroidVideo::seek(double timestamp) {
89
90
  env->CallVoidMethod(_jniVideo.get(), mid, static_cast<jlong>(timestamp));
90
91
  }
91
92
 
93
+ float RNSkAndroidVideo::getRotationInDegrees() {
94
+ JNIEnv *env = facebook::jni::Environment::current();
95
+ jclass cls = env->GetObjectClass(_jniVideo.get());
96
+ jmethodID mid = env->GetMethodID(cls, "getRotationDegrees", "()I");
97
+ if (!mid) {
98
+ RNSkLogger::logToConsole("getRotationDegrees method not found");
99
+ return 0;
100
+ }
101
+ auto rotation = env->CallIntMethod(_jniVideo.get(), mid);
102
+ return static_cast<float>(rotation);
103
+ }
104
+
92
105
  } // namespace RNSkia
@@ -31,6 +31,7 @@ public:
31
31
  double duration() override;
32
32
  double framerate() override;
33
33
  void seek(double timestamp) override;
34
+ float getRotationInDegrees() override;
34
35
  };
35
36
 
36
37
  } // namespace RNSkia
@@ -29,6 +29,7 @@ public class RNSkVideo {
29
29
  private Surface outputSurface;
30
30
  private double durationMs;
31
31
  private double frameRate;
32
+ private int rotationDegrees = 0;
32
33
 
33
34
  RNSkVideo(Context context, String localUri) {
34
35
  this.uri = Uri.parse(localUri);
@@ -53,6 +54,9 @@ public class RNSkVideo {
53
54
  if (format.containsKey(MediaFormat.KEY_FRAME_RATE)) {
54
55
  frameRate = format.getInteger(MediaFormat.KEY_FRAME_RATE);
55
56
  }
57
+ if (format.containsKey(MediaFormat.KEY_ROTATION)) {
58
+ rotationDegrees = format.getInteger(MediaFormat.KEY_ROTATION);
59
+ }
56
60
  int width = format.getInteger(MediaFormat.KEY_WIDTH);
57
61
  int height = format.getInteger(MediaFormat.KEY_HEIGHT);
58
62
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
@@ -87,11 +91,15 @@ public class RNSkVideo {
87
91
  }
88
92
 
89
93
  @DoNotStrip
90
-
91
94
  public double getFrameRate() {
92
95
  return frameRate;
93
96
  }
94
97
 
98
+ @DoNotStrip
99
+ public int getRotationDegrees() {
100
+ return rotationDegrees;
101
+ }
102
+
95
103
  @DoNotStrip
96
104
  public HardwareBuffer nextImage() {
97
105
  if (!decoderOutputAvailable()) {
@@ -53,10 +53,17 @@ public:
53
53
  return jsi::Value::undefined();
54
54
  }
55
55
 
56
+ JSI_HOST_FUNCTION(getRotationInDegrees) {
57
+ auto context = getContext();
58
+ auto rot = getObject()->getRotationInDegrees();
59
+ return jsi::Value(static_cast<double>(rot));
60
+ }
61
+
56
62
  JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiVideo, nextImage),
57
63
  JSI_EXPORT_FUNC(JsiVideo, duration),
58
64
  JSI_EXPORT_FUNC(JsiVideo, framerate),
59
65
  JSI_EXPORT_FUNC(JsiVideo, seek),
66
+ JSI_EXPORT_FUNC(JsiVideo, getRotationInDegrees),
60
67
  JSI_EXPORT_FUNC(JsiVideo, dispose))
61
68
 
62
69
  JsiVideo(std::shared_ptr<RNSkPlatformContext> context,
@@ -18,6 +18,7 @@ public:
18
18
  virtual double duration() = 0;
19
19
  virtual double framerate() = 0;
20
20
  virtual void seek(double timestamp) = 0;
21
+ virtual float getRotationInDegrees() = 0;
21
22
  };
22
23
 
23
24
  } // namespace RNSkia
@@ -27,6 +27,7 @@ private:
27
27
  double _framerate = 0;
28
28
  void setupReader(CMTimeRange timeRange);
29
29
  NSDictionary *getOutputSettings();
30
+ CGAffineTransform _preferredTransform;
30
31
 
31
32
  public:
32
33
  RNSkiOSVideo(std::string url, RNSkPlatformContext *context);
@@ -35,6 +36,7 @@ public:
35
36
  double duration() override;
36
37
  double framerate() override;
37
38
  void seek(double timestamp) override;
39
+ float getRotationInDegrees() override;
38
40
  };
39
41
 
40
42
  } // namespace RNSkia
@@ -1,5 +1,3 @@
1
- #pragma once
2
-
3
1
  #include <memory>
4
2
  #include <string>
5
3
 
@@ -46,6 +44,7 @@ void RNSkiOSVideo::setupReader(CMTimeRange timeRange) {
46
44
  AVAssetTrack *videoTrack =
47
45
  [[asset tracksWithMediaType:AVMediaTypeVideo] firstObject];
48
46
  _framerate = videoTrack.nominalFrameRate;
47
+ _preferredTransform = videoTrack.preferredTransform;
49
48
 
50
49
  NSDictionary *outputSettings = getOutputSettings();
51
50
  AVAssetReaderTrackOutput *trackOutput =
@@ -99,6 +98,27 @@ NSDictionary *RNSkiOSVideo::getOutputSettings() {
99
98
  };
100
99
  }
101
100
 
101
+ float RNSkiOSVideo::getRotationInDegrees() {
102
+ CGFloat rotationAngle = 0.0;
103
+ auto transform = _preferredTransform;
104
+ // Determine the rotation angle in radians
105
+ if (transform.a == 0 && transform.b == 1 && transform.c == -1 &&
106
+ transform.d == 0) {
107
+ rotationAngle = M_PI_2; // 90 degrees
108
+ } else if (transform.a == 0 && transform.b == -1 && transform.c == 1 &&
109
+ transform.d == 0) {
110
+ rotationAngle = -M_PI_2; // -90 degrees
111
+ } else if (transform.a == -1 && transform.b == 0 && transform.c == 0 &&
112
+ transform.d == -1) {
113
+ rotationAngle = M_PI; // 180 degrees
114
+ } else if (transform.a == 1 && transform.b == 0 && transform.c == 0 &&
115
+ transform.d == 1) {
116
+ rotationAngle = 0.0; // 0 degrees
117
+ }
118
+ // Convert the rotation angle from radians to degrees
119
+ return rotationAngle * 180 / M_PI;
120
+ }
121
+
102
122
  void RNSkiOSVideo::seek(double timeInMilliseconds) {
103
123
  if (_reader) {
104
124
  [_reader cancelReading];
@@ -1,12 +1,9 @@
1
- import { type SharedValue } from "react-native-reanimated";
2
1
  import type { SkImage } from "../../skia/types";
3
- type Animated<T> = SharedValue<T> | T;
4
- export interface PlaybackOptions {
5
- playbackSpeed: Animated<number>;
6
- looping: Animated<boolean>;
7
- paused: Animated<boolean>;
8
- seek: Animated<number | null>;
9
- currentTime: Animated<number>;
10
- }
11
- export declare const useVideo: (source: string | null, userOptions?: Partial<PlaybackOptions>) => SharedValue<SkImage | null>;
12
- export {};
2
+ import { type PlaybackOptions } from "./video";
3
+ export declare const useVideo: (source: string | null, userOptions?: Partial<PlaybackOptions>) => {
4
+ currentFrame: import("react-native-reanimated").SharedValue<SkImage | null>;
5
+ currentTime: import("react-native-reanimated").SharedValue<number>;
6
+ duration: number;
7
+ framerate: number;
8
+ rotationInDegrees: number;
9
+ };
@@ -4,11 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.useVideo = void 0;
7
- var _reactNativeReanimated = require("react-native-reanimated");
8
7
  var _react = require("react");
9
8
  var _Skia = require("../../skia/Skia");
10
- var _Platform = require("../../Platform");
11
9
  var _ReanimatedProxy = _interopRequireDefault(require("./ReanimatedProxy"));
10
+ var _video = require("./video");
12
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
12
  const defaultOptions = {
14
13
  playbackSpeed: 1,
@@ -21,85 +20,56 @@ const useOption = value => {
21
20
  "worklet";
22
21
 
23
22
  // TODO: only create defaultValue is needed (via makeMutable)
24
- const defaultValue = (0, _reactNativeReanimated.useSharedValue)(_ReanimatedProxy.default.isSharedValue(value) ? value.value : value);
23
+ const defaultValue = _ReanimatedProxy.default.useSharedValue(_ReanimatedProxy.default.isSharedValue(value) ? value.value : value);
25
24
  return _ReanimatedProxy.default.isSharedValue(value) ? value : defaultValue;
26
25
  };
26
+ const disposeVideo = video => {
27
+ "worklet";
28
+
29
+ video === null || video === void 0 || video.dispose();
30
+ };
27
31
  const useVideo = (source, userOptions) => {
28
- var _userOptions$paused, _userOptions$looping, _userOptions$seek, _userOptions$currentT, _userOptions$playback;
32
+ var _userOptions$paused, _userOptions$looping, _userOptions$seek, _userOptions$playback;
29
33
  const video = (0, _react.useMemo)(() => source ? _Skia.Skia.Video(source) : null, [source]);
30
34
  const isPaused = useOption((_userOptions$paused = userOptions === null || userOptions === void 0 ? void 0 : userOptions.paused) !== null && _userOptions$paused !== void 0 ? _userOptions$paused : defaultOptions.paused);
31
35
  const looping = useOption((_userOptions$looping = userOptions === null || userOptions === void 0 ? void 0 : userOptions.looping) !== null && _userOptions$looping !== void 0 ? _userOptions$looping : defaultOptions.looping);
32
36
  const seek = useOption((_userOptions$seek = userOptions === null || userOptions === void 0 ? void 0 : userOptions.seek) !== null && _userOptions$seek !== void 0 ? _userOptions$seek : defaultOptions.seek);
33
- const currentTime = useOption((_userOptions$currentT = userOptions === null || userOptions === void 0 ? void 0 : userOptions.currentTime) !== null && _userOptions$currentT !== void 0 ? _userOptions$currentT : defaultOptions.currentTime);
34
37
  const playbackSpeed = useOption((_userOptions$playback = userOptions === null || userOptions === void 0 ? void 0 : userOptions.playbackSpeed) !== null && _userOptions$playback !== void 0 ? _userOptions$playback : defaultOptions.playbackSpeed);
35
38
  const currentFrame = _ReanimatedProxy.default.useSharedValue(null);
39
+ const currentTime = _ReanimatedProxy.default.useSharedValue(0);
36
40
  const lastTimestamp = _ReanimatedProxy.default.useSharedValue(-1);
37
- const startTimestamp = _ReanimatedProxy.default.useSharedValue(-1);
38
- const framerate = (0, _react.useMemo)(() => video ? video.framerate() : -1, [video]);
39
- const duration = (0, _react.useMemo)(() => video ? video.duration() : -1, [video]);
40
- const frameDuration = (0, _react.useMemo)(() => framerate > 0 ? 1000 / framerate : -1, [framerate]);
41
- const disposeVideo = (0, _react.useCallback)(() => {
42
- "worklet";
43
-
44
- video === null || video === void 0 || video.dispose();
41
+ const duration = (0, _react.useMemo)(() => {
42
+ var _video$duration;
43
+ return (_video$duration = video === null || video === void 0 ? void 0 : video.duration()) !== null && _video$duration !== void 0 ? _video$duration : 0;
44
+ }, [video]);
45
+ const framerate = (0, _react.useMemo)(() => {
46
+ var _video$framerate;
47
+ return (_video$framerate = video === null || video === void 0 ? void 0 : video.framerate()) !== null && _video$framerate !== void 0 ? _video$framerate : 0;
48
+ }, [video]);
49
+ const rotationInDegrees = (0, _react.useMemo)(() => {
50
+ var _video$getRotationInD;
51
+ return (_video$getRotationInD = video === null || video === void 0 ? void 0 : video.getRotationInDegrees()) !== null && _video$getRotationInD !== void 0 ? _video$getRotationInD : 0;
45
52
  }, [video]);
46
53
  _ReanimatedProxy.default.useFrameCallback(frameInfo => {
47
- if (!video) {
48
- return;
49
- }
50
- if (seek.value !== null) {
51
- video.seek(seek.value);
52
- seek.value = null;
53
- lastTimestamp.value = -1;
54
- startTimestamp.value = -1;
55
- }
56
- if (isPaused.value && lastTimestamp.value !== -1) {
57
- return;
58
- }
59
- const {
60
- timestamp
61
- } = frameInfo;
62
-
63
- // Initialize start timestamp
64
- if (startTimestamp.value === -1) {
65
- startTimestamp.value = timestamp;
66
- }
67
-
68
- // Calculate the current time in the video
69
- const currentTimestamp = timestamp - startTimestamp.value;
70
- currentTime.value = currentTimestamp;
71
-
72
- // Handle looping
73
- if (currentTimestamp > duration && looping.value) {
74
- video.seek(0);
75
- startTimestamp.value = timestamp;
76
- }
77
-
78
- // Update frame only if the elapsed time since last update is greater than the frame duration
79
- const currentFrameDuration = Math.floor(frameDuration / playbackSpeed.value);
80
- const delta = Math.floor(timestamp - lastTimestamp.value);
81
- if (lastTimestamp.value === -1 || delta >= currentFrameDuration) {
82
- const img = video.nextImage();
83
- if (img) {
84
- if (currentFrame.value) {
85
- currentFrame.value.dispose();
86
- }
87
- if (_Platform.Platform.OS === "android") {
88
- currentFrame.value = img.makeNonTextureImage();
89
- } else {
90
- currentFrame.value = img;
91
- }
92
- }
93
- lastTimestamp.value = timestamp;
94
- }
54
+ (0, _video.processVideoState)(video, duration, framerate, frameInfo.timestamp, {
55
+ paused: isPaused.value,
56
+ looping: looping.value,
57
+ playbackSpeed: playbackSpeed.value
58
+ }, currentTime, currentFrame, lastTimestamp, seek);
95
59
  });
96
60
  (0, _react.useEffect)(() => {
97
61
  return () => {
98
62
  // TODO: should video simply be a shared value instead?
99
- (0, _reactNativeReanimated.runOnUI)(disposeVideo)();
63
+ _ReanimatedProxy.default.runOnUI(disposeVideo)(video);
100
64
  };
101
- }, [disposeVideo, video]);
102
- return currentFrame;
65
+ }, [video]);
66
+ return {
67
+ currentFrame,
68
+ currentTime,
69
+ duration,
70
+ framerate,
71
+ rotationInDegrees
72
+ };
103
73
  };
104
74
  exports.useVideo = useVideo;
105
75
  //# sourceMappingURL=useVideo.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNativeReanimated","require","_react","_Skia","_Platform","_ReanimatedProxy","_interopRequireDefault","obj","__esModule","default","defaultOptions","playbackSpeed","looping","paused","seek","currentTime","useOption","value","defaultValue","useSharedValue","Rea","isSharedValue","useVideo","source","userOptions","_userOptions$paused","_userOptions$looping","_userOptions$seek","_userOptions$currentT","_userOptions$playback","video","useMemo","Skia","Video","isPaused","currentFrame","lastTimestamp","startTimestamp","framerate","duration","frameDuration","disposeVideo","useCallback","dispose","useFrameCallback","frameInfo","timestamp","currentTimestamp","currentFrameDuration","Math","floor","delta","img","nextImage","Platform","OS","makeNonTextureImage","useEffect","runOnUI","exports"],"sources":["useVideo.ts"],"sourcesContent":["import {\n runOnUI,\n useSharedValue,\n type FrameInfo,\n type SharedValue,\n} from \"react-native-reanimated\";\nimport { useCallback, useEffect, useMemo } from \"react\";\n\nimport { Skia } from \"../../skia/Skia\";\nimport type { SkImage } from \"../../skia/types\";\nimport { Platform } from \"../../Platform\";\n\nimport Rea from \"./ReanimatedProxy\";\n\ntype Animated<T> = SharedValue<T> | T;\n\nexport interface PlaybackOptions {\n playbackSpeed: Animated<number>;\n looping: Animated<boolean>;\n paused: Animated<boolean>;\n seek: Animated<number | null>;\n currentTime: Animated<number>;\n}\n\nconst defaultOptions = {\n playbackSpeed: 1,\n looping: true,\n paused: false,\n seek: null,\n currentTime: 0,\n};\n\nconst useOption = <T>(value: Animated<T>) => {\n \"worklet\";\n // TODO: only create defaultValue is needed (via makeMutable)\n const defaultValue = useSharedValue(\n Rea.isSharedValue(value) ? value.value : value\n );\n return Rea.isSharedValue(value) ? value : defaultValue;\n};\n\nexport const useVideo = (\n source: string | null,\n userOptions?: Partial<PlaybackOptions>\n) => {\n const video = useMemo(() => (source ? Skia.Video(source) : null), [source]);\n const isPaused = useOption(userOptions?.paused ?? defaultOptions.paused);\n const looping = useOption(userOptions?.looping ?? defaultOptions.looping);\n const seek = useOption(userOptions?.seek ?? defaultOptions.seek);\n const currentTime = useOption(\n userOptions?.currentTime ?? defaultOptions.currentTime\n );\n const playbackSpeed = useOption(\n userOptions?.playbackSpeed ?? defaultOptions.playbackSpeed\n );\n const currentFrame = Rea.useSharedValue<null | SkImage>(null);\n const lastTimestamp = Rea.useSharedValue(-1);\n const startTimestamp = Rea.useSharedValue(-1);\n\n const framerate = useMemo(() => (video ? video.framerate() : -1), [video]);\n const duration = useMemo(() => (video ? video.duration() : -1), [video]);\n const frameDuration = useMemo(\n () => (framerate > 0 ? 1000 / framerate : -1),\n [framerate]\n );\n const disposeVideo = useCallback(() => {\n \"worklet\";\n video?.dispose();\n }, [video]);\n\n Rea.useFrameCallback((frameInfo: FrameInfo) => {\n if (!video) {\n return;\n }\n if (seek.value !== null) {\n video.seek(seek.value);\n seek.value = null;\n lastTimestamp.value = -1;\n startTimestamp.value = -1;\n }\n if (isPaused.value && lastTimestamp.value !== -1) {\n return;\n }\n const { timestamp } = frameInfo;\n\n // Initialize start timestamp\n if (startTimestamp.value === -1) {\n startTimestamp.value = timestamp;\n }\n\n // Calculate the current time in the video\n const currentTimestamp = timestamp - startTimestamp.value;\n currentTime.value = currentTimestamp;\n\n // Handle looping\n if (currentTimestamp > duration && looping.value) {\n video.seek(0);\n startTimestamp.value = timestamp;\n }\n\n // Update frame only if the elapsed time since last update is greater than the frame duration\n const currentFrameDuration = Math.floor(\n frameDuration / playbackSpeed.value\n );\n const delta = Math.floor(timestamp - lastTimestamp.value);\n if (lastTimestamp.value === -1 || delta >= currentFrameDuration) {\n const img = video.nextImage();\n if (img) {\n if (currentFrame.value) {\n currentFrame.value.dispose();\n }\n if (Platform.OS === \"android\") {\n currentFrame.value = img.makeNonTextureImage();\n } else {\n currentFrame.value = img;\n }\n }\n lastTimestamp.value = timestamp;\n }\n });\n\n useEffect(() => {\n return () => {\n // TODO: should video simply be a shared value instead?\n runOnUI(disposeVideo)();\n };\n }, [disposeVideo, video]);\n\n return currentFrame;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,sBAAA,GAAAC,OAAA;AAMA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,KAAA,GAAAF,OAAA;AAEA,IAAAG,SAAA,GAAAH,OAAA;AAEA,IAAAI,gBAAA,GAAAC,sBAAA,CAAAL,OAAA;AAAoC,SAAAK,uBAAAC,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAYpC,MAAMG,cAAc,GAAG;EACrBC,aAAa,EAAE,CAAC;EAChBC,OAAO,EAAE,IAAI;EACbC,MAAM,EAAE,KAAK;EACbC,IAAI,EAAE,IAAI;EACVC,WAAW,EAAE;AACf,CAAC;AAED,MAAMC,SAAS,GAAOC,KAAkB,IAAK;EAC3C,SAAS;;EACT;EACA,MAAMC,YAAY,GAAG,IAAAC,qCAAc,EACjCC,wBAAG,CAACC,aAAa,CAACJ,KAAK,CAAC,GAAGA,KAAK,CAACA,KAAK,GAAGA,KAC3C,CAAC;EACD,OAAOG,wBAAG,CAACC,aAAa,CAACJ,KAAK,CAAC,GAAGA,KAAK,GAAGC,YAAY;AACxD,CAAC;AAEM,MAAMI,QAAQ,GA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QAAA,GAAAA,QAAA"}
1
+ {"version":3,"names":["_react","require","_Skia","_ReanimatedProxy","_interopRequireDefault","_video","obj","__esModule","default","defaultOptions","playbackSpeed","looping","paused","seek","currentTime","useOption","value","defaultValue","Rea","useSharedValue","isSharedValue","disposeVideo","video","dispose","useVideo","source","userOptions","_userOptions$paused","_userOptions$looping","_userOptions$seek","_userOptions$playback","useMemo","Skia","Video","isPaused","currentFrame","lastTimestamp","duration","_video$duration","framerate","_video$framerate","rotationInDegrees","_video$getRotationInD","getRotationInDegrees","useFrameCallback","frameInfo","processVideoState","timestamp","useEffect","runOnUI","exports"],"sources":["useVideo.ts"],"sourcesContent":["import { type FrameInfo } from \"react-native-reanimated\";\nimport { useEffect, useMemo } from \"react\";\n\nimport { Skia } from \"../../skia/Skia\";\nimport type { SkImage, Video } from \"../../skia/types\";\n\nimport Rea from \"./ReanimatedProxy\";\nimport {\n processVideoState,\n type Animated,\n type PlaybackOptions,\n} from \"./video\";\n\nconst defaultOptions = {\n playbackSpeed: 1,\n looping: true,\n paused: false,\n seek: null,\n currentTime: 0,\n};\n\nconst useOption = <T>(value: Animated<T>) => {\n \"worklet\";\n // TODO: only create defaultValue is needed (via makeMutable)\n const defaultValue = Rea.useSharedValue(\n Rea.isSharedValue(value) ? value.value : value\n );\n return Rea.isSharedValue(value) ? value : defaultValue;\n};\n\nconst disposeVideo = (video: Video | null) => {\n \"worklet\";\n video?.dispose();\n};\n\nexport const useVideo = (\n source: string | null,\n userOptions?: Partial<PlaybackOptions>\n) => {\n const video = useMemo(() => (source ? Skia.Video(source) : null), [source]);\n const isPaused = useOption(userOptions?.paused ?? defaultOptions.paused);\n const looping = useOption(userOptions?.looping ?? defaultOptions.looping);\n const seek = useOption(userOptions?.seek ?? defaultOptions.seek);\n const playbackSpeed = useOption(\n userOptions?.playbackSpeed ?? defaultOptions.playbackSpeed\n );\n const currentFrame = Rea.useSharedValue<null | SkImage>(null);\n const currentTime = Rea.useSharedValue(0);\n const lastTimestamp = Rea.useSharedValue(-1);\n const duration = useMemo(() => video?.duration() ?? 0, [video]);\n const framerate = useMemo(() => video?.framerate() ?? 0, [video]);\n const rotationInDegrees = useMemo(\n () => video?.getRotationInDegrees() ?? 0,\n [video]\n );\n Rea.useFrameCallback((frameInfo: FrameInfo) => {\n processVideoState(\n video,\n duration,\n framerate,\n frameInfo.timestamp,\n {\n paused: isPaused.value,\n looping: looping.value,\n playbackSpeed: playbackSpeed.value,\n },\n currentTime,\n currentFrame,\n lastTimestamp,\n seek\n );\n });\n\n useEffect(() => {\n return () => {\n // TODO: should video simply be a shared value instead?\n Rea.runOnUI(disposeVideo)(video);\n };\n }, [video]);\n\n return { currentFrame, currentTime, duration, framerate, rotationInDegrees };\n};\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,KAAA,GAAAD,OAAA;AAGA,IAAAE,gBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAIiB,SAAAG,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEjB,MAAMG,cAAc,GAAG;EACrBC,aAAa,EAAE,CAAC;EAChBC,OAAO,EAAE,IAAI;EACbC,MAAM,EAAE,KAAK;EACbC,IAAI,EAAE,IAAI;EACVC,WAAW,EAAE;AACf,CAAC;AAED,MAAMC,SAAS,GAAOC,KAAkB,IAAK;EAC3C,SAAS;;EACT;EACA,MAAMC,YAAY,GAAGC,wBAAG,CAACC,cAAc,CACrCD,wBAAG,CAACE,aAAa,CAACJ,KAAK,CAAC,GAAGA,KAAK,CAACA,KAAK,GAAGA,KAC3C,CAAC;EACD,OAAOE,wBAAG,CAACE,aAAa,CAACJ,KAAK,CAAC,GAAGA,KAAK,GAAGC,YAAY;AACxD,CAAC;AAED,MAAMI,YAAY,GAAIC,KAAmB,IAAK;EAC5C,SAAS;;EACTA,KAAK,aAALA,KAA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;EAAkB,CAAC;AAC9E,CAAC;AAACS,OAAA,CAAA1B,QAAA,GAAAA,QAAA"}
@@ -0,0 +1,16 @@
1
+ import type { SharedValue } from "react-native-reanimated";
2
+ import type { SkImage, Video } from "../../skia/types";
3
+ export type Animated<T> = SharedValue<T> | T;
4
+ export interface PlaybackOptions {
5
+ playbackSpeed: Animated<number>;
6
+ looping: Animated<boolean>;
7
+ paused: Animated<boolean>;
8
+ seek: Animated<number | null>;
9
+ }
10
+ type Materialized<T> = {
11
+ [K in keyof T]: T[K] extends Animated<infer U> ? U : T[K];
12
+ };
13
+ export type MaterializedPlaybackOptions = Materialized<Omit<PlaybackOptions, "seek">>;
14
+ export declare const setFrame: (video: Video, currentFrame: SharedValue<SkImage | null>) => void;
15
+ export declare const processVideoState: (video: Video | null, duration: number, framerate: number, currentTimestamp: number, options: Materialized<Omit<PlaybackOptions, "seek">>, currentTime: SharedValue<number>, currentFrame: SharedValue<SkImage | null>, lastTimestamp: SharedValue<number>, seek: SharedValue<number | null>) => void;
16
+ export {};
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.setFrame = exports.processVideoState = void 0;
7
+ var _Platform = require("../../Platform");
8
+ const setFrame = (video, currentFrame) => {
9
+ "worklet";
10
+
11
+ const img = video.nextImage();
12
+ if (img) {
13
+ if (currentFrame.value) {
14
+ currentFrame.value.dispose();
15
+ }
16
+ if (_Platform.Platform.OS === "android") {
17
+ currentFrame.value = img.makeNonTextureImage();
18
+ } else {
19
+ currentFrame.value = img;
20
+ }
21
+ }
22
+ };
23
+ exports.setFrame = setFrame;
24
+ const processVideoState = (video, duration, framerate, currentTimestamp, options, currentTime, currentFrame, lastTimestamp, seek) => {
25
+ "worklet";
26
+
27
+ if (!video) {
28
+ return;
29
+ }
30
+ if (options.paused) {
31
+ return;
32
+ }
33
+ const delta = currentTimestamp - lastTimestamp.value;
34
+ const frameDuration = 1000 / framerate;
35
+ const currentFrameDuration = Math.floor(frameDuration / options.playbackSpeed);
36
+ if (currentTime.value + delta >= duration && options.looping) {
37
+ seek.value = 0;
38
+ }
39
+ if (seek.value !== null) {
40
+ video.seek(seek.value);
41
+ currentTime.value = seek.value;
42
+ setFrame(video, currentFrame);
43
+ lastTimestamp.value = currentTimestamp;
44
+ seek.value = null;
45
+ return;
46
+ }
47
+ if (delta >= currentFrameDuration) {
48
+ setFrame(video, currentFrame);
49
+ currentTime.value += delta;
50
+ lastTimestamp.value = currentTimestamp;
51
+ }
52
+ };
53
+ exports.processVideoState = processVideoState;
54
+ //# sourceMappingURL=video.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_Platform","require","setFrame","video","currentFrame","img","nextImage","value","dispose","Platform","OS","makeNonTextureImage","exports","processVideoState","duration","framerate","currentTimestamp","options","currentTime","lastTimestamp","seek","paused","delta","frameDuration","currentFrameDuration","Math","floor","playbackSpeed","looping"],"sources":["video.ts"],"sourcesContent":["import type { SharedValue } from \"react-native-reanimated\";\n\nimport type { SkImage, Video } from \"../../skia/types\";\nimport { Platform } from \"../../Platform\";\n\nexport type Animated<T> = SharedValue<T> | T;\n\nexport interface PlaybackOptions {\n playbackSpeed: Animated<number>;\n looping: Animated<boolean>;\n paused: Animated<boolean>;\n seek: Animated<number | null>;\n}\n\ntype Materialized<T> = {\n [K in keyof T]: T[K] extends Animated<infer U> ? U : T[K];\n};\n\nexport type MaterializedPlaybackOptions = Materialized<\n Omit<PlaybackOptions, \"seek\">\n>;\n\nexport const setFrame = (\n video: Video,\n currentFrame: SharedValue<SkImage | null>\n) => {\n \"worklet\";\n const img = video.nextImage();\n if (img) {\n if (currentFrame.value) {\n currentFrame.value.dispose();\n }\n if (Platform.OS === \"android\") {\n currentFrame.value = img.makeNonTextureImage();\n } else {\n currentFrame.value = img;\n }\n }\n};\n\nexport const processVideoState = (\n video: Video | null,\n duration: number,\n framerate: number,\n currentTimestamp: number,\n options: Materialized<Omit<PlaybackOptions, \"seek\">>,\n currentTime: SharedValue<number>,\n currentFrame: SharedValue<SkImage | null>,\n lastTimestamp: SharedValue<number>,\n seek: SharedValue<number | null>\n) => {\n \"worklet\";\n if (!video) {\n return;\n }\n if (options.paused) {\n return;\n }\n const delta = currentTimestamp - lastTimestamp.value;\n\n const frameDuration = 1000 / framerate;\n const currentFrameDuration = Math.floor(\n frameDuration / options.playbackSpeed\n );\n if (currentTime.value + delta >= duration && options.looping) {\n seek.value = 0;\n }\n if (seek.value !== null) {\n video.seek(seek.value);\n currentTime.value = seek.value;\n setFrame(video, currentFrame);\n lastTimestamp.value = currentTimestamp;\n seek.value = null;\n return;\n }\n\n if (delta >= currentFrameDuration) {\n setFrame(video, currentFrame);\n currentTime.value += delta;\n lastTimestamp.value = currentTimestamp;\n }\n};\n"],"mappings":";;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AAmBO,MAAMC,QAAQ,GAAGA,CACtBC,KAAY,EACZC,YAAyC,KACtC;EACH,SAAS;;EACT,MAAMC,GAAG,GAAGF,KAAK,CAACG,SAAS,CAAC,CAAC;EAC7B,IAAID,GAAG,EAAE;IACP,IAAID,YAAY,CAACG,KAAK,EAAE;MACtBH,YAAY,CAACG,KAAK,CAACC,OAAO,CAAC,CAAC;IAC9B;IACA,IAAIC,kBAAQ,CAACC,EAAE,KAAK,SAAS,EAAE;MAC7BN,YAAY,CAACG,KAAK,GAAGF,GAAG,CAACM,mBAAmB,CAAC,CAAC;IAChD,CAAC,MAAM;MACLP,YAAY,CAACG,KAAK,GAAGF,GAAG;IAC1B;EACF;AACF,CAAC;AAACO,OAAA,CAAAV,QAAA,GAAAA,QAAA;AAEK,MAAMW,iBAAiB,GAAGA,CAC/BV,KAAmB,EACnBW,QAAgB,EAChBC,SAAiB,EACjBC,gBAAwB,EACxBC,OAAoD,EACpDC,WAAgC,EAChCd,YAAyC,EACzCe,aAAkC,EAClCC,IAAgC,KAC7B;EACH,SAAS;;EACT,IAAI,CAACjB,KAAK,EAAE;IACV;EACF;EACA,IAAIc,OAAO,CAACI,MAAM,EAAE;IAClB;EACF;EACA,MAAMC,KAAK,GAAGN,gBAAgB,GAAGG,aAAa,CAACZ,KAAK;EAEpD,MAAMgB,aAAa,GAAG,IAAI,GAAGR,SAAS;EACtC,MAAMS,oBAAoB,GAAGC,IAAI,CAACC,KAAK,CACrCH,aAAa,GAAGN,OAAO,CAACU,aAC1B,CAAC;EACD,IAAIT,WAAW,CAACX,KAAK,GAAGe,KAAK,IAAIR,QAAQ,IAAIG,OAAO,CAACW,OAAO,EAAE;IAC5DR,IAAI,CAACb,KAAK,GAAG,CAAC;EAChB;EACA,IAAIa,IAAI,CAACb,KAAK,KAAK,IAAI,EAAE;IACvBJ,KAAK,CAACiB,IAAI,CAACA,IAAI,CAACb,KAAK,CAAC;IACtBW,WAAW,CAACX,KAAK,GAAGa,IAAI,CAACb,KAAK;IAC9BL,QAAQ,CAACC,KAAK,EAAEC,YAAY,CAAC;IAC7Be,aAAa,CAACZ,KAAK,GAAGS,gBAAgB;IACtCI,IAAI,CAACb,KAAK,GAAG,IAAI;IACjB;EACF;EAEA,IAAIe,KAAK,IAAIE,oBAAoB,EAAE;IACjCtB,QAAQ,CAACC,KAAK,EAAEC,YAAY,CAAC;IAC7Bc,WAAW,CAACX,KAAK,IAAIe,KAAK;IAC1BH,aAAa,CAACZ,KAAK,GAAGS,gBAAgB;EACxC;AACF,CAAC;AAACJ,OAAA,CAAAC,iBAAA,GAAAA,iBAAA"}
@@ -5,4 +5,5 @@ export interface Video extends SkJSIInstance<"Video"> {
5
5
  framerate(): number;
6
6
  nextImage(): SkImage | null;
7
7
  seek(time: number): void;
8
+ getRotationInDegrees(): number;
8
9
  }
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["Video.ts"],"sourcesContent":["import type { SkImage } from \"../Image\";\nimport type { SkJSIInstance } from \"../JsiInstance\";\n\nexport interface Video extends SkJSIInstance<\"Video\"> {\n duration(): number;\n framerate(): number;\n nextImage(): SkImage | null;\n seek(time: number): void;\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["Video.ts"],"sourcesContent":["import type { SkImage } from \"../Image\";\nimport type { SkJSIInstance } from \"../JsiInstance\";\n\nexport interface Video extends SkJSIInstance<\"Video\"> {\n duration(): number;\n framerate(): number;\n nextImage(): SkImage | null;\n seek(time: number): void;\n getRotationInDegrees(): number;\n}\n"],"mappings":""}
@@ -30,3 +30,4 @@ export * from "./Size";
30
30
  export * from "./Paragraph";
31
31
  export * from "./Matrix4";
32
32
  export * from "./NativeBuffer";
33
+ export * from "./Video";
@@ -355,4 +355,15 @@ Object.keys(_NativeBuffer).forEach(function (key) {
355
355
  }
356
356
  });
357
357
  });
358
+ var _Video = require("./Video");
359
+ Object.keys(_Video).forEach(function (key) {
360
+ if (key === "default" || key === "__esModule") return;
361
+ if (key in exports && exports[key] === _Video[key]) return;
362
+ Object.defineProperty(exports, key, {
363
+ enumerable: true,
364
+ get: function () {
365
+ return _Video[key];
366
+ }
367
+ });
368
+ });
358
369
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_Picture","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_Data","_SVG","_Surface","_Vertices","_RuntimeEffect","_Shader","_Image","_AnimatedImage","_ColorFilter","_ImageFilter","_Font","_Typeface","_Paint","_Path","_Color","_Canvas","_ContourMeasure","_MaskFilter","_Matrix","_PathEffect","_Point","_Rect","_RRect","_RSXform","_JsiInstance","_Skia","_TextBlob","_Size","_Paragraph","_Matrix2","_NativeBuffer"],"sources":["index.ts"],"sourcesContent":["export * from \"./Picture\";\nexport * from \"./Data\";\nexport * from \"./SVG\";\nexport * from \"./Surface\";\nexport * from \"./Vertices\";\nexport * from \"./RuntimeEffect\";\nexport * from \"./Shader\";\nexport * from \"./Image\";\nexport * from \"./AnimatedImage\";\nexport * from \"./ColorFilter\";\nexport * from \"./ImageFilter\";\nexport * from \"./Font\";\nexport * from \"./Typeface\";\nexport * from \"./Paint\";\nexport * from \"./Path\";\nexport * from \"./Color\";\nexport * from \"./Canvas\";\nexport * from \"./ContourMeasure\";\nexport * from \"./MaskFilter\";\nexport * from \"./Matrix\";\nexport * from \"./PathEffect\";\nexport * from \"./Point\";\nexport * from \"./Rect\";\nexport * from \"./RRect\";\nexport * from \"./RSXform\";\nexport * from \"./JsiInstance\";\nexport * from \"./Skia\";\nexport * from \"./TextBlob\";\nexport * from \"./Size\";\nexport * from \"./Paragraph\";\nexport * from \"./Matrix4\";\nexport * from \"./NativeBuffer\";\n"],"mappings":";;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,QAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,QAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,QAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,KAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,KAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,KAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,KAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,IAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,IAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OA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A,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAiC,UAAA,CAAAjC,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAA6B,UAAA,CAAAjC,GAAA;IAAA;EAAA;AAAA;AACA,IAAAkC,QAAA,GAAAtC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAoC,QAAA,EAAAnC,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAkC,QAAA,CAAAlC,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAA8B,QAAA,CAAAlC,GAAA;IAAA;EAAA;AAAA;AACA,IAAAmC,aAAA,GAAAvC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAqC,aAAA,EAAApC,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAmC,aAAA,CAAAnC,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAA+B,aAAA,CAAAnC,GAAA;IAAA;EAAA;AAAA"}
1
+ {"version":3,"names":["_Picture","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_Data","_SVG","_Surface","_Vertices","_RuntimeEffect","_Shader","_Image","_AnimatedImage","_ColorFilter","_ImageFilter","_Font","_Typeface","_Paint","_Path","_Color","_Canvas","_ContourMeasure","_MaskFilter","_Matrix","_PathEffect","_Point","_Rect","_RRect","_RSXform","_JsiInstance","_Skia","_TextBlob","_Size","_Paragraph","_Matrix2","_NativeBuffer","_Video"],"sources":["index.ts"],"sourcesContent":["export * from \"./Picture\";\nexport * from \"./Data\";\nexport * from \"./SVG\";\nexport * from \"./Surface\";\nexport * from \"./Vertices\";\nexport * from \"./RuntimeEffect\";\nexport * from \"./Shader\";\nexport * from \"./Image\";\nexport * from \"./AnimatedImage\";\nexport * from \"./ColorFilter\";\nexport * from \"./ImageFilter\";\nexport * from \"./Font\";\nexport * from \"./Typeface\";\nexport * from \"./Paint\";\nexport * from \"./Path\";\nexport * from \"./Color\";\nexport * from \"./Canvas\";\nexport * from \"./ContourMeasure\";\nexport * from \"./MaskFilter\";\nexport * from \"./Matrix\";\nexport * from \"./PathEffect\";\nexport * from \"./Point\";\nexport * from \"./Rect\";\nexport * from \"./RRect\";\nexport * from \"./RSXform\";\nexport * from \"./JsiInstance\";\nexport * from \"./Skia\";\nexport * from \"./TextBlob\";\nexport * from \"./Size\";\nexport * from \"./Paragraph\";\nexport * from \"./Matrix4\";\nexport * from \"./NativeBuffer\";\nexport * from \"./Video\";\n"],"mappings":";;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,QAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,QAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,QAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,KAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,KAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,KAAA,CAAAL,GAAA;EA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AAA,CAAAnC,GAAA;IAAA;EAAA;AAAA;AACA,IAAAoC,MAAA,GAAAxC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAsC,MAAA,EAAArC,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAoC,MAAA,CAAApC,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAgC,MAAA,CAAApC,GAAA;IAAA;EAAA;AAAA"}
@@ -1,12 +1,9 @@
1
- import { type SharedValue } from "react-native-reanimated";
2
1
  import type { SkImage } from "../../skia/types";
3
- type Animated<T> = SharedValue<T> | T;
4
- export interface PlaybackOptions {
5
- playbackSpeed: Animated<number>;
6
- looping: Animated<boolean>;
7
- paused: Animated<boolean>;
8
- seek: Animated<number | null>;
9
- currentTime: Animated<number>;
10
- }
11
- export declare const useVideo: (source: string | null, userOptions?: Partial<PlaybackOptions>) => SharedValue<SkImage | null>;
12
- export {};
2
+ import { type PlaybackOptions } from "./video";
3
+ export declare const useVideo: (source: string | null, userOptions?: Partial<PlaybackOptions>) => {
4
+ currentFrame: import("react-native-reanimated").SharedValue<SkImage | null>;
5
+ currentTime: import("react-native-reanimated").SharedValue<number>;
6
+ duration: number;
7
+ framerate: number;
8
+ rotationInDegrees: number;
9
+ };
@@ -1,8 +1,7 @@
1
- import { runOnUI, useSharedValue } from "react-native-reanimated";
2
- import { useCallback, useEffect, useMemo } from "react";
1
+ import { useEffect, useMemo } from "react";
3
2
  import { Skia } from "../../skia/Skia";
4
- import { Platform } from "../../Platform";
5
3
  import Rea from "./ReanimatedProxy";
4
+ import { processVideoState } from "./video";
6
5
  const defaultOptions = {
7
6
  playbackSpeed: 1,
8
7
  looping: true,
@@ -14,84 +13,55 @@ const useOption = value => {
14
13
  "worklet";
15
14
 
16
15
  // TODO: only create defaultValue is needed (via makeMutable)
17
- const defaultValue = useSharedValue(Rea.isSharedValue(value) ? value.value : value);
16
+ const defaultValue = Rea.useSharedValue(Rea.isSharedValue(value) ? value.value : value);
18
17
  return Rea.isSharedValue(value) ? value : defaultValue;
19
18
  };
19
+ const disposeVideo = video => {
20
+ "worklet";
21
+
22
+ video === null || video === void 0 || video.dispose();
23
+ };
20
24
  export const useVideo = (source, userOptions) => {
21
- var _userOptions$paused, _userOptions$looping, _userOptions$seek, _userOptions$currentT, _userOptions$playback;
25
+ var _userOptions$paused, _userOptions$looping, _userOptions$seek, _userOptions$playback;
22
26
  const video = useMemo(() => source ? Skia.Video(source) : null, [source]);
23
27
  const isPaused = useOption((_userOptions$paused = userOptions === null || userOptions === void 0 ? void 0 : userOptions.paused) !== null && _userOptions$paused !== void 0 ? _userOptions$paused : defaultOptions.paused);
24
28
  const looping = useOption((_userOptions$looping = userOptions === null || userOptions === void 0 ? void 0 : userOptions.looping) !== null && _userOptions$looping !== void 0 ? _userOptions$looping : defaultOptions.looping);
25
29
  const seek = useOption((_userOptions$seek = userOptions === null || userOptions === void 0 ? void 0 : userOptions.seek) !== null && _userOptions$seek !== void 0 ? _userOptions$seek : defaultOptions.seek);
26
- const currentTime = useOption((_userOptions$currentT = userOptions === null || userOptions === void 0 ? void 0 : userOptions.currentTime) !== null && _userOptions$currentT !== void 0 ? _userOptions$currentT : defaultOptions.currentTime);
27
30
  const playbackSpeed = useOption((_userOptions$playback = userOptions === null || userOptions === void 0 ? void 0 : userOptions.playbackSpeed) !== null && _userOptions$playback !== void 0 ? _userOptions$playback : defaultOptions.playbackSpeed);
28
31
  const currentFrame = Rea.useSharedValue(null);
32
+ const currentTime = Rea.useSharedValue(0);
29
33
  const lastTimestamp = Rea.useSharedValue(-1);
30
- const startTimestamp = Rea.useSharedValue(-1);
31
- const framerate = useMemo(() => video ? video.framerate() : -1, [video]);
32
- const duration = useMemo(() => video ? video.duration() : -1, [video]);
33
- const frameDuration = useMemo(() => framerate > 0 ? 1000 / framerate : -1, [framerate]);
34
- const disposeVideo = useCallback(() => {
35
- "worklet";
36
-
37
- video === null || video === void 0 || video.dispose();
34
+ const duration = useMemo(() => {
35
+ var _video$duration;
36
+ return (_video$duration = video === null || video === void 0 ? void 0 : video.duration()) !== null && _video$duration !== void 0 ? _video$duration : 0;
37
+ }, [video]);
38
+ const framerate = useMemo(() => {
39
+ var _video$framerate;
40
+ return (_video$framerate = video === null || video === void 0 ? void 0 : video.framerate()) !== null && _video$framerate !== void 0 ? _video$framerate : 0;
41
+ }, [video]);
42
+ const rotationInDegrees = useMemo(() => {
43
+ var _video$getRotationInD;
44
+ return (_video$getRotationInD = video === null || video === void 0 ? void 0 : video.getRotationInDegrees()) !== null && _video$getRotationInD !== void 0 ? _video$getRotationInD : 0;
38
45
  }, [video]);
39
46
  Rea.useFrameCallback(frameInfo => {
40
- if (!video) {
41
- return;
42
- }
43
- if (seek.value !== null) {
44
- video.seek(seek.value);
45
- seek.value = null;
46
- lastTimestamp.value = -1;
47
- startTimestamp.value = -1;
48
- }
49
- if (isPaused.value && lastTimestamp.value !== -1) {
50
- return;
51
- }
52
- const {
53
- timestamp
54
- } = frameInfo;
55
-
56
- // Initialize start timestamp
57
- if (startTimestamp.value === -1) {
58
- startTimestamp.value = timestamp;
59
- }
60
-
61
- // Calculate the current time in the video
62
- const currentTimestamp = timestamp - startTimestamp.value;
63
- currentTime.value = currentTimestamp;
64
-
65
- // Handle looping
66
- if (currentTimestamp > duration && looping.value) {
67
- video.seek(0);
68
- startTimestamp.value = timestamp;
69
- }
70
-
71
- // Update frame only if the elapsed time since last update is greater than the frame duration
72
- const currentFrameDuration = Math.floor(frameDuration / playbackSpeed.value);
73
- const delta = Math.floor(timestamp - lastTimestamp.value);
74
- if (lastTimestamp.value === -1 || delta >= currentFrameDuration) {
75
- const img = video.nextImage();
76
- if (img) {
77
- if (currentFrame.value) {
78
- currentFrame.value.dispose();
79
- }
80
- if (Platform.OS === "android") {
81
- currentFrame.value = img.makeNonTextureImage();
82
- } else {
83
- currentFrame.value = img;
84
- }
85
- }
86
- lastTimestamp.value = timestamp;
87
- }
47
+ processVideoState(video, duration, framerate, frameInfo.timestamp, {
48
+ paused: isPaused.value,
49
+ looping: looping.value,
50
+ playbackSpeed: playbackSpeed.value
51
+ }, currentTime, currentFrame, lastTimestamp, seek);
88
52
  });
89
53
  useEffect(() => {
90
54
  return () => {
91
55
  // TODO: should video simply be a shared value instead?
92
- runOnUI(disposeVideo)();
56
+ Rea.runOnUI(disposeVideo)(video);
93
57
  };
94
- }, [disposeVideo, video]);
95
- return currentFrame;
58
+ }, [video]);
59
+ return {
60
+ currentFrame,
61
+ currentTime,
62
+ duration,
63
+ framerate,
64
+ rotationInDegrees
65
+ };
96
66
  };
97
67
  //# sourceMappingURL=useVideo.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["runOnUI","useSharedValue","useCallback","useEffect","useMemo","Skia","Platform","Rea","defaultOptions","playbackSpeed","looping","paused","seek","currentTime","useOption","value","defaultValue","isSharedValue","useVideo","source","userOptions","_userOptions$paused","_userOptions$looping","_userOptions$seek","_userOptions$currentT","_userOptions$playback","video","Video","isPaused","currentFrame","lastTimestamp","startTimestamp","framerate","duration","frameDuration","disposeVideo","dispose","useFrameCallback","frameInfo","timestamp","currentTimestamp","currentFrameDuration","Math","floor","delta","img","nextImage","OS","makeNonTextureImage"],"sources":["useVideo.ts"],"sourcesContent":["import {\n runOnUI,\n useSharedValue,\n type FrameInfo,\n type SharedValue,\n} from \"react-native-reanimated\";\nimport { useCallback, useEffect, useMemo } from \"react\";\n\nimport { Skia } from \"../../skia/Skia\";\nimport type { SkImage } from \"../../skia/types\";\nimport { Platform } from \"../../Platform\";\n\nimport Rea from \"./ReanimatedProxy\";\n\ntype Animated<T> = SharedValue<T> | T;\n\nexport interface PlaybackOptions {\n playbackSpeed: Animated<number>;\n looping: Animated<boolean>;\n paused: Animated<boolean>;\n seek: Animated<number | null>;\n currentTime: Animated<number>;\n}\n\nconst defaultOptions = {\n playbackSpeed: 1,\n looping: true,\n paused: false,\n seek: null,\n currentTime: 0,\n};\n\nconst useOption = <T>(value: Animated<T>) => {\n \"worklet\";\n // TODO: only create defaultValue is needed (via makeMutable)\n const defaultValue = useSharedValue(\n Rea.isSharedValue(value) ? value.value : value\n );\n return Rea.isSharedValue(value) ? value : defaultValue;\n};\n\nexport const useVideo = (\n source: string | null,\n userOptions?: Partial<PlaybackOptions>\n) => {\n const video = useMemo(() => (source ? Skia.Video(source) : null), [source]);\n const isPaused = useOption(userOptions?.paused ?? defaultOptions.paused);\n const looping = useOption(userOptions?.looping ?? defaultOptions.looping);\n const seek = useOption(userOptions?.seek ?? defaultOptions.seek);\n const currentTime = useOption(\n userOptions?.currentTime ?? defaultOptions.currentTime\n );\n const playbackSpeed = useOption(\n userOptions?.playbackSpeed ?? defaultOptions.playbackSpeed\n );\n const currentFrame = Rea.useSharedValue<null | SkImage>(null);\n const lastTimestamp = Rea.useSharedValue(-1);\n const startTimestamp = Rea.useSharedValue(-1);\n\n const framerate = useMemo(() => (video ? video.framerate() : -1), [video]);\n const duration = useMemo(() => (video ? video.duration() : -1), [video]);\n const frameDuration = useMemo(\n () => (framerate > 0 ? 1000 / framerate : -1),\n [framerate]\n );\n const disposeVideo = useCallback(() => {\n \"worklet\";\n video?.dispose();\n }, [video]);\n\n Rea.useFrameCallback((frameInfo: FrameInfo) => {\n if (!video) {\n return;\n }\n if (seek.value !== null) {\n video.seek(seek.value);\n seek.value = null;\n lastTimestamp.value = -1;\n startTimestamp.value = -1;\n }\n if (isPaused.value && lastTimestamp.value !== -1) {\n return;\n }\n const { timestamp } = frameInfo;\n\n // Initialize start timestamp\n if (startTimestamp.value === -1) {\n startTimestamp.value = timestamp;\n }\n\n // Calculate the current time in the video\n const currentTimestamp = timestamp - startTimestamp.value;\n currentTime.value = currentTimestamp;\n\n // Handle looping\n if (currentTimestamp > duration && looping.value) {\n video.seek(0);\n startTimestamp.value = timestamp;\n }\n\n // Update frame only if the elapsed time since last update is greater than the frame duration\n const currentFrameDuration = Math.floor(\n frameDuration / playbackSpeed.value\n );\n const delta = Math.floor(timestamp - lastTimestamp.value);\n if (lastTimestamp.value === -1 || delta >= currentFrameDuration) {\n const img = video.nextImage();\n if (img) {\n if (currentFrame.value) {\n currentFrame.value.dispose();\n }\n if (Platform.OS === \"android\") {\n currentFrame.value = img.makeNonTextureImage();\n } else {\n currentFrame.value = img;\n }\n }\n lastTimestamp.value = timestamp;\n }\n });\n\n useEffect(() => {\n return () => {\n // TODO: should video simply be a shared value instead?\n runOnUI(disposeVideo)();\n };\n }, [disposeVideo, video]);\n\n return currentFrame;\n};\n"],"mappings":"AAAA,SACEA,OAAO,EACPC,cAAc,QAGT,yBAAyB;AAChC,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,QAAQ,OAAO;AAEvD,SAASC,IAAI,QAAQ,iBAAiB;AAEtC,SAASC,QAAQ,QAAQ,gBAAgB;AAEzC,OAAOC,GAAG,MAAM,mBAAmB;AAYnC,MAAMC,cAAc,GAAG;EACrBC,aAAa,EAAE,CAAC;EAChBC,OAAO,EAAE,IAAI;EACbC,MAAM,EAAE,KAAK;EACbC,IAAI,EAAE,IAAI;EACVC,WAAW,EAAE;AACf,CAAC;AAED,MAAMC,SAAS,GAAOC,KAAkB,IAAK;EAC3C,SAAS;;EACT;EACA,MAAMC,YAAY,GAAGf,cAAc,CACjCM,GAAG,CAACU,aAAa,CAACF,KAAK,CAAC,GAAGA,KAAK,CAACA,KAAK,GAAGA,KAC3C,CAAC;EACD,OAAOR,GAAG,CAACU,aAAa,CAACF,KAAK,CAAC,GAAGA,KAAK,GAAGC,YAAY;AACxD,CAAC;AAED,OAAO,MAAME,QAAQ,GAAGA,CACtBC,MAAqB,EACrBC,WAAsC,KACnC;EAAA,IAAAC,mBAAA,EAAAC,oBAAA,EAAAC,iBAAA,EAAAC,qBAAA,EAAAC,qBAAA;EACH,MAAMC,KAAK,GAAGtB,OAAO,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AACK,KAAK,EAAE;MAChDW,KAAK,CAACd,IAAI,CAAC,CAAC,CAAC;MACbmB,cAAc,CAAChB,KAAK,GAAGwB,SAAS;IAClC;;IAEA;IACA,MAAME,oBAAoB,GAAGC,IAAI,CAACC,KAAK,CACrCT,aAAa,GAAGzB,aAAa,CAACM,KAChC,CAAC;IACD,MAAM6B,KAAK,GAAGF,IAAI,CAACC,KAAK,CAACJ,SAAS,GAAGT,aAAa,CAACf,KAAK,CAAC;IACzD,IAAIe,aAAa,CAACf,KAAK,KAAK,CAAC,CAAC,IAAI6B,KAAK,IAAIH,oBAAoB,EAAE;MAC/D,MAAMI,GAAG,GAAGnB,KAAK,CAACoB,SAAS,CAAC,CAAC;MAC7B,IAAID,GAAG,EAAE;QACP,IAAIhB,YAAY,CAACd,KAAK,EAAE;UACtBc,YAAY,CAACd,KAAK,CAACqB,OAAO,CAAC,CAAC;QAC9B;QACA,IAAI9B,QAAQ,CAACyC,EAAE,KAAK,SAAS,EAAE;UAC7BlB,YAAY,CAACd,KAAK,GAAG8B,GAAG,CAACG,mBAAmB,CAAC,CAAC;QAChD,CAAC,MAAM;UACLnB,YAAY,CAACd,KAAK,GAAG8B,GAAG;QAC1B;MACF;MACAf,aAAa,CAACf,KAAK,GAAGwB,SAAS;IACjC;EACF,CAAC,CAAC;EAEFpC,SAAS,CAAC,MAAM;IACd,OAAO,MAAM;MACX;MACAH,OAAO,CAACmC,YAAY,CAAC,CAAC,CAAC;IACzB,CAAC;EACH,CAAC,EAAE,CAACA,YAAY,EAAET,KAAK,CAAC,CAAC;EAEzB,OAAOG,YAAY;AACrB,CAAC"}
1
+ {"version":3,"names":["useEffect","useMemo","Skia","Rea","processVideoState","defaultOptions","playbackSpeed","looping","paused","seek","currentTime","useOption","value","defaultValue","useSharedValue","isSharedValue","disposeVideo","video","dispose","useVideo","source","userOptions","_userOptions$paused","_userOptions$looping","_userOptions$seek","_userOptions$playback","Video","isPaused","currentFrame","lastTimestamp","duration","_video$duration","framerate","_video$framerate","rotationInDegrees","_video$getRotationInD","getRotationInDegrees","useFrameCallback","frameInfo","timestamp","runOnUI"],"sources":["useVideo.ts"],"sourcesContent":["import { type FrameInfo } from \"react-native-reanimated\";\nimport { useEffect, useMemo } from \"react\";\n\nimport { Skia } from \"../../skia/Skia\";\nimport type { SkImage, Video } from \"../../skia/types\";\n\nimport Rea from \"./ReanimatedProxy\";\nimport {\n processVideoState,\n type Animated,\n type PlaybackOptions,\n} from \"./video\";\n\nconst defaultOptions = {\n playbackSpeed: 1,\n looping: true,\n paused: false,\n seek: null,\n currentTime: 0,\n};\n\nconst useOption = <T>(value: Animated<T>) => {\n \"worklet\";\n // TODO: only create defaultValue is needed (via makeMutable)\n const defaultValue = Rea.useSharedValue(\n Rea.isSharedValue(value) ? value.value : value\n );\n return Rea.isSharedValue(value) ? value : defaultValue;\n};\n\nconst disposeVideo = (video: Video | null) => {\n \"worklet\";\n video?.dispose();\n};\n\nexport const useVideo = (\n source: string | null,\n userOptions?: Partial<PlaybackOptions>\n) => {\n const video = useMemo(() => (source ? Skia.Video(source) : null), [source]);\n const isPaused = useOption(userOptions?.paused ?? defaultOptions.paused);\n const looping = useOption(userOptions?.looping ?? defaultOptions.looping);\n const seek = useOption(userOptions?.seek ?? defaultOptions.seek);\n const playbackSpeed = useOption(\n userOptions?.playbackSpeed ?? defaultOptions.playbackSpeed\n );\n const currentFrame = Rea.useSharedValue<null | SkImage>(null);\n const currentTime = Rea.useSharedValue(0);\n const lastTimestamp = Rea.useSharedValue(-1);\n const duration = useMemo(() => video?.duration() ?? 0, [video]);\n const framerate = useMemo(() => video?.framerate() ?? 0, [video]);\n const rotationInDegrees = useMemo(\n () => video?.getRotationInDegrees() ?? 0,\n [video]\n );\n Rea.useFrameCallback((frameInfo: FrameInfo) => {\n processVideoState(\n video,\n duration,\n framerate,\n frameInfo.timestamp,\n {\n paused: isPaused.value,\n looping: looping.value,\n playbackSpeed: playbackSpeed.value,\n },\n currentTime,\n currentFrame,\n lastTimestamp,\n seek\n );\n });\n\n useEffect(() => {\n return () => {\n // TODO: should video simply be a shared value instead?\n Rea.runOnUI(disposeVideo)(video);\n };\n }, [video]);\n\n return { currentFrame, currentTime, duration, framerate, rotationInDegrees };\n};\n"],"mappings":"AACA,SAASA,SAAS,EAAEC,OAAO,QAAQ,OAAO;AAE1C,SAASC,IAAI,QAAQ,iBAAiB;AAGtC,OAAOC,GAAG,MAAM,mBAAmB;AACnC,SACEC,iBAAiB,QAGZ,SAAS;AAEhB,MAAMC,cAAc,GAAG;EACrBC,aAAa,EAAE,CAAC;EAChBC,OAAO,EAAE,IAAI;EACbC,MAAM,EAAE,KAAK;EACbC,IAAI,EAAE,IAAI;EACVC,WAAW,EAAE;AACf,CAAC;AAED,MAAMC,SAAS,GAAOC,KAAkB,IAAK;EAC3C,SAAS;;EACT;EACA,MAAMC,YAAY,GAAGV,GAAG,CAACW,cAAc,CACrCX,GAAG,CAACY,aAAa,CAACH,KAAK,CAAC,GAAGA,KAAK,CAACA,KAAK,GAAGA,KAC3C,CAAC;EACD,OAAOT,GAAG,CAACY,aAAa,CAACH,KAAK,CAAC,GAAGA,KAAK,GAAGC,YAAY;AACxD,CAAC;AAED,MAAMG,YAAY,GAAIC,KAAmB,IAAK;EAC5C,SAAS;;EACTA,KAAK,aAALA,KAAK,eAALA,KAAK,CAAEC,OAAO,CAAC,CAAC;AAClB,CAAC;AAED,OAAO,MAAMC,QAAQ,GAAGA,CACtBC,MAAqB,EACrBC,WAAsC,KACnC;EAAA,IAAAC,mBAAA,EAAAC,oBAAA,EAAAC,iBAAA,EAAAC,qBAAA;EACH,MAAMR,KAAK,GAAGhB,OAAO,CAAC,MAAOmB,MAAM,GAAGlB,IAAI,CAACwB,KAAK,CAACN,MAAM,CAAC,GAAG,IAAK,EAAE,CAACA,MAAM,CAAC,CAAC;EAC3E,MAAMO,QAAQ,GAAGhB,SAAS,EAAAW,mBAAA,GAACD,WAAW,aAAXA,WAAW,uBAAXA,WAAW,CAAEb,MAAM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OAAO,CAC/B;IAAA,IAAAkC,qBAAA;IAAA,QAAAA,qBAAA,GAAMlB,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEmB,oBAAoB,CAAC,CAAC,cAAAD,qBAAA,cAAAA,qBAAA,GAAI,CAAC;EAAA,GACxC,CAAClB,KAAK,CACR,CAAC;EACDd,GAAG,CAACkC,gBAAgB,CAAEC,SAAoB,IAAK;IAC7ClC,iBAAiB,CACfa,KAAK,EACLa,QAAQ,EACRE,SAAS,EACTM,SAAS,CAACC,SAAS,EACnB;MACE/B,MAAM,EAAEmB,QAAQ,CAACf,KAAK;MACtBL,OAAO,EAAEA,OAAO,CAACK,KAAK;MACtBN,aAAa,EAAEA,aAAa,CAACM;IAC/B,CAAC,EACDF,WAAW,EACXkB,YAAY,EACZC,aAAa,EACbpB,IACF,CAAC;EACH,CAAC,CAAC;EAEFT,SAAS,CAAC,MAAM;IACd,OAAO,MAAM;MACX;MACAG,GAAG,CAACqC,OAAO,CAACxB,YAAY,CAAC,CAACC,KAAK,CAAC;IAClC,CAAC;EACH,CAAC,EAAE,CAACA,KAAK,CAAC,CAAC;EAEX,OAAO;IAAEW,YAAY;IAAElB,WAAW;IAAEoB,QAAQ;IAAEE,SAAS;IAAEE;EAAkB,CAAC;AAC9E,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { SharedValue } from "react-native-reanimated";
2
+ import type { SkImage, Video } from "../../skia/types";
3
+ export type Animated<T> = SharedValue<T> | T;
4
+ export interface PlaybackOptions {
5
+ playbackSpeed: Animated<number>;
6
+ looping: Animated<boolean>;
7
+ paused: Animated<boolean>;
8
+ seek: Animated<number | null>;
9
+ }
10
+ type Materialized<T> = {
11
+ [K in keyof T]: T[K] extends Animated<infer U> ? U : T[K];
12
+ };
13
+ export type MaterializedPlaybackOptions = Materialized<Omit<PlaybackOptions, "seek">>;
14
+ export declare const setFrame: (video: Video, currentFrame: SharedValue<SkImage | null>) => void;
15
+ export declare const processVideoState: (video: Video | null, duration: number, framerate: number, currentTimestamp: number, options: Materialized<Omit<PlaybackOptions, "seek">>, currentTime: SharedValue<number>, currentFrame: SharedValue<SkImage | null>, lastTimestamp: SharedValue<number>, seek: SharedValue<number | null>) => void;
16
+ export {};
@@ -0,0 +1,46 @@
1
+ import { Platform } from "../../Platform";
2
+ export const setFrame = (video, currentFrame) => {
3
+ "worklet";
4
+
5
+ const img = video.nextImage();
6
+ if (img) {
7
+ if (currentFrame.value) {
8
+ currentFrame.value.dispose();
9
+ }
10
+ if (Platform.OS === "android") {
11
+ currentFrame.value = img.makeNonTextureImage();
12
+ } else {
13
+ currentFrame.value = img;
14
+ }
15
+ }
16
+ };
17
+ export const processVideoState = (video, duration, framerate, currentTimestamp, options, currentTime, currentFrame, lastTimestamp, seek) => {
18
+ "worklet";
19
+
20
+ if (!video) {
21
+ return;
22
+ }
23
+ if (options.paused) {
24
+ return;
25
+ }
26
+ const delta = currentTimestamp - lastTimestamp.value;
27
+ const frameDuration = 1000 / framerate;
28
+ const currentFrameDuration = Math.floor(frameDuration / options.playbackSpeed);
29
+ if (currentTime.value + delta >= duration && options.looping) {
30
+ seek.value = 0;
31
+ }
32
+ if (seek.value !== null) {
33
+ video.seek(seek.value);
34
+ currentTime.value = seek.value;
35
+ setFrame(video, currentFrame);
36
+ lastTimestamp.value = currentTimestamp;
37
+ seek.value = null;
38
+ return;
39
+ }
40
+ if (delta >= currentFrameDuration) {
41
+ setFrame(video, currentFrame);
42
+ currentTime.value += delta;
43
+ lastTimestamp.value = currentTimestamp;
44
+ }
45
+ };
46
+ //# sourceMappingURL=video.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Platform","setFrame","video","currentFrame","img","nextImage","value","dispose","OS","makeNonTextureImage","processVideoState","duration","framerate","currentTimestamp","options","currentTime","lastTimestamp","seek","paused","delta","frameDuration","currentFrameDuration","Math","floor","playbackSpeed","looping"],"sources":["video.ts"],"sourcesContent":["import type { SharedValue } from \"react-native-reanimated\";\n\nimport type { SkImage, Video } from \"../../skia/types\";\nimport { Platform } from \"../../Platform\";\n\nexport type Animated<T> = SharedValue<T> | T;\n\nexport interface PlaybackOptions {\n playbackSpeed: Animated<number>;\n looping: Animated<boolean>;\n paused: Animated<boolean>;\n seek: Animated<number | null>;\n}\n\ntype Materialized<T> = {\n [K in keyof T]: T[K] extends Animated<infer U> ? U : T[K];\n};\n\nexport type MaterializedPlaybackOptions = Materialized<\n Omit<PlaybackOptions, \"seek\">\n>;\n\nexport const setFrame = (\n video: Video,\n currentFrame: SharedValue<SkImage | null>\n) => {\n \"worklet\";\n const img = video.nextImage();\n if (img) {\n if (currentFrame.value) {\n currentFrame.value.dispose();\n }\n if (Platform.OS === \"android\") {\n currentFrame.value = img.makeNonTextureImage();\n } else {\n currentFrame.value = img;\n }\n }\n};\n\nexport const processVideoState = (\n video: Video | null,\n duration: number,\n framerate: number,\n currentTimestamp: number,\n options: Materialized<Omit<PlaybackOptions, \"seek\">>,\n currentTime: SharedValue<number>,\n currentFrame: SharedValue<SkImage | null>,\n lastTimestamp: SharedValue<number>,\n seek: SharedValue<number | null>\n) => {\n \"worklet\";\n if (!video) {\n return;\n }\n if (options.paused) {\n return;\n }\n const delta = currentTimestamp - lastTimestamp.value;\n\n const frameDuration = 1000 / framerate;\n const currentFrameDuration = Math.floor(\n frameDuration / options.playbackSpeed\n );\n if (currentTime.value + delta >= duration && options.looping) {\n seek.value = 0;\n }\n if (seek.value !== null) {\n video.seek(seek.value);\n currentTime.value = seek.value;\n setFrame(video, currentFrame);\n lastTimestamp.value = currentTimestamp;\n seek.value = null;\n return;\n }\n\n if (delta >= currentFrameDuration) {\n setFrame(video, currentFrame);\n currentTime.value += delta;\n lastTimestamp.value = currentTimestamp;\n }\n};\n"],"mappings":"AAGA,SAASA,QAAQ,QAAQ,gBAAgB;AAmBzC,OAAO,MAAMC,QAAQ,GAAGA,CACtBC,KAAY,EACZC,YAAyC,KACtC;EACH,SAAS;;EACT,MAAMC,GAAG,GAAGF,KAAK,CAACG,SAAS,CAA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AK,IAAIE,oBAAoB,EAAE;IACjCpB,QAAQ,CAACC,KAAK,EAAEC,YAAY,CAAC;IAC7BY,WAAW,CAACT,KAAK,IAAIa,KAAK;IAC1BH,aAAa,CAACV,KAAK,GAAGO,gBAAgB;EACxC;AACF,CAAC"}
@@ -5,4 +5,5 @@ export interface Video extends SkJSIInstance<"Video"> {
5
5
  framerate(): number;
6
6
  nextImage(): SkImage | null;
7
7
  seek(time: number): void;
8
+ getRotationInDegrees(): number;
8
9
  }
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["Video.ts"],"sourcesContent":["import type { SkImage } from \"../Image\";\nimport type { SkJSIInstance } from \"../JsiInstance\";\n\nexport interface Video extends SkJSIInstance<\"Video\"> {\n duration(): number;\n framerate(): number;\n nextImage(): SkImage | null;\n seek(time: number): void;\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["Video.ts"],"sourcesContent":["import type { SkImage } from \"../Image\";\nimport type { SkJSIInstance } from \"../JsiInstance\";\n\nexport interface Video extends SkJSIInstance<\"Video\"> {\n duration(): number;\n framerate(): number;\n nextImage(): SkImage | null;\n seek(time: number): void;\n getRotationInDegrees(): number;\n}\n"],"mappings":""}
@@ -30,3 +30,4 @@ export * from "./Size";
30
30
  export * from "./Paragraph";
31
31
  export * from "./Matrix4";
32
32
  export * from "./NativeBuffer";
33
+ export * from "./Video";
@@ -30,4 +30,5 @@ export * from "./Size";
30
30
  export * from "./Paragraph";
31
31
  export * from "./Matrix4";
32
32
  export * from "./NativeBuffer";
33
+ export * from "./Video";
33
34
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./Picture\";\nexport * from \"./Data\";\nexport * from \"./SVG\";\nexport * from \"./Surface\";\nexport * from \"./Vertices\";\nexport * from \"./RuntimeEffect\";\nexport * from \"./Shader\";\nexport * from \"./Image\";\nexport * from \"./AnimatedImage\";\nexport * from \"./ColorFilter\";\nexport * from \"./ImageFilter\";\nexport * from \"./Font\";\nexport * from \"./Typeface\";\nexport * from \"./Paint\";\nexport * from \"./Path\";\nexport * from \"./Color\";\nexport * from \"./Canvas\";\nexport * from \"./ContourMeasure\";\nexport * from \"./MaskFilter\";\nexport * from \"./Matrix\";\nexport * from \"./PathEffect\";\nexport * from \"./Point\";\nexport * from \"./Rect\";\nexport * from \"./RRect\";\nexport * from \"./RSXform\";\nexport * from \"./JsiInstance\";\nexport * from \"./Skia\";\nexport * from \"./TextBlob\";\nexport * from \"./Size\";\nexport * from \"./Paragraph\";\nexport * from \"./Matrix4\";\nexport * from \"./NativeBuffer\";\n"],"mappings":"AAAA,cAAc,WAAW;AACzB,cAAc,QAAQ;AACtB,cAAc,OAAO;AACrB,cAAc,WAAW;AACzB,cAAc,YAAY;AAC1B,cAAc,iBAAiB;AAC/B,cAAc,UAAU;AACxB,cAAc,SAAS;AACvB,cAAc,iBAAiB;AAC/B,cAAc,eAAe;AAC7B,cAAc,eAAe;AAC7B,cAAc,QAAQ;AACtB,cAAc,YAAY;AAC1B,cAAc,SAAS;AACvB,cAAc,QAAQ;AACtB,cAAc,SAAS;AACvB,cAAc,UAAU;AACxB,cAAc,kBAAkB;AAChC,cAAc,cAAc;AAC5B,cAAc,UAAU;AACxB,cAAc,cAAc;AAC5B,cAAc,SAAS;AACvB,cAAc,QAAQ;AACtB,cAAc,SAAS;AACvB,cAAc,WAAW;AACzB,cAAc,eAAe;AAC7B,cAAc,QAAQ;AACtB,cAAc,YAAY;AAC1B,cAAc,QAAQ;AACtB,cAAc,aAAa;AAC3B,cAAc,WAAW;AACzB,cAAc,gBAAgB"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./Picture\";\nexport * from \"./Data\";\nexport * from \"./SVG\";\nexport * from \"./Surface\";\nexport * from \"./Vertices\";\nexport * from \"./RuntimeEffect\";\nexport * from \"./Shader\";\nexport * from \"./Image\";\nexport * from \"./AnimatedImage\";\nexport * from \"./ColorFilter\";\nexport * from \"./ImageFilter\";\nexport * from \"./Font\";\nexport * from \"./Typeface\";\nexport * from \"./Paint\";\nexport * from \"./Path\";\nexport * from \"./Color\";\nexport * from \"./Canvas\";\nexport * from \"./ContourMeasure\";\nexport * from \"./MaskFilter\";\nexport * from \"./Matrix\";\nexport * from \"./PathEffect\";\nexport * from \"./Point\";\nexport * from \"./Rect\";\nexport * from \"./RRect\";\nexport * from \"./RSXform\";\nexport * from \"./JsiInstance\";\nexport * from \"./Skia\";\nexport * from \"./TextBlob\";\nexport * from \"./Size\";\nexport * from \"./Paragraph\";\nexport * from \"./Matrix4\";\nexport * from \"./NativeBuffer\";\nexport * from \"./Video\";\n"],"mappings":"AAAA,cAAc,WAAW;AACzB,cAAc,QAAQ;AACtB,cAAc,OAAO;AACrB,cAAc,WAAW;AACzB,cAAc,YAAY;AAC1B,cAAc,iBAAiB;AAC/B,cAAc,UAAU;AACxB,cAAc,SAAS;AACvB,cAAc,iBAAiB;AAC/B,cAAc,eAAe;AAC7B,cAAc,eAAe;AAC7B,cAAc,QAAQ;AACtB,cAAc,YAAY;AAC1B,cAAc,SAAS;AACvB,cAAc,QAAQ;AACtB,cAAc,SAAS;AACvB,cAAc,UAAU;AACxB,cAAc,kBAAkB;AAChC,cAAc,cAAc;AAC5B,cAAc,UAAU;AACxB,cAAc,cAAc;AAC5B,cAAc,SAAS;AACvB,cAAc,QAAQ;AACtB,cAAc,SAAS;AACvB,cAAc,WAAW;AACzB,cAAc,eAAe;AAC7B,cAAc,QAAQ;AACtB,cAAc,YAAY;AAC1B,cAAc,QAAQ;AACtB,cAAc,aAAa;AAC3B,cAAc,WAAW;AACzB,cAAc,gBAAgB;AAC9B,cAAc,SAAS"}
@@ -1,12 +1,9 @@
1
- import { type SharedValue } from "react-native-reanimated";
2
1
  import type { SkImage } from "../../skia/types";
3
- type Animated<T> = SharedValue<T> | T;
4
- export interface PlaybackOptions {
5
- playbackSpeed: Animated<number>;
6
- looping: Animated<boolean>;
7
- paused: Animated<boolean>;
8
- seek: Animated<number | null>;
9
- currentTime: Animated<number>;
10
- }
11
- export declare const useVideo: (source: string | null, userOptions?: Partial<PlaybackOptions>) => SharedValue<SkImage | null>;
12
- export {};
2
+ import { type PlaybackOptions } from "./video";
3
+ export declare const useVideo: (source: string | null, userOptions?: Partial<PlaybackOptions>) => {
4
+ currentFrame: import("react-native-reanimated").SharedValue<SkImage | null>;
5
+ currentTime: import("react-native-reanimated").SharedValue<number>;
6
+ duration: number;
7
+ framerate: number;
8
+ rotationInDegrees: number;
9
+ };
@@ -0,0 +1,16 @@
1
+ import type { SharedValue } from "react-native-reanimated";
2
+ import type { SkImage, Video } from "../../skia/types";
3
+ export type Animated<T> = SharedValue<T> | T;
4
+ export interface PlaybackOptions {
5
+ playbackSpeed: Animated<number>;
6
+ looping: Animated<boolean>;
7
+ paused: Animated<boolean>;
8
+ seek: Animated<number | null>;
9
+ }
10
+ type Materialized<T> = {
11
+ [K in keyof T]: T[K] extends Animated<infer U> ? U : T[K];
12
+ };
13
+ export type MaterializedPlaybackOptions = Materialized<Omit<PlaybackOptions, "seek">>;
14
+ export declare const setFrame: (video: Video, currentFrame: SharedValue<SkImage | null>) => void;
15
+ export declare const processVideoState: (video: Video | null, duration: number, framerate: number, currentTimestamp: number, options: Materialized<Omit<PlaybackOptions, "seek">>, currentTime: SharedValue<number>, currentFrame: SharedValue<SkImage | null>, lastTimestamp: SharedValue<number>, seek: SharedValue<number | null>) => void;
16
+ export {};
@@ -5,4 +5,5 @@ export interface Video extends SkJSIInstance<"Video"> {
5
5
  framerate(): number;
6
6
  nextImage(): SkImage | null;
7
7
  seek(time: number): void;
8
+ getRotationInDegrees(): number;
8
9
  }
@@ -30,3 +30,4 @@ export * from "./Size";
30
30
  export * from "./Paragraph";
31
31
  export * from "./Matrix4";
32
32
  export * from "./NativeBuffer";
33
+ export * from "./Video";
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "setup-skia-web": "./scripts/setup-canvaskit.js"
8
8
  },
9
9
  "title": "React Native Skia",
10
- "version": "1.3.1",
10
+ "version": "1.3.2",
11
11
  "description": "High-performance React Native Graphics using Skia",
12
12
  "main": "lib/module/index.js",
13
13
  "react-native": "src/index.ts",
@@ -1,26 +1,15 @@
1
- import {
2
- runOnUI,
3
- useSharedValue,
4
- type FrameInfo,
5
- type SharedValue,
6
- } from "react-native-reanimated";
7
- import { useCallback, useEffect, useMemo } from "react";
1
+ import { type FrameInfo } from "react-native-reanimated";
2
+ import { useEffect, useMemo } from "react";
8
3
 
9
4
  import { Skia } from "../../skia/Skia";
10
- import type { SkImage } from "../../skia/types";
11
- import { Platform } from "../../Platform";
5
+ import type { SkImage, Video } from "../../skia/types";
12
6
 
13
7
  import Rea from "./ReanimatedProxy";
14
-
15
- type Animated<T> = SharedValue<T> | T;
16
-
17
- export interface PlaybackOptions {
18
- playbackSpeed: Animated<number>;
19
- looping: Animated<boolean>;
20
- paused: Animated<boolean>;
21
- seek: Animated<number | null>;
22
- currentTime: Animated<number>;
23
- }
8
+ import {
9
+ processVideoState,
10
+ type Animated,
11
+ type PlaybackOptions,
12
+ } from "./video";
24
13
 
25
14
  const defaultOptions = {
26
15
  playbackSpeed: 1,
@@ -33,12 +22,17 @@ const defaultOptions = {
33
22
  const useOption = <T>(value: Animated<T>) => {
34
23
  "worklet";
35
24
  // TODO: only create defaultValue is needed (via makeMutable)
36
- const defaultValue = useSharedValue(
25
+ const defaultValue = Rea.useSharedValue(
37
26
  Rea.isSharedValue(value) ? value.value : value
38
27
  );
39
28
  return Rea.isSharedValue(value) ? value : defaultValue;
40
29
  };
41
30
 
31
+ const disposeVideo = (video: Video | null) => {
32
+ "worklet";
33
+ video?.dispose();
34
+ };
35
+
42
36
  export const useVideo = (
43
37
  source: string | null,
44
38
  userOptions?: Partial<PlaybackOptions>
@@ -47,84 +41,42 @@ export const useVideo = (
47
41
  const isPaused = useOption(userOptions?.paused ?? defaultOptions.paused);
48
42
  const looping = useOption(userOptions?.looping ?? defaultOptions.looping);
49
43
  const seek = useOption(userOptions?.seek ?? defaultOptions.seek);
50
- const currentTime = useOption(
51
- userOptions?.currentTime ?? defaultOptions.currentTime
52
- );
53
44
  const playbackSpeed = useOption(
54
45
  userOptions?.playbackSpeed ?? defaultOptions.playbackSpeed
55
46
  );
56
47
  const currentFrame = Rea.useSharedValue<null | SkImage>(null);
48
+ const currentTime = Rea.useSharedValue(0);
57
49
  const lastTimestamp = Rea.useSharedValue(-1);
58
- const startTimestamp = Rea.useSharedValue(-1);
59
-
60
- const framerate = useMemo(() => (video ? video.framerate() : -1), [video]);
61
- const duration = useMemo(() => (video ? video.duration() : -1), [video]);
62
- const frameDuration = useMemo(
63
- () => (framerate > 0 ? 1000 / framerate : -1),
64
- [framerate]
50
+ const duration = useMemo(() => video?.duration() ?? 0, [video]);
51
+ const framerate = useMemo(() => video?.framerate() ?? 0, [video]);
52
+ const rotationInDegrees = useMemo(
53
+ () => video?.getRotationInDegrees() ?? 0,
54
+ [video]
65
55
  );
66
- const disposeVideo = useCallback(() => {
67
- "worklet";
68
- video?.dispose();
69
- }, [video]);
70
-
71
56
  Rea.useFrameCallback((frameInfo: FrameInfo) => {
72
- if (!video) {
73
- return;
74
- }
75
- if (seek.value !== null) {
76
- video.seek(seek.value);
77
- seek.value = null;
78
- lastTimestamp.value = -1;
79
- startTimestamp.value = -1;
80
- }
81
- if (isPaused.value && lastTimestamp.value !== -1) {
82
- return;
83
- }
84
- const { timestamp } = frameInfo;
85
-
86
- // Initialize start timestamp
87
- if (startTimestamp.value === -1) {
88
- startTimestamp.value = timestamp;
89
- }
90
-
91
- // Calculate the current time in the video
92
- const currentTimestamp = timestamp - startTimestamp.value;
93
- currentTime.value = currentTimestamp;
94
-
95
- // Handle looping
96
- if (currentTimestamp > duration && looping.value) {
97
- video.seek(0);
98
- startTimestamp.value = timestamp;
99
- }
100
-
101
- // Update frame only if the elapsed time since last update is greater than the frame duration
102
- const currentFrameDuration = Math.floor(
103
- frameDuration / playbackSpeed.value
57
+ processVideoState(
58
+ video,
59
+ duration,
60
+ framerate,
61
+ frameInfo.timestamp,
62
+ {
63
+ paused: isPaused.value,
64
+ looping: looping.value,
65
+ playbackSpeed: playbackSpeed.value,
66
+ },
67
+ currentTime,
68
+ currentFrame,
69
+ lastTimestamp,
70
+ seek
104
71
  );
105
- const delta = Math.floor(timestamp - lastTimestamp.value);
106
- if (lastTimestamp.value === -1 || delta >= currentFrameDuration) {
107
- const img = video.nextImage();
108
- if (img) {
109
- if (currentFrame.value) {
110
- currentFrame.value.dispose();
111
- }
112
- if (Platform.OS === "android") {
113
- currentFrame.value = img.makeNonTextureImage();
114
- } else {
115
- currentFrame.value = img;
116
- }
117
- }
118
- lastTimestamp.value = timestamp;
119
- }
120
72
  });
121
73
 
122
74
  useEffect(() => {
123
75
  return () => {
124
76
  // TODO: should video simply be a shared value instead?
125
- runOnUI(disposeVideo)();
77
+ Rea.runOnUI(disposeVideo)(video);
126
78
  };
127
- }, [disposeVideo, video]);
79
+ }, [video]);
128
80
 
129
- return currentFrame;
81
+ return { currentFrame, currentTime, duration, framerate, rotationInDegrees };
130
82
  };
@@ -0,0 +1,82 @@
1
+ import type { SharedValue } from "react-native-reanimated";
2
+
3
+ import type { SkImage, Video } from "../../skia/types";
4
+ import { Platform } from "../../Platform";
5
+
6
+ export type Animated<T> = SharedValue<T> | T;
7
+
8
+ export interface PlaybackOptions {
9
+ playbackSpeed: Animated<number>;
10
+ looping: Animated<boolean>;
11
+ paused: Animated<boolean>;
12
+ seek: Animated<number | null>;
13
+ }
14
+
15
+ type Materialized<T> = {
16
+ [K in keyof T]: T[K] extends Animated<infer U> ? U : T[K];
17
+ };
18
+
19
+ export type MaterializedPlaybackOptions = Materialized<
20
+ Omit<PlaybackOptions, "seek">
21
+ >;
22
+
23
+ export const setFrame = (
24
+ video: Video,
25
+ currentFrame: SharedValue<SkImage | null>
26
+ ) => {
27
+ "worklet";
28
+ const img = video.nextImage();
29
+ if (img) {
30
+ if (currentFrame.value) {
31
+ currentFrame.value.dispose();
32
+ }
33
+ if (Platform.OS === "android") {
34
+ currentFrame.value = img.makeNonTextureImage();
35
+ } else {
36
+ currentFrame.value = img;
37
+ }
38
+ }
39
+ };
40
+
41
+ export const processVideoState = (
42
+ video: Video | null,
43
+ duration: number,
44
+ framerate: number,
45
+ currentTimestamp: number,
46
+ options: Materialized<Omit<PlaybackOptions, "seek">>,
47
+ currentTime: SharedValue<number>,
48
+ currentFrame: SharedValue<SkImage | null>,
49
+ lastTimestamp: SharedValue<number>,
50
+ seek: SharedValue<number | null>
51
+ ) => {
52
+ "worklet";
53
+ if (!video) {
54
+ return;
55
+ }
56
+ if (options.paused) {
57
+ return;
58
+ }
59
+ const delta = currentTimestamp - lastTimestamp.value;
60
+
61
+ const frameDuration = 1000 / framerate;
62
+ const currentFrameDuration = Math.floor(
63
+ frameDuration / options.playbackSpeed
64
+ );
65
+ if (currentTime.value + delta >= duration && options.looping) {
66
+ seek.value = 0;
67
+ }
68
+ if (seek.value !== null) {
69
+ video.seek(seek.value);
70
+ currentTime.value = seek.value;
71
+ setFrame(video, currentFrame);
72
+ lastTimestamp.value = currentTimestamp;
73
+ seek.value = null;
74
+ return;
75
+ }
76
+
77
+ if (delta >= currentFrameDuration) {
78
+ setFrame(video, currentFrame);
79
+ currentTime.value += delta;
80
+ lastTimestamp.value = currentTimestamp;
81
+ }
82
+ };
@@ -6,4 +6,5 @@ export interface Video extends SkJSIInstance<"Video"> {
6
6
  framerate(): number;
7
7
  nextImage(): SkImage | null;
8
8
  seek(time: number): void;
9
+ getRotationInDegrees(): number;
9
10
  }
@@ -30,3 +30,4 @@ export * from "./Size";
30
30
  export * from "./Paragraph";
31
31
  export * from "./Matrix4";
32
32
  export * from "./NativeBuffer";
33
+ export * from "./Video";