Skip to content

Commit

Permalink
bogus testing commit
Browse files Browse the repository at this point in the history
  • Loading branch information
haileyok committed Apr 19, 2024
1 parent faae209 commit b3c8751
Showing 1 changed file with 78 additions and 43 deletions.
121 changes: 78 additions & 43 deletions src/view/com/util/post-embeds/ExternalGifEmbed.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import React, {useRef} from 'react'
import {
ActivityIndicator,
GestureResponderEvent,
Expand All @@ -18,6 +18,17 @@ import {isIOS, isNative, isWeb} from '#/platform/detection'
import {useExternalEmbedsPrefs} from '#/state/preferences'
import {useDialogControl} from '#/components/Dialog'
import {EmbedConsentDialog} from '#/components/dialogs/EmbedConsent'
import {VideoPlayer} from '../../../../../modules/expo-bluesky-video-player'

const GIF_LIST = [
'https://media1.giphy.com/media/duexIlfr9yYwYE23UA/200w.mp4',
'https://media2.giphy.com/media/p9FB3WC9Xju4o/200w.mp4',
'https://media2.giphy.com/media/iGAXf0OlUUMYo/200w.mp4',
'https://media4.giphy.com/media/cFeXVeTKDB0fm/200w.mp4',
'https://media3.giphy.com/media/qs6ev2pm8g9dS/200w.mp4',
'https://media2.giphy.com/media/6R2mLi910HL4VXFwOG/200w.mp4',
'https://media4.giphy.com/media/rOGuft1jgiq66zpQI2/200w.mp4',
]

export function ExternalGifEmbed({
link,
Expand Down Expand Up @@ -102,55 +113,79 @@ export function ExternalGifEmbed({
viewWidth.current = e.nativeEvent.layout.width
}, [])

const onDidLoad = React.useCallback(() => {}, [])

const rand = React.useMemo(
() => GIF_LIST[Math.floor(Math.random() * GIF_LIST.length)],
[],
)

const playerRef = useRef()

return (
<>
<EmbedConsentDialog
control={consentDialogControl}
source={params.source}
onAccept={load}
/>
{/*<EmbedConsentDialog*/}
{/* control={consentDialogControl}*/}
{/* source={params.source}*/}
{/* onAccept={load}*/}
{/*/>*/}

<Pressable
style={[
{height: imageDims.height},
styles.topRadius,
styles.gifContainer,
]}
onPress={onPlayPress}
onLayout={onLayout}
accessibilityRole="button"
accessibilityHint={_(msg`Plays the GIF`)}
accessibilityLabel={_(msg`Play ${link.title}`)}>
{(!isPrefetched || !isAnimating) && ( // If we have not loaded or are not animating, show the overlay
<View style={[styles.layer, styles.overlayLayer]}>
<View style={[styles.overlayContainer, styles.topRadius]}>
{!isAnimating || !isPlayerActive ? ( // Play button when not animating or not active
<FontAwesomeIcon icon="play" size={42} color="white" />
) : (
// Activity indicator while gif loads
<ActivityIndicator size="large" color="white" />
)}
</View>
</View>
)}
<Image
source={{
uri:
!isPrefetched || (isWeb && !isAnimating)
? link.thumb
: params.playerUri,
}} // Web uses the thumb to control playback
style={{flex: 1}}
ref={imageRef}
onLoad={onLoad}
autoplay={isAnimating}
contentFit="contain"
accessibilityIgnoresInvertColors
accessibilityLabel={link.title}
accessibilityHint={link.title}
cachePolicy={isIOS ? 'disk' : 'memory-disk'} // cant control playback with memory-disk on ios
onPress={() => {
playerRef.current.toggleAsync()
}}>
<VideoPlayer
// source="https://media3.giphy.com/media/v1.Y2lkPTc5MGI3NjExcXJ0ZXk0cmk0b2hmNXhzaGxmbGw4dGE2b2JxNzc4NW13b3Y4MGJrYyZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/1BXa2alBjrCXC/giphy.mp4"
// source="https://media1.giphy.com/media/duexIlfr9yYwYE23UA/200h.mp4"
// source="https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"
source={rand}
style={{height: 200, width: '100%'}}
ref={playerRef}
/>
</Pressable>

{/*<Pressable*/}
{/* style={[*/}
{/* {height: imageDims.height},*/}
{/* styles.topRadius,*/}
{/* styles.gifContainer,*/}
{/* ]}*/}
{/* onPress={onPlayPress}*/}
{/* onLayout={onLayout}*/}
{/* accessibilityRole="button"*/}
{/* accessibilityHint={_(msg`Plays the GIF`)}*/}
{/* accessibilityLabel={_(msg`Play ${link.title}`)}>*/}
{/* {(!isPrefetched || !isAnimating) && ( // If we have not loaded or are not animating, show the overlay*/}
{/* <View style={[styles.layer, styles.overlayLayer]}>*/}
{/* <View style={[styles.overlayContainer, styles.topRadius]}>*/}
{/* {!isAnimating || !isPlayerActive ? ( // Play button when not animating or not active*/}
{/* <FontAwesomeIcon icon="play" size={42} color="white" />*/}
{/* ) : (*/}
{/* // Activity indicator while gif loads*/}
{/* <ActivityIndicator size="large" color="white" />*/}
{/* )}*/}
{/* </View>*/}
{/* </View>*/}
{/* )}*/}
{/* <Image*/}
{/* source={{*/}
{/* uri:*/}
{/* !isPrefetched || (isWeb && !isAnimating)*/}
{/* ? link.thumb*/}
{/* : params.playerUri,*/}
{/* }} // Web uses the thumb to control playback*/}
{/* style={{flex: 1}}*/}
{/* ref={imageRef}*/}
{/* onLoad={onLoad}*/}
{/* autoplay={isAnimating}*/}
{/* contentFit="contain"*/}
{/* accessibilityIgnoresInvertColors*/}
{/* accessibilityLabel={link.title}*/}
{/* accessibilityHint={link.title}*/}
{/* cachePolicy={isIOS ? 'disk' : 'memory-disk'} // cant control playback with memory-disk on ios*/}
{/* />*/}
{/*</Pressable>*/}
</>
)
}
Expand Down

0 comments on commit b3c8751

Please sign in to comment.