File tree Expand file tree Collapse file tree 2 files changed +18
-6
lines changed
example/src/Examples/Video
package/src/external/reanimated Expand file tree Collapse file tree 2 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ import Slider from "@react-native-community/slider";
1616const videoURL =
1717 Platform . OS === "web"
1818 ? require ( "../../Tests/assets/BigBuckBunny.mp4" ) . default
19- : "https://bit.ly/skia-video-short " ;
19+ : "https://bit.ly/skia-video" ;
2020
2121export const Video = ( ) => {
2222 const paused = useSharedValue ( false ) ;
Original file line number Diff line number Diff line change @@ -22,18 +22,29 @@ interface PlaybackOptions {
2222 volume : Animated < number > ;
2323}
2424
25+ const copyFrameOnAndroid = ( currentFrame : SharedValue < SkImage | null > ) => {
26+ "worklet" ;
27+ // on android we need to copy the texture before it's invalidated
28+ if ( Platform . OS === "android" ) {
29+ const tex = currentFrame . value ;
30+ if ( tex ) {
31+ console . log ( "Copying frame on Android" ) ;
32+ currentFrame . value = tex . makeNonTextureImage ( ) ;
33+ tex . dispose ( ) ;
34+ }
35+ }
36+ } ;
37+
2538const setFrame = ( video : Video , currentFrame : SharedValue < SkImage | null > ) => {
2639 "worklet" ;
2740 const img = video . nextImage ( ) ;
2841 if ( img ) {
2942 if ( currentFrame . value ) {
3043 currentFrame . value . dispose ( ) ;
3144 }
32- if ( Platform . OS === "android" ) {
33- currentFrame . value = img . makeNonTextureImage ( ) ;
34- } else {
35- currentFrame . value = img ;
36- }
45+ currentFrame . value = img ;
46+ } else {
47+ copyFrameOnAndroid ( currentFrame ) ;
3748 }
3849} ;
3950
@@ -111,6 +122,7 @@ export const useVideo = (
111122 ( ) => seek . value ,
112123 ( value ) => {
113124 if ( value !== null ) {
125+ copyFrameOnAndroid ( currentFrame ) ;
114126 video ?. seek ( value ) ;
115127 currentTime . value = value ;
116128 seek . value = null ;
You can’t perform that action at this time.
0 commit comments