How to use the react-native-track-player.pause 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 / src / PlayerControls.js View on Github external
_onPlayPause = async () => {
    const state = this.props.playerState;

    if (state === STATE_PLAYING) {
      await TrackPlayer.pause();
    } else if (state === STATE_PAUSED) {
      const position = Math.round(await TrackPlayer.getPosition());
      const duration = Math.round(await TrackPlayer.getDuration());
      if (position === duration) {
        // It's finished
        this._playNewTrack();
      } else {
        await TrackPlayer.play();
      }
    } else {
      this._playNewTrack();
    }
  };
github AbelTesfaye / dingo / src / BL / Services / event-handler-service.js View on Github external
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 moonou / siren / src / store / models / music.js View on Github external
async pause () {
    return TrackPlayer.pause()
  }
  @action
github Musicoin / app / components / Player.js View on Github external
async pauseTrack() {
    await 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 PierreBresson / Thinkerview / app / event-handler.js View on Github external
TrackPlayer.addEventListener("remote-pause", () => {
    TrackPlayer.pause();
  });
github ThalKod / react-native-music-player / src / screens / NowPlaying.js View on Github external
const togglePlayback = async () => {
    const currentTrack = await TrackPlayer.getCurrentTrack();
    if(currentTrack){
      if (playbackState === TrackPlayer.STATE_PAUSED) {
        await TrackPlayer.play();
      } else {
        await TrackPlayer.pause();
      }
    }
  };
github react-native-kit / react-native-track-player / example / service.js View on Github external
TrackPlayer.addEventListener('remote-pause', () => {
    TrackPlayer.pause()
  });