How to use the react-native-track-player.stop function in react-native-track-player

To help you get started, we’ve selected a few react-native-track-player examples, based on popular ways it is used in public projects.

github ferrannp / react-native-spotify-streamer / player-handler.js View on Github external
async function playerHandler(dispatch: DispatchType, data: Data) {
  switch (data.type) {
    // Forward remote events to the player
    case 'remote-play':
      TrackPlayer.play();
      break;
    case 'remote-pause':
      TrackPlayer.pause();
      break;
    case 'remote-stop':
      TrackPlayer.stop();
      break;
    case 'remote-next':
      TrackPlayer.skipToNext();
      break;
    case 'remote-previous':
      TrackPlayer.skipToPrevious();
      break;
    case 'remote-seek':
      TrackPlayer.seekTo(data.position);
      break;
    // You can make ducking smoother by adding a fade in/out
    case 'remote-duck':
      TrackPlayer.setVolume(data.ducking ? 0.5 : 1);
      break;
    // Playback updates
    case 'playback-state': {
github moonou / siren / src / store / models / music.js View on Github external
async removeTrack(id) {
    if (!id) {
      return
    }
    if (id === this.trackId) {
      await TrackPlayer.stop()
    }
    // WIP[remove will auto play on iOS]
    if (Platform.OS === 'android') {
      await TrackPlayer.remove(id)
    }
    this.list = this.list.filter((item) => item.id !== id)
  }
  @action
github Musicoin / app / components / Player.js View on Github external
onPlaybackError(data) {
    console.log(data);
    console.log(this.props.currentTrack.trackUrl);
    console.log(this.state.retries);
    if (this.state.retries < 3) {
      this.playNextTrack(true);
    }else{
      TrackPlayer.stop();
    }
    this.setState({retries: this.state.retries + 1});
    this.showAlert('', 'Hmm, we couldn’t play this track. Please try again in a moment.');
  }
github AbelTesfaye / dingo / src / BL / Services / event-handler-service.js View on Github external
console.log('STATE_BUFFERING');
			_fetchURLs(false, 1, 1, () => {}, () => {});
		}
	} else if (data.type == 'remote-play') {
		TrackPlayer.play();
	} else if (data.type == 'remote-pause') {
		TrackPlayer.pause();
	} else if (data.type == 'remote-next') {
		TrackPlayer.skipToNext();
	} else if (data.type == 'remote-previous') {
		TrackPlayer.skipToPrevious();
	} else if (data.type == 'remote-seek') {
		TrackPlayer.seekTo(data.position);
	} else if (data.type == 'remote-duck') {
		if (data.paused) TrackPlayer.pause();
		if (data.permanent) TrackPlayer.stop();
		if (data.ducking) {
			const prevVolume = await TrackPlayer.getVolume();
			TrackPlayer.setVolume(0.1);

			BackgroundTimer.setTimeout(() => {
				TrackPlayer.setVolume(prevVolume);
			}, 3 * 1000);
		}
	}
};
github PierreBresson / Thinkerview / app / event-handler.js View on Github external
TrackPlayer.addEventListener("remote-stop", () => {
    TrackPlayer.stop();
  });
github d2rivendell / react-native-GCore / app / components / other / timeLine / TimeLine.js View on Github external
return async (data) => {
                        if (data.type == 'playback-state') {

                        } else if (data.type == 'remote-play') {
                            this.audioPlayer.playAudio()
                        } else if (data.type == 'remote-stop') {
                            TrackPlayer.stop();
                        } else if (data.type == 'remote-pause') {
                            this.audioPlayer.pause()
                            TrackPlayer.pause();
                        }
                    };
                });
github d2rivendell / react-native-GCore / player-handler.js View on Github external
module.exports = async (data) =>{
    if(data.type == 'playback-state') {
    }else if(data.type == 'remote-play') {
        TrackPlayer.play();
    } else if(data.type == 'remote-seek') {
        TrackPlayer.seekTo(data.position);
    }else if (data.type == 'remote-stop') {
        TrackPlayer.stop();
    }else if (data.type == 'remote-pause') {
        TrackPlayer.pause();
    }

};
github m-inan / react-native-music-app / src / reducers / Player / handler.js View on Github external
async function Handler(dispatch, data) {
	switch (data.type) {
		case 'remote-play':
			TrackPlayer.play()
			break
		case 'remote-pause':
			TrackPlayer.pause()
			break
		case 'remote-stop':
			TrackPlayer.stop()
			break
		case 'remote-next':
			TrackPlayer.skipToNext()
			break
		case 'remote-previous':
			TrackPlayer.skipToPrevious()
			break
		case 'remote-seek':
			TrackPlayer.seekTo(data.position)
			break
		case 'remote-duck':
			TrackPlayer.setVolume(data.ducking ? 0.5 : 1)
			break
		case 'playback-state':
			dispatch(playbackState(data.state))
			break