Why is react-native-html-render not rendering html audio tag? Is it possible to do it with this library? Since there is iframe plugin to handle videos and it feels like there should be one to do that with audio but I can not find. Thanks in advance.
Asked
Active
Viewed 680 times
0
-
try with this library [react-native-render-html](https://www.npmjs.com/package/react-native-render-html) – DhavalR Nov 09 '21 at 12:16
-
"it feels like there should be" → You can always create a feature request here: https://native-html.canny.io/features ! And I want to remember kindly, "Open Source contributors don't owe you anything". I would love to see the community starting to make some plugins! – Jules Sam. Randolph Nov 10 '21 at 10:05
1 Answers
0
You can also use expo-av libary to play audio within your app (https://docs.expo.dev/versions/latest/sdk/audio/)
import * as React from 'react';
import { Text, View, StyleSheet, Button } from 'react-native';
import { Audio } from 'expo-av';
export default function App() {
const [sound, setSound] = React.useState();
async function playSound() {
console.log('Loading Sound');
const { sound } = await Audio.Sound.createAsync(
require('./assets/Hello.mp3')
);
setSound(sound);
console.log('Playing Sound');
await sound.playAsync(); }
React.useEffect(() => {
return sound
? () => {
console.log('Unloading Sound');
sound.unloadAsync(); }
: undefined;
}, [sound]);
return (
<View style={styles.container}>
<Button title="Play Sound" onPress={playSound} />
</View>
);
}

carlosdafield
- 1,479
- 5
- 16