@@ -24,6 +24,7 @@ const convertState = (state) => {
2424}
2525
2626const initPlayer = async ( songDispatch ) => {
27+ global . songDispatch = songDispatch
2728 const song = await AsyncStorage . getItem ( 'song' )
2829 . then ( ( song ) => song ? JSON . parse ( song ) : null )
2930 try {
@@ -202,7 +203,7 @@ const tuktuktuk = async (songDispatch) => {
202203 const urlTuk = 'https://sawyerf.github.io/tuktuktuk.mp3'
203204 const playingState = await TrackPlayer . getPlaybackState ( )
204205
205- if ( [ State . Paused , State . Ended , State . Stopped , State . None ] . indexOf ( playingState . state ) > - 1 ) {
206+ if ( [ State . Paused , State . Ended , State . Stopped , State . None , State . Error ] . indexOf ( playingState . state ) > - 1 ) {
206207 const queue = [ {
207208 id : 'tuktuktuk' ,
208209 albumId : 'tuktuktuk' ,
@@ -211,19 +212,10 @@ const tuktuktuk = async (songDispatch) => {
211212 album : 'Tuk Tuk Tuk' ,
212213 artist : 'Sawyerf' ,
213214 artwork : require ( '~/../assets/icon.png' )
214- } ,
215- {
216- id : 'tuktuktukend' ,
217- albumId : 'tuktuktuk' ,
218- url : urlTuk ,
219- title : 'Tuk Tuk Tuk' ,
220- artist : 'Sawyerf' ,
221- artwork : require ( '~/../assets/foreground-icon.png' )
222215 } ]
223- await TrackPlayer . setQueue ( queue )
224- await TrackPlayer . play ( )
225216 songDispatch ( { type : 'setQueue' , queue, index : 0 } )
226217 songDispatch ( { type : 'setActionEndOfSong' , action : 'next' } )
218+ await loadSong ( global . config , queue , 0 )
227219 }
228220}
229221
@@ -255,6 +247,7 @@ const connect = async (_device) => {
255247}
256248
257249const disconnect = async ( _device ) => {
250+ await stopSong ( )
258251 isConnected = false
259252}
260253
0 commit comments