From 4be0fb5a5f3a0bc92af59440f36c7ce467a4e297 Mon Sep 17 00:00:00 2001 From: Zhiyuan Zheng Date: Mon, 29 Mar 2021 23:53:49 +0200 Subject: [PATCH] Partial fix #90 Now playing gifv won't interrupt existing audio playing. But when switching app state, it still will. --- Gemfile.lock | 12 +++++----- fastlane/Fastfile | 2 +- src/components/Instance.tsx | 22 +++++++++++++++++++ src/components/Timeline.tsx | 2 +- .../Timeline/Shared/Attachment/Video.tsx | 15 ++++++------- src/screens/Compose/Root.tsx | 4 +++- src/screens/Compose/Root/Footer/Emojis.tsx | 2 +- src/screens/Tabs/Shared/Users.tsx | 4 +--- src/startup/audio.ts | 7 ++++-- 9 files changed, 47 insertions(+), 23 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index fb410963..7b2accf9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,7 +2,7 @@ GEM remote: https://rubygems.org/ specs: CFPropertyList (3.0.3) - activesupport (5.2.4.5) + activesupport (5.2.5) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) @@ -15,7 +15,7 @@ GEM artifactory (3.0.15) atomos (0.1.3) aws-eventstream (1.1.1) - aws-partitions (1.432.0) + aws-partitions (1.436.0) aws-sdk-core (3.113.0) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.239.0) @@ -24,7 +24,7 @@ GEM aws-sdk-kms (1.43.0) aws-sdk-core (~> 3, >= 3.112.0) aws-sigv4 (~> 1.1) - aws-sdk-s3 (1.91.0) + aws-sdk-s3 (1.93.0) aws-sdk-core (~> 3, >= 3.112.0) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.1) @@ -97,7 +97,7 @@ GEM faraday_middleware (1.0.0) faraday (~> 1.0) fastimage (2.2.3) - fastlane (2.178.0) + fastlane (2.179.0) CFPropertyList (>= 2.3, < 4.0.0) addressable (>= 2.3, < 3.0.0) artifactory (~> 3.0) @@ -196,7 +196,7 @@ GEM jwt (2.2.2) memoist (0.16.2) mini_magick (4.11.0) - mini_mime (1.0.2) + mini_mime (1.0.3) minitest (5.14.4) molinillo (0.6.6) multi_json (1.15.0) @@ -260,7 +260,7 @@ GEM xcpretty (~> 0.2, >= 0.0.7) PLATFORMS - ruby + universal-darwin-20 DEPENDENCIES cocoapods diff --git a/fastlane/Fastfile b/fastlane/Fastfile index db926d36..c1d922ea 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -1,4 +1,4 @@ -fastlane_version "2.178.0" +fastlane_version "2.179.0" skip_docs ensure_env_vars( diff --git a/src/components/Instance.tsx b/src/components/Instance.tsx index e7dfee70..e9aeb412 100644 --- a/src/components/Instance.tsx +++ b/src/components/Instance.tsx @@ -138,6 +138,23 @@ const ComponentInstance: React.FC = ({ ) : null} + + } + /> = ({ ref={customFLRef || flRef} scrollEventThrottle={16} onScroll={onScroll} - windowSize={10} + windowSize={7} data={flattenData} initialNumToRender={6} maxToRenderPerBatch={3} diff --git a/src/components/Timeline/Shared/Attachment/Video.tsx b/src/components/Timeline/Shared/Attachment/Video.tsx index d8c87c32..c9ceb408 100644 --- a/src/components/Timeline/Shared/Attachment/Video.tsx +++ b/src/components/Timeline/Shared/Attachment/Video.tsx @@ -1,7 +1,7 @@ import Button from '@components/Button' import { StyleConstants } from '@utils/styles/constants' import { Video } from 'expo-av' -import React, { useCallback, useEffect, useRef, useState } from 'react' +import React, { useCallback, useRef, useState } from 'react' import { Pressable, StyleSheet, View } from 'react-native' import { Blurhash } from 'react-native-blurhash' import attachmentAspectRatio from './aspectRatio' @@ -54,12 +54,6 @@ const AttachmentVideo: React.FC = ({ }) }, [videoLoaded, videoPosition]) - useEffect(() => { - if (gifv) { - videoPlayer.current?.setIsLoopingAsync(true) - } - }, []) - return ( = ({ }} usePoster {...(gifv - ? { shouldPlay: true, source: { uri: video.url } } + ? { + shouldPlay: true, + isMuted: true, + isLooping: true, + source: { uri: video.url } + } : { resizeMode: 'cover', posterSource: { uri: video.preview_url }, diff --git a/src/screens/Compose/Root.tsx b/src/screens/Compose/Root.tsx index fea1bff6..e8da9e8a 100644 --- a/src/screens/Compose/Root.tsx +++ b/src/screens/Compose/Root.tsx @@ -34,7 +34,9 @@ const prefetchEmojis = ( requestedIndex++ }) }) - FastImage.preload(prefetches) + try { + FastImage.preload(prefetches) + } catch {} } const ComposeRoot = React.memo( diff --git a/src/screens/Compose/Root/Footer/Emojis.tsx b/src/screens/Compose/Root/Footer/Emojis.tsx index 0be2886b..d2cee289 100644 --- a/src/screens/Compose/Root/Footer/Emojis.tsx +++ b/src/screens/Compose/Root/Footer/Emojis.tsx @@ -78,7 +78,7 @@ const ComposeEmojis: React.FC = () => { keyExtractor={item => item.shortcode} renderSectionHeader={listHeader} renderItem={listItem} - windowSize={3} + windowSize={2} /> ) diff --git a/src/screens/Tabs/Shared/Users.tsx b/src/screens/Tabs/Shared/Users.tsx index c26770f6..5bbec464 100644 --- a/src/screens/Tabs/Shared/Users.tsx +++ b/src/screens/Tabs/Shared/Users.tsx @@ -38,10 +38,8 @@ const TabSharedUsers = React.memo( return ( { log('log', 'audio', 'setting audio playback default options') Audio.setAudioModeAsync({ playsInSilentModeIOS: true, - interruptionModeIOS: 1 + interruptionModeIOS: Audio.INTERRUPTION_MODE_IOS_DO_NOT_MIX, + interruptionModeAndroid: Audio.INTERRUPTION_MODE_ANDROID_DO_NOT_MIX, + shouldDuckAndroid: true, + playThroughEarpieceAndroid: true }) }