Skip to content

Instantly share code, notes, and snippets.

@andikan
Created March 6, 2019 11:00
Show Gist options
  • Save andikan/673ef1d1c38b319440d9b0a541c37eef to your computer and use it in GitHub Desktop.
Save andikan/673ef1d1c38b319440d9b0a541c37eef to your computer and use it in GitHub Desktop.
react native play video/audio sample
import React from 'react';
import {
AppRegistry,
WebView
} from 'react-native';
export default class Demo extends React.Component {
render() {
const source = require('./assets/player.html');
return (
<WebView source={source}/>
);
}
}
AppRegistry.registerComponent('Demo', () => Demo);
...
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
...
<html>
<body>
<video width="320" height="240" controls>
<source src="https://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
<audio controls>
<source src="https://www.w3schools.com/html/horse.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment