UNPKG

media_player_wrapper

Version:
105 lines (95 loc) 2.77 kB
import React, { Component } from "react"; import { DeviceEventEmitter, AppRegistry, StyleSheet, Text, View, Button, TouchableHighlight } from "react-native"; import { NativeModules } from "react-native"; //"/storage/extSdCard/MediaFiles/3.mp3" //"http://www.youtube.com/api/manifest/dash/id/bf5bb2419360daf1/source/youtube?as=fmp4_audio_clear,fmp4_sd_hd_clear&sparams=ip,ipbits,expire,source,id,as&ip=0.0.0.0&ipbits=0&expire=19000000000&signature=51AF5F39AB0CEC3E5497CD9C900EBFEAECCCB5C7.8506521BFC350652163895D4C26DEE124209AA9E&key=ik0" //http://ice31.securenetsystems.net/NOGOUM const filePath = "http://ice31.securenetsystems.net/NOGOUM"; const filePathExtension = "mpd"; DeviceEventEmitter.addListener("CB_CONNECT", msg => { console.log("===================================="); console.log(msg); console.log("===================================="); // NativeModules.RNMediaLibrary.play(filePath, null); }); DeviceEventEmitter.addListener("CB_PLAYBACKSTATE", msg => { console.log("===================================="); console.log(msg); console.log("===================================="); }); export default class RNNativeModules extends Component { componentWillMount() { NativeModules.RNMediaLibrary.connect(); } render() { return ( <View style={styles.container}> <TouchableHighlight style={{ padding: 10 }} onPress={() => { NativeModules.RNMediaLibrary.play( filePath, null, "She Wolf", "Sia", null ); }} > <Text>Play</Text> </TouchableHighlight> <TouchableHighlight style={{ padding: 10 }} onPress={() => { NativeModules.RNMediaLibrary.pause(); }} > <Text>Pause</Text> </TouchableHighlight> <TouchableHighlight style={{ padding: 10 }} onPress={() => { NativeModules.RNMediaLibrary.forward(); }} > <Text>Forward</Text> </TouchableHighlight> <TouchableHighlight style={{ padding: 10 }} onPress={() => { NativeModules.RNMediaLibrary.rewind(); }} > <Text>Rewind</Text> </TouchableHighlight> </View> ); } } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: "center", alignItems: "center", backgroundColor: "#F5FCFF" }, welcome: { fontSize: 20, textAlign: "center", margin: 10 }, instructions: { textAlign: "center", color: "#333333", marginBottom: 5 } }); AppRegistry.registerComponent("RNNativeModules", () => RNNativeModules);