How to use the react-native-music-control.enableControl function in react-native-music-control

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

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github flarocca / react-native-music-player-service / __tests__ / src / MusicPlayerService.Tests.js View on Github external
it('MusicPlayerService | Created with enableSetNowPlaying true | MusicControl is set', () => {
  let musicPlayerService = new MusicPlayerService(true);

  expect.assertions(20);
  expect(MusicControl.enableBackgroundMode.mock.calls).toHaveLength(1);
  expect(MusicControl.enableBackgroundMode.mock.calls[0][0]).toEqual(true);

  expect(MusicControl.enableControl.mock.calls).toHaveLength(4);
  expect(MusicControl.enableControl.mock.calls[0][0]).toEqual('play');
  expect(MusicControl.enableControl.mock.calls[0][1]).toEqual(true);
  expect(MusicControl.enableControl.mock.calls[1][0]).toEqual('pause');
  expect(MusicControl.enableControl.mock.calls[1][1]).toEqual(true);
  expect(MusicControl.enableControl.mock.calls[2][0]).toEqual('nextTrack');
  expect(MusicControl.enableControl.mock.calls[2][1]).toEqual(true);
  expect(MusicControl.enableControl.mock.calls[3][0]).toEqual('previousTrack');
  expect(MusicControl.enableControl.mock.calls[3][1]).toEqual(true);

  expect(MusicControl.on.mock.calls).toHaveLength(4);
  expect(MusicControl.on.mock.calls[0][0]).toEqual('play');
  expect(MusicControl.on.mock.calls[0][1]).toEqual(musicPlayerService.togglePlayPause);
  expect(MusicControl.on.mock.calls[1][0]).toEqual('pause');
  expect(MusicControl.on.mock.calls[1][1]).toEqual(musicPlayerService.togglePlayPause);
  expect(MusicControl.on.mock.calls[2][0]).toEqual('nextTrack');
  expect(MusicControl.on.mock.calls[2][1]).toEqual(musicPlayerService.playNext);
  expect(MusicControl.on.mock.calls[3][0]).toEqual('previousTrack');
  expect(MusicControl.on.mock.calls[3][1]).toEqual(musicPlayerService.playPrev);
});
github sonnylazuardi / bibleify-mobile / old / src / screens / Passage / PassageScreen.js View on Github external
() => {
        MusicControl.enableControl("seekForward", false);
        MusicControl.enableControl("seekBackward", false);
        MusicControl.enableControl("skipForward", false);
        MusicControl.enableControl("skipBackward", false);
        MusicControl.enableBackgroundMode(true);

        const { streamChapter } = this.state;

        MusicControl.setNowPlaying({
          title: `${streamChapter && streamChapter.activeBook.name_id} ${streamChapter && streamChapter.activeChapter}`,
          artist: "Alkitab Suara",
          duration: this.state.streamDuration,
          color: 0xfffffff
        });

        MusicControl.on("play", () => {
          this.setState({ paused: false });
        });
        MusicControl.on("pause", () => {
github var77 / react-native-youtube-player / src / containers / MiniPlayer.js View on Github external
async componentDidMount() {
    await this.props.getSongs();
    MusicControl.enableControl('play', true);
    MusicControl.enableControl('pause', true);
    MusicControl.enableControl('nextTrack', true);
    MusicControl.enableControl('previousTrack', true);
    MusicControl.enableControl('seekForward', false);
    MusicControl.enableControl('seekBackward', false);
    MusicControl.enableBackgroundMode(true);
    MusicControl.on('play', ()=> {
      this.togglePlay(true);
    });
    MusicControl.on('pause', ()=> {
      this.togglePlay(false);
    });
    MusicControl.on('nextTrack', this.goForward.bind(this));
    MusicControl.on('previousTrack', this.goBackward.bind(this));
  }
github flarocca / react-native-music-player-service / src / MusicPlayerService.js View on Github external
_initializeMusicControl(): void {
    MusicControl.enableBackgroundMode(true);

    MusicControl.enableControl('play', true);
    MusicControl.enableControl('pause', true);
    MusicControl.enableControl('nextTrack', true);
    MusicControl.enableControl('previousTrack', true);

    MusicControl.on('play', this.togglePlayPause);
    MusicControl.on('pause', this.togglePlayPause);
    MusicControl.on('nextTrack', this.playNext);
    MusicControl.on('previousTrack', this.playPrev);
  }