UNPKG

mediasfu-reactnative-expo

Version:
31 lines 909 B
import { Audio } from 'expo-av'; /** * Plays a sound from a given URL. * * @param {SoundPlayerOptions} options - The options for the sound player. * @param {string} options.soundUrl - The URL of the sound to play. * * @returns {void} * * @example * ```typescript * SoundPlayer({ soundUrl: 'https://example.com/sound.mp3' }); * ``` */ export const SoundPlayer = async ({ soundUrl }) => { /** * Plays a sound from the specified URL. * @function * @param {string} url - The URL of the sound to play. */ const { sound } = await Audio.Sound.createAsync({ uri: soundUrl }); // Play the sound await sound.playAsync(); // Release the sound once it's finished playing sound.setOnPlaybackStatusUpdate((status) => { if (status.isLoaded && status.didJustFinish) { sound.unloadAsync(); } }); }; //# sourceMappingURL=SoundPlayer.js.map