How to use the react-native-track-player.skipToPrevious 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
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': {
      dispatch(playbackState(data.state));
      break;
    }
    case 'playback-track-changed':
      break;
    case 'playback-error':
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
		case 'playback-track-changed':
			dispatch(playbackTrack(data.nextTrack))

			break
		case 'playback-queue-ended':
			// finish
github AbelTesfaye / dingo / src / BL / Services / event-handler-service.js View on Github external
}
		if (data.state == TrackPlayer.STATE_STOPPED) {
			console.log('STATE_STOPPED');
		}
		if (data.state == TrackPlayer.STATE_BUFFERING) {
			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 m-inan / react-native-music-app / src / scenes / Player / Controllers.js View on Github external
const onPressPrev = async () => {
		const time = await TrackPlayer.getPosition()

		if (time <= 3) {
			TrackPlayer.skipToPrevious()
		} else {
			TrackPlayer.seekTo(0)
		}
	}
github react-native-kit / react-native-track-player / example / service.js View on Github external
TrackPlayer.addEventListener('remote-previous', () => {
    TrackPlayer.skipToPrevious()
  });
github m-inan / react-native-music-app / src / provider / service.js View on Github external
TrackPlayer.addEventListener('remote-previous', async () => {
		const time = await TrackPlayer.getPosition()

		if (time <= 3) {
			TrackPlayer.skipToPrevious()
		} else {
			TrackPlayer.seekTo(0)
		}
	})
github ThalKod / react-native-music-player / src / screens / NowPlaying.js View on Github external
const skipToPrevious = async () => {
    try {
      await TrackPlayer.skipToPrevious();
    } catch (_) {}
  };
github react-native-kit / react-native-track-player / example / react / screens / PlaylistScreen.js View on Github external
async function skipToPrevious() {
  try {
    await TrackPlayer.skipToPrevious();
  } catch (_) {}
}