Skip to content

Instantly share code, notes, and snippets.

@stan229
Last active October 15, 2015 04:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stan229/6fcf43b86b12488bc516 to your computer and use it in GitHub Desktop.
Save stan229/6fcf43b86b12488bc516 to your computer and use it in GitHub Desktop.
'use strict';
var React = require('react-native');
var MediaController = require('NativeModules').MediaController;
var {
AppRegistry,
StyleSheet,
Text,
TouchableHighlight,
View,
NativeAppEventEmitter
} = React;
class MCDJ extends React.Component {
constructor(props) {
super(props);
this.state = this.getInitialState();
this.bindMethods();
}
bindMethods() {
if (! this.bindableMethods) {
return;
}
for (var methodName in this.bindableMethods) {
this[methodName] = this.bindableMethods[methodName].bind(this);
}
}
getInitialState() {
return {
songPlaying : 'None'
}
}
componentDidMount() {
// Add Event Listener for SongPlaying event from MediaController
NativeAppEventEmitter.addListener('SongPlaying', (songName) => this.setState({songPlaying : songName}))
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment