-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathSeriesEpisodeViewer.js
executable file
·132 lines (115 loc) · 4.01 KB
/
SeriesEpisodeViewer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import React, { Component } from 'react';
import { Linking, Platform, StyleSheet, ScrollView, Text } from 'react-native';
import { Button, Card } from 'react-native-elements';
import { play } from 'react-native-vlc-player';
import { ConfirmDialog } from 'react-native-simple-dialogs';
import getLocalizedString from './utils/getLocalizedString';
const colors = {
deepSkyBlue: '#03A9F4',
};
const styles = StyleSheet.create({
activityContainer: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
text: {
marginBottom: 10,
fontSize: 16,
},
button: {
borderRadius: 0,
marginLeft: 0,
marginRight: 0,
marginBottom: 0,
},
});
class SeriesEpisodePicker extends Component {
/* eslint-disable react/sort-comp */
state = {
dialogVisible: false,
};
/* eslint-enable react/sort-comp */
render() {
const {
url, username, password, s,
} = this.props.navigation.state.params;
const card = s.info.movie_image ? (
<Card image={{ uri: s.info.movie_image }} imageProps={{ resizeMode: 'contain' }} title={s.title}>
{s.info.name.length ? <Text>Name:{s.info.name}</Text> : null}
{s.info.plot.length ? <Text>Plot: {s.info.plot}</Text> : null}
{s.info.releasedate.length ? <Text>Release Date: {s.info.releasedate}</Text> : null}
{s.info.rating.length ? <Text>Rating: {s.info.rating}</Text> : null}
<Button
backgroundColor={colors.deepSkyBlue}
buttonStyle={styles.button}
icon={{ name: 'eye', type: 'font-awesome' }}
onPress={() => this.viewNow(url, username, password, s)}
title={getLocalizedString('liveChannel.viewNow')} />
</Card>
) : (
<Card title={s.title}>
{s.info.name.length ? <Text>Name:{s.info.name}</Text> : null}
{s.info.plot.length ? <Text>Plot: {s.info.plot}</Text> : null}
{s.info.releasedate.length ? <Text>Release Date: {s.info.releasedate}</Text> : null}
{s.info.rating.length ? <Text>Rating: {s.info.rating}</Text> : null}
<Button
backgroundColor={colors.deepSkyBlue}
buttonStyle={styles.button}
icon={{ name: 'eye', type: 'font-awesome' }}
onPress={() => this.viewNow(url, username, password, s)}
title={getLocalizedString('liveChannel.viewNow')} />
</Card>
);
if (this.state.dialogVisible) {
const message = getLocalizedString('liveChannel.message');
return (
<ConfirmDialog
message={message}
negativeButton={{
onPress: () => {
this.setState({ dialogVisible: false });
if (Platform.OS === 'android') {
play(url + '/series/' + username + '/' + password + '/' + s.id + '.' + s.container_extension);
} else if (Platform.OS === 'ios') {
this.props.navigation.navigate('PlayeriOS', { uri: url + '/series/' + username + '/' + password + '/' + s.id + '.' + s.container_extension });
} else {
throw new Error('Platform not recognized: ' + Platform.OS);
}
},
title: getLocalizedString('liveChannel.no'),
}}
onTouchOutside={() => this.setState({ dialogVisible: false })}
positiveButton={{
onPress: () => {
this.setState({ dialogVisible: false });
if (Platform.OS === 'android') {
Linking.openURL(url + '/series/' + username + '/' + password + '/' + s.id + '.' + s.container_extension);
} else if (Platform.OS === 'ios') {
Linking.openURL('vlc-x-callback://x-callback-url/stream?url=' + url + '/series/' + username + '/' + password + '/' + s.id + '.' + s.container_extension);
} else {
throw new Error('Platform not recognized: ' + Platform.OS);
}
},
title: getLocalizedString('liveChannel.yes'),
}}
title={getLocalizedString('liveChannel.title')}
visible={this.state.dialogVisible} />
);
}
return (
<ScrollView>
{card}
</ScrollView>
);
}
viewNow(url, username, password, ch) {
if (Platform.OS === 'android' || Platform.OS === 'ios') {
this.setState({ dialogVisible: true });
} else {
throw new Error('Platform not recognized: ' + Platform.OS);
}
return this;
}
}
export default SeriesEpisodePicker;