Skip to content

Commit

Permalink
Add existing project
Browse files Browse the repository at this point in the history
  • Loading branch information
kyo504 committed Feb 16, 2018
0 parents commit eed3a32
Show file tree
Hide file tree
Showing 132 changed files with 5,697 additions and 0 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
16 changes: 16 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"parser": "babel-eslint",
"extends": "airbnb",
"plugins": [
"prefer-object-spread"
],
"rules": {
"prefer-object-spread/prefer-object-spread": 2,
"react/jsx-filename-extension": 0,
"react/prefer-stateless-function": 0,
"react/sort-comp": 0,
"no-use-before-define": 0,
"no-underscore-dangle": 0,
"import/no-unresolved": [2, { "ignore": ["react"] }]
}
}
42 changes: 42 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# OSX
#
.DS_Store

# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace

# Android/IJ
#
*.iml
.idea
.gradle
local.properties
*.hprof

# node.js
#
node_modules/
npm-debug.log

# BUCK
buck-out/
\.buckd/
android/app/libs
android/keystores/debug.keystore
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Example
3 changes: 3 additions & 0 deletions Example/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["react-native"]
}
6 changes: 6 additions & 0 deletions Example/.buckconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

[android]
target = Google Inc.:Google APIs:23

[maven_repositories]
central = https://repo1.maven.org/maven2
44 changes: 44 additions & 0 deletions Example/.flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[ignore]
; We fork some components by platform
.*/*[.]android.js

; Ignore "BUCK" generated dirs
<PROJECT_ROOT>/\.buckd/

; Ignore unexpected extra "@providesModule"
.*/node_modules/.*/node_modules/fbjs/.*

; Ignore duplicate module providers
; For RN Apps installed via npm, "Libraries" folder is inside
; "node_modules/react-native" but in the source repo it is in the root
.*/Libraries/react-native/React.js
.*/Libraries/react-native/ReactNative.js

[include]

[libs]
node_modules/react-native/Libraries/react-native/react-native-interface.js
node_modules/react-native/flow
flow/

[options]
module.system=haste

experimental.strict_type_args=true

munge_underscores=true

module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'

suppress_type=$FlowIssue
suppress_type=$FlowFixMe
suppress_type=$FixMe

suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-7]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-7]\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy

unsafe.enable_getters_and_setters=true

[version]
^0.37.0
1 change: 1 addition & 0 deletions Example/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.pbxproj -text
54 changes: 54 additions & 0 deletions Example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# OSX
#
.DS_Store

# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace

# Android/IntelliJ
#
build/
.idea
.gradle
local.properties
*.iml

# node.js
#
node_modules/
npm-debug.log
yarn-error.log

# BUCK
buck-out/
\.buckd/
android/app/libs
*.keystore

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md

fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
1 change: 1 addition & 0 deletions Example/.watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
202 changes: 202 additions & 0 deletions Example/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
import React, { Component } from 'react';
import {
StyleSheet,
Text,
View,
Button,
DeviceEventEmitter,
Slider,
} from 'react-native';
import Player from 'react-native-streaming-audio-player';

const PLAYBACK_STATE = {
STATE_NONE: 0,
STATE_STOPPED: 1,
STATE_PAUSED: 2,
STATE_PLAYING: 3,
STATE_FAST_FORWARDING: 4,
STATE_REWINDING: 5,
STATE_BUFFERING: 6,
STATE_ERROR: 7,
STATE_CONNECTING: 8,
STATE_SKIPPING_TO_PREVIOUS: 9,
STATE_SKIPPING_TO_NEXT: 10,
STATE_SKIPPING_TO_QUEUE_ITEM: 11,
}

export default class Example extends Component {

constructor(props) {
super(props);

this.state = {
currentTime: 0,
index: 0,
playlist: null,
}

this.dragging = false;

this.onUpdatePosition = this.onUpdatePosition.bind(this);
this.onPlaybackStateChanged = this.onPlaybackStateChanged.bind(this);
}

componentWillMount() {
fetch('http://www.feedyourmusic.com/api/v1/editors_pick')
.then(response => response.json())
.then(playlist => this.setState({ playlist }))
.catch(e => console.log(e))
}

componentDidMount() {
DeviceEventEmitter.addListener('onUpdatePosition', this.onUpdatePosition);
DeviceEventEmitter.addListener('onPlaybackStateChanged', this.onPlaybackStateChanged);
}

componentWillUnmount() {
DeviceEventEmitter.removeListener('onUpdatePosition', this.onUpdatePosition);
DeviceEventEmitter.removeListener('onPlaybackStateChanged', this.onPlaybackStateChanged);
}

onUpdatePosition(event) {
console.log("Current position: " + event.currentPosition);

Player.isPlaying(() => {
if (!this.dragging) {
this.setState({
currentTime: parseInt(event.currentPosition), // convert milisecond to second
});
}
})
}

onPlaybackStateChanged(event) {
console.log("PlaybackState: " + event.state);
}

onPlay() {
const {
playlist,
index
} = this.state;

Player.play('http://pianosolo.streamguys.net/live.m3u', {
title: 'Aaron',
artist: 'Celine Dion',
album_art_uri: 'https://unsplash.it/300/300'
});
}

onPause() {
Player.pause();
}

onStop() {
this.setState({
currentTime: 0,
});
Player.stop();
}

onNext() {
const {
playlist,
index
} = this.state;

this.setState({
currentTime: 0,
index: (index + 1) % playlist.length,
}, () => {
this.onPlay();
})
}

onPrev() {
const {
playlist,
index
} = this.state;

this.setState({
currentTime: 0,
index: index === 0 ? playlist.length - 1 : index,
}, () => {
this.onPlay();
})
}

onSeekTo(pos) {
this.dragging = false;
Player.seekTo(pos);
}

render() {
const {
playlist,
index,
currentTime
} = this.state;

if (!playlist) {
return null;
}

return (
<View style={styles.container}>
<View style={{ flexDirection: 'row', alignSelf: 'stretch', justifyContent: 'space-around' }}>
<Button
title='Play'
onPress={() => this.onPlay()}
color='red'
/>
<Button
title='Pause'
onPress={() => this.onPause()}
color='red'
/>
<Button
title='Stop'
onPress={() => this.onStop()}
color='red'
/>
</View>
<View style={{ alignSelf: 'stretch', marginVertical: 10 }}>
<Slider
value={currentTime}
minimumValue={0}
maximumValue={playlist ? playlist[index].duration : 1}
onValueChange={value => {
this.dragging = true;
}}
step={1}
onSlidingComplete={value => this.onSeekTo(value)}
/>
<View style={{ flexDirection: 'row', justifyContent: 'space-between', marginHorizontal: 15 }}>
<Text>{currentTime}</Text>
<Text>{playlist ? playlist[index].duration : 1}</Text>
</View>
</View>
</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,
},
});
12 changes: 12 additions & 0 deletions Example/__tests__/index.android.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'react-native';
import React from 'react';
import Index from '../index.android.js';

// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';

it('renders correctly', () => {
const tree = renderer.create(
<Index />
);
});
Loading

0 comments on commit eed3a32

Please sign in to comment.