react-native-music-control icon indicating copy to clipboard operation
react-native-music-control copied to clipboard

Android Seek bar starting position is not not working on notification area

Open ajoykarmakar opened this issue 4 years ago • 1 comments

Issue

I am using this plugin since 1 year and it's working very beautifully. Now 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.

I have attached a other application working demo Image to explain the problem -

image

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);
   });
 }
  1. Platform

    • [ ] iOS
    • [x] Android
  1. Device
  • [x] Simulator
  • [x] Real device

ajoykarmakar avatar Oct 10 '20 19:10 ajoykarmakar

try to update elapsedTime also in component progress https://github.com/tanguyantoine/react-native-music-control#update-playback

krunalbad avatar Dec 20 '20 17:12 krunalbad