Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beep sound when initializing AudioContext in ios device #228

Closed
sgwanlee opened this issue Dec 9, 2024 · 2 comments · Fixed by #231
Closed

Beep sound when initializing AudioContext in ios device #228

sgwanlee opened this issue Dec 9, 2024 · 2 comments · Fixed by #231
Assignees

Comments

@sgwanlee
Copy link

sgwanlee commented Dec 9, 2024

Description

In simulator, there's no issue. However, when I initialize AudioContext in the iPhone, The beep sound is coming out.

Here's the code I used

export default function HomeScreen() {
  const [isConnected, setIsConnected] = useState(false);
  const audioContextRef = useRef<AudioContext | null>(null);
  const clientRef = useRef<RealtimeClient>(
    new RealtimeClient({
      apiKey: process.env.EXPO_PUBLIC_OPENAI_API_KEY,
      dangerouslyAllowAPIKeyInBrowser: true,
    })
  );

  const connectConversation = async () => {
    console.log("connectConversation");
    if (!audioContextRef.current) {
      audioContextRef.current = new AudioContext();
    }
}
  
return (
    <SafeAreaView>
      <View style={{ padding: 10 }}>
        <TouchableOpacity
          onPress={isConnected ? disconnectConversation : connectConversation}
          style={{ padding: 4 }}
        >
          <Text style={{ color: "red" }}>
            {isConnected ? "Disconnect" : "Connect"}
          </Text>
        </TouchableOpacity>
      </View>
    </SafeAreaView>
  );

Steps to reproduce

npm install
npx expo run:ios -d
Tap connect button

Snack or a link to a repository

https://github.com/sgwanlee/react-natvie-audio-api-test

React Native Audio API version

0.3.0-rc1

React Native version

0.76.3

Platforms

iOS

JavaScript runtime

None

Workflow

Expo Dev Client

Architecture

None

Build type

None

Device

None

Device model

iPhone 15 Pro, 18.1.1

Acknowledgements

Yes

@michalsek
Copy link
Member

We have just published 0.3.0-rc2, It should have the issue resolved :)

@sgwanlee
Copy link
Author

It works! Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants