How to use the react-native-music-control.setNowPlaying 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 / src / MusicPlayerService.js View on Github external
_setNowPlaying(track: Track): void {
    let config = { ...this.setNowPlayingConfig };
    let info = this._getInfo(track.additionalInfo);

    MusicControl.setNowPlaying({
      ...info,
      color: config.color, // Notification Color - Android Only
      notificationIcon: config.notificationIcon // Android Only (String), Android Drawable resource name for a custom notification icon
    });
  }
github flarocca / react-native-music-player-service / __tests__ / src / MusicPlayerService.Tests.js View on Github external
test('MusicPlayerService | _setNowPlaying with track with no additionalInfo | setNowPlaying is set with default values', () => {
  let setNowPlayingConfig = {
    color: 'some color',
    notificationIcon: 'notificationIcon'
  }
  let musicPlayerService = new MusicPlayerService(true, setNowPlayingConfig);
  let trackWithNoAdditionalInfo = new Track({ id: '1', path: 'some path' });

  expect.assertions(2);
  musicPlayerService._setNowPlaying(trackWithNoAdditionalInfo);

  expect(MusicControl.setNowPlaying).toHaveBeenCalledTimes(1);
  expect(MusicControl.setNowPlaying).toHaveBeenCalledWith({
    title: '',
    artwork: undefined,
    artist: '',
    album: '',
    genre: '',
    duration: 0,
    color: setNowPlayingConfig.color,
    notificationIcon: setNowPlayingConfig.notificationIcon
  });
});
github flarocca / react-native-music-player-service / __tests__ / src / MusicPlayerService.Tests.js View on Github external
beforeEach(() => {
  Sound.mockReset();
  Sound.prototype.play.mockClear();
  Sound.prototype.pause.mockClear();
  Sound.prototype.stop.mockClear();
  Sound.prototype.release.mockClear();

  MusicControl.on.mockClear();
  MusicControl.enableControl.mockClear();
  MusicControl.enableBackgroundMode.mockClear();
  MusicControl.setNowPlaying.mockClear();
  MusicControl.updatePlayback.mockClear();
});
github var77 / react-native-youtube-player / src / containers / MiniPlayer.js View on Github external
setPlayingSong(duration) {
    let song = this.props.songs[this.props.songIndex];
    MusicControl.setNowPlaying({
      title: song.title,
      artwork: song.thumb,
      artist: song.artist,
      duration
    });
  }
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", () => {
          this.setState({ paused: true });
        });
        MusicControl.on("nextTrack", () => {});
        MusicControl.on("previousTrack", () => {});

        MusicControl.updatePlayback({