Index of every page on this site: llms.txt
All skills
software-mansion-labs avatar

/react-native-client

@43cde80
Run it yourself

React Native / Expo SDK for Fishjam — video/audio streaming on iOS and Android. Use when writing a React Native or Expo app that calls Fishjam, configures the Fishjam Expo plugin, sets up permissions, runs background streaming, integrates CallKit, or renders RTCView. Trigger on: '@fishjam-cloud/react-native-client', 'fishjam expo plugin', 'FishjamProvider mobile', 'useCameraPermissions', 'useMicrophonePermissions', 'useForegroundService', 'useCallKit', 'useCallKitEvent', 'useCallKitService', 'RTCView', 'RTCPIPView', 'ScreenCapturePickerView', 'startPIP', 'stopPIP', 'AudioDeviceType', 'useAudioOutput', '@fishjam-cloud/react-native-webrtc', 'fishjam react native', 'expo fishjam', 'fishjam ios', 'fishjam android', 'broadcast extension'. Re-exports @fishjam-cloud/react-client hooks plus mobile-only: permissions, foreground service, iOS broadcast extension, audio routing, CallKit, Expo config plugin.

  • 11 files
  • 54.9 KB
  • MIT
  • Updated 6 months ago
  • GitHub
Use this Skill: https://skilld.dev/gh/software-mansion-labs/skills/react-native-client

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

audio-output.md

≈1.2k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Audio Output Routing

Mobile devices have multiple audio outputs — earpiece, speaker, wired headset, Bluetooth headset — and the OS routes audio to one of them. The SDK exposes a hook to read and override the routing.

No web equivalent in the React client — programmatic audio-output routing on the web relies on browser-specific APIs (e.g. HTMLMediaElement.setSinkId) with uneven cross-browser support, so the SDK doesn't expose an equivalent hook. This is mobile-only.

API

import {
  useAudioOutput,
  AudioDeviceType,
} from '@fishjam-cloud/react-native-client';
import type {
  AudioDevice,
  AudioOutputChangedInfo,
  UseAudioOutputResult,
} from '@fishjam-cloud/react-native-client';

const result: UseAudioOutputResult = useAudioOutput();

The SDK re-exports useAudioOutput and AudioDeviceType directly from @fishjam-cloud/react-native-webrtc, plus the types AudioDevice, AudioOutputChangedInfo, and UseAudioOutputResult.

Exact field names on UseAudioOutputResult (list of devices, current selection, selector function) and AudioDevice come from the upstream @fishjam-cloud/react-native-webrtc types. Use TypeScript intellisense or check those types directly when wiring this up — destructure the hook result and let the compiler guide you.

AudioDeviceType enumerates the broad categories: earpiece, speaker, bluetooth, wiredHeadset, usb, hdmi, airplay, carAudio, hearingAid, lineOut, unknown. Use the enum members (e.g. AudioDeviceType.speaker, AudioDeviceType.bluetooth) — they're lowercase to match the upstream package — rather than string literals so renames don't silently break your code.

Default routing

If you never call the selector, the OS picks a sensible default:

  • Headset connected → headset.
  • Bluetooth connected and the user prefers it → Bluetooth.
  • Otherwise → earpiece for voice-only / speaker for video calls (heuristic-based).

Most apps don't need to override. Override when:

  • The user explicitly toggles "speakerphone" on or off.
  • You want video calls to start in speaker mode by default.
  • An external audio router demands a specific output (Bluetooth deck, USB audio interface, etc.).

API shape

useAudioOutput() returns:

type UseAudioOutputResult = {
  currentAudioOutput: AudioDevice | null;
  availableAudioOutputs: AudioDevice[];
  ios: {
    showAudioRoutePicker(): void;
    overrideAudioOutput(output: 'speaker' | 'none'): Promise<void>;
  };
  android: {
    selectAudioOutput(deviceId: string): Promise<void>;
    // …additional Android-only controls
  };
};

The .ios / .android namespaces throw if you call them on the wrong platform — guard with Platform.OS first.

Forcing speaker mode

On iOS, override the route to the built-in speaker:

import { useAudioOutput } from '@fishjam-cloud/react-native-client';
import { Platform } from 'react-native';
import { useEffect } from 'react';

function ForceSpeaker() {
  const audio = useAudioOutput();

  useEffect(() => {
    if (Platform.OS === 'ios') {
      audio.ios.overrideAudioOutput('speaker').catch(console.error);
    }
  }, [audio]);

  return null;
}

On Android, pick a specific output device by its id:

const speaker = audio.availableAudioOutputs.find((d) => d.type === AudioDeviceType.speaker);
if (speaker && Platform.OS === 'android') {
  await audio.android.selectAudioOutput(speaker.id);
}

Reactive Bluetooth in/out

The hook's device list updates when the user connects or disconnects a Bluetooth or wired headset — re-render off the hook value rather than subscribing to OS audio events separately. When a previously-selected device disconnects, the OS picks a fallback automatically and the hook reports the new selection.

Pairing with CallKit / foreground service

  • During a CallKit session, iOS respects audio routes the same way as during a phone call (e.g. Bluetooth headset, AirPods).
  • During an Android foreground-service-backed session, the SDK's audio focus declarations cooperate with the OS routing.

In both cases the selector works as expected — no special handling needed.

Sources

  • packages/mobile-client/src/index.ts (re-exports useAudioOutput, AudioDeviceType, type aliases)
  • @fishjam-cloud/react-native-webrtc → lib/typescript/useAudioOutput.d.ts (UseAudioOutputResult) and lib/typescript/audioOutputManager/AudioOutputManager.d.ts (AudioDevice, AudioDeviceType, AudioOutputChangedInfo, ios.showAudioRoutePicker, ios.overrideAudioOutput('speaker' | 'none'), android.selectAudioOutput(deviceId))

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No third-party reports yet.

Signed by skilld at 43cde80. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 weeks ago.

Activeupdated 6 months ago

README badge

README badge for software-mansion-labs/skills/react-native-client