Last active
October 15, 2015 04:51
-
-
Save stan229/6fcf43b86b12488bc516 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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