esoftplay 0.0.111-d → 0.0.111-g

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/esp.ts CHANGED
@@ -8,7 +8,7 @@ import routers from './cache/routers';
8
8
  import './oneplusfixfont';
9
9
  LogBox.ignoreLogs(['YellowBox has been replaced with LogBox. Please call LogBox.ignoreLogs() instead.']);
10
10
  LogBox.ignoreLogs(['VirtualizedLists should never be nested inside plain ScrollViews with the same orientation - use another VirtualizedList-backed container instead.']);
11
- LogBox.ignoreLogs([`Got a component with the name 'm' me.`]);
11
+ LogBox.ignoreLogs([`Got a component with the name 'm'`]);
12
12
  let app = require('../../app.json');
13
13
  let conf = require('../../config.json');
14
14
  let lconf
@@ -0,0 +1,126 @@
1
+ // noPage
2
+
3
+ import { LibComponent } from "esoftplay";
4
+ import { Audio } from "expo-av";
5
+
6
+ export interface ContentAudioProps {
7
+ code: string,
8
+ onStatusChange: (status: any) => void
9
+ }
10
+
11
+ export interface ContentAudioState {
12
+ playbackInstanceName: string,
13
+ muted: boolean,
14
+ playbackInstancePosition: any,
15
+ playbackInstanceDuration: any,
16
+ shouldPlay: boolean,
17
+ isPlaying: boolean,
18
+ isBuffering: boolean,
19
+ isLoading: boolean,
20
+ volume: number,
21
+ }
22
+
23
+ // create a component
24
+ class eaudio extends LibComponent<ContentAudioProps, ContentAudioState> {
25
+ playbackInstance: any
26
+ state: ContentAudioState;
27
+ props: ContentAudioProps;
28
+ constructor(props: ContentAudioProps) {
29
+ super(props)
30
+ this.props = props;
31
+ this.playbackInstance = null;
32
+ this.state = {
33
+ playbackInstanceName: "loading...",
34
+ muted: false,
35
+ playbackInstancePosition: null,
36
+ playbackInstanceDuration: null,
37
+ shouldPlay: false,
38
+ isPlaying: false,
39
+ isBuffering: false,
40
+ isLoading: true,
41
+ volume: 1.0,
42
+ };
43
+ this._onPlaybackStatusUpdate = this._onPlaybackStatusUpdate.bind(this)
44
+ this._loadNewPlaybackInstance = this._loadNewPlaybackInstance.bind(this)
45
+ this._onPlayPausePressed = this._onPlayPausePressed.bind(this)
46
+ }
47
+
48
+ componentDidMount(): void {
49
+ super.componentDidMount();
50
+ Audio.setAudioModeAsync({
51
+ allowsRecordingIOS: false,
52
+ interruptionModeIOS: Audio.INTERRUPTION_MODE_IOS_DO_NOT_MIX,
53
+ playsInSilentModeIOS: true,
54
+ shouldDuckAndroid: true,
55
+ staysActiveInBackground: false,
56
+ interruptionModeAndroid: Audio.INTERRUPTION_MODE_ANDROID_DUCK_OTHERS,
57
+ playThroughEarpieceAndroid: false
58
+ });
59
+ this._loadNewPlaybackInstance(false);
60
+ }
61
+
62
+ componentWillUnmount(): void {
63
+ super.componentWillUnmount();
64
+ (async () => {
65
+ if (this.playbackInstance != null) {
66
+ await this.playbackInstance.unloadAsync();
67
+ this.playbackInstance.setOnPlaybackStatusUpdate(null);
68
+ this.playbackInstance = null;
69
+ }
70
+ })()
71
+ }
72
+
73
+ async _loadNewPlaybackInstance(playing: boolean): Promise<void> {
74
+ if (this.playbackInstance != null) {
75
+ await this.playbackInstance.unloadAsync();
76
+ this.playbackInstance.setOnPlaybackStatusUpdate(null);
77
+ this.playbackInstance = null;
78
+ }
79
+
80
+ const source = { uri: "https://api.soundcloud.com/tracks/" + this.props.code + "/stream?client_id=4a584e57dbc1c522b0ccdb68464f6ec3" };
81
+ const initialStatus = {
82
+ shouldPlay: playing,
83
+ volume: this.state.volume,
84
+ isMuted: this.state.muted,
85
+ };
86
+ const { sound, status } = await Audio.Sound.createAsync(
87
+ source,
88
+ initialStatus,
89
+ this._onPlaybackStatusUpdate
90
+ );
91
+ this.playbackInstance = sound;
92
+ }
93
+
94
+ _onPlaybackStatusUpdate(status: any): void {
95
+ if (status.isLoaded) {
96
+ this.setState({
97
+ playbackInstancePosition: status.positionMillis,
98
+ playbackInstanceDuration: status.durationMillis,
99
+ shouldPlay: status.shouldPlay,
100
+ isPlaying: status.isPlaying,
101
+ isBuffering: status.isBuffering,
102
+ muted: status.isMuted,
103
+ volume: status.volume,
104
+ }, () => this.props.onStatusChange(this.state.isPlaying));
105
+ } else {
106
+ if (status.error) {
107
+ }
108
+ }
109
+ };
110
+
111
+ _onPlayPausePressed(): void {
112
+ if (this.playbackInstance != null) {
113
+ if (this.state.isPlaying) {
114
+ this.playbackInstance.pauseAsync()
115
+ } else {
116
+ this.playbackInstance.playAsync()
117
+ }
118
+ }
119
+ }
120
+
121
+ render(): any {
122
+ return null
123
+ }
124
+ }
125
+
126
+ export default eaudio;
@@ -1,5 +1,4 @@
1
- // noPage
2
- import { esp, LibCrypt, LibNet_status, LibObject, LibProgress, LibUtils, LogStateProperty } from 'esoftplay';
1
+ import { esp, LibCrypt, LibNet_status, LibObject, LibProgress, LibToastProperty, LibUtils, LogStateProperty } from 'esoftplay';
3
2
  import { reportApiError } from "esoftplay/error";
4
3
  import moment from "esoftplay/moment";
5
4
  import Constants from 'expo-constants';
@@ -191,15 +190,9 @@ export default class ecurl {
191
190
  onFailed(this.refineErrorMessage(msg), false)
192
191
  }, debug)
193
192
  }).catch((r: string) => {
194
- this.cancelTimeout();
195
- if (this.maxRetry > 0) {
196
- this.init(uri, post, onDone, onFailed, debug)
197
- this.maxRetry = this.maxRetry - 1
198
- } else {
199
- this.onFetched(r, onDone, onFailed, debug)
200
- }
193
+ this.cancelTimeout();
194
+ LibToastProperty.show("Koneksi internet anda tidak stabil, silahkan coba beberapa saat lagi")
201
195
  LibProgress.hide()
202
- this.onFetchFailed(r)
203
196
  })
204
197
  }
205
198
  }
@@ -323,10 +316,9 @@ export default class ecurl {
323
316
  }
324
317
  LibProgress.hide()
325
318
  }).catch((r: string) => {
326
- // this.cancelTimeout()
327
- this.onFetchFailed(r)
319
+ LibToastProperty.show("Koneksi internet anda tidak stabil, silahkan coba beberapa saat lagi")
328
320
  LibProgress.hide()
329
- this.onError(r)
321
+ // this.cancelTimeout()
330
322
  })
331
323
  }
332
324
  }
@@ -372,10 +364,10 @@ export default class ecurl {
372
364
  mode: "cors",
373
365
  _post: post
374
366
  }
375
- // if (debug == 1) {
376
- // console.log(this.url + this.uri, { ...options, cancelToken: undefined })
377
- // }
378
-
367
+ if (debug == 1) {
368
+ console.log(this.url + this.uri, { ...options, cancelToken: undefined })
369
+ }
370
+
379
371
  if (esp.isDebug('apitest') && manifest?.packagerOpts?.dev && LogStateProperty) {
380
372
  const allData = LogStateProperty.state().get() || []
381
373
  const logEnable = LogStateProperty.enableLog().get()
@@ -417,7 +409,8 @@ export default class ecurl {
417
409
  this.init(uri, post, onDone, onFailed, debug)
418
410
  this.maxRetry = this.maxRetry - 1
419
411
  } else {
420
- this.onFetched(e, onDone, onFailed, debug)
412
+ LibToastProperty.show("Koneksi internet anda tidak stabil, silahkan coba beberapa saat lagi")
413
+ LibProgress.hide()
421
414
  }
422
415
  })
423
416
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esoftplay",
3
- "version": "0.0.111-d",
3
+ "version": "0.0.111-g",
4
4
  "description": "embedding data from esoftplay framework (web based) into mobile app",
5
5
  "main": "cache/index.js",
6
6
  "types": "../../index.d.ts",