Skip to content
This repository was archived by the owner on Oct 6, 2022. It is now read-only.

Android Seek bar synchronization with the audio #343

Closed
3 of 4 tasks
ajoykarmakar opened this issue Aug 29, 2020 · 2 comments
Closed
3 of 4 tasks

Android Seek bar synchronization with the audio #343

ajoykarmakar opened this issue Aug 29, 2020 · 2 comments

Comments

@ajoykarmakar
Copy link

ajoykarmakar commented Aug 29, 2020

Description

I am using this plugin since 1 year and it's working very beautifully. Now I am enabling seek bar features that works after android version 10+. Everything works as expected only one thing that doesn't work the seek bar is not synchronized with the audio but when I drag the seek bar audio position changing as expected.

Music control enable control -

MusicControl.enableControl('seek', true);
  MusicControl.enableControl('changePlaybackPosition', true);

  MusicControl.on('changePlaybackPosition', () => {
    console.log('hi');
  });

MusicControl.on('seek', (pos) => {
    this.seek(pos);
  });
  1. Platform ?

    • Android

    • iOS

  1. Device
  • Simulator
  • Real device

Any help will be appreciated. Thank you.

@bradfloodx
Copy link
Collaborator

HI @ajoykarmakar I'm not understanding your problem. Can you elaborate or provide more code?

@ajoykarmakar
Copy link
Author

ajoykarmakar commented Sep 10, 2020

Yes why not? When a android 10 user play a mp3 with this notification plugin a seekbar is available in the notification area to seek the position of the mp3 and it's working too but the marked area in the attached image's seekbar current position is never changing it's always show 0 that's means the seekbar is not syncing with the mp3 position.

image
Dummy image to explain the problem.

The total code snippet -

musicControlsSetup() {
   // const track = this.props.tracks[this.state.selectedTrack];
   MusicControl.setNowPlaying({
     title: TRACKS[0].title,
     artwork: require('../assets/imgs/album.jpg'), // URL or RN's image require()
     artist: TRACKS[0].artist,
     duration: this.state.totalLength, // (Seconds)
     description: '', // Android Only
     color: 0x000000, // Notification Color - Android Only
     date: '1983-01-02T00:00:00Z', // Release Date (RFC 3339) - Android Only
     rating: 84, // Android Only (Boolean or Number depending on the type)
     notificationIcon: 'media_play_icon', // Android Only (String), Android Drawable resource name for a custom notification icon
   });

   // Seeking
   MusicControl.enableControl('seek', true); // Android only

   // Basic Controls
   MusicControl.enableControl('play', true);
   MusicControl.enableControl('pause', true);
   MusicControl.enableControl('skipBackward', true, {interval: 15});
   MusicControl.enableControl('skipForward', true, {interval: 15});
   MusicControl.enableControl('closeNotification', true, {when: 'paused'});
   MusicControl.enableBackgroundMode(true);

   MusicControl.on('play', () => {
     this.setState({paused: false});
     MusicControl.updatePlayback({
       state: MusicControl.STATE_PLAYING, // (STATE_ERROR, STATE_STOPPED, STATE_PLAYING, STATE_PAUSED, STATE_BUFFERING)
     });
   });

   MusicControl.on('pause', () => {
     this.setState({paused: true});
     MusicControl.updatePlayback({
       state: MusicControl.STATE_PAUSED, // (STATE_ERROR, STATE_STOPPED, STATE_PLAYING, STATE_PAUSED, STATE_BUFFERING)
     });
   });

   MusicControl.on('skipForward', () => {
     this.seek(this.state.currentPosition + 15);
   });

   MusicControl.on('skipBackward', () => {
     this.seek(this.state.currentPosition - 15);
   });

   MusicControl.on('seek', (pos) => {
     this.seek(pos);
   });
 }

Now is it clear for you? And please don't close the issue because its still not resolved.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants