Announcements

Help Wizard

Step 1

NEXT STEP

Web Playback SDK Skipping to Next Track and Seeking

Web Playback SDK Skipping to Next Track and Seeking

Plan

Premium

 

Device

IPhone 12

Operating System

iOS 18

 

My Question or Issue

I'm trying to have my Player skip to the next track and seek to the 20 second mark, but the audio keeps playing at the beginning of the song and then seek to the 20 second mark and creating this weird skipping effect. The implementation I have works fine on desktop browser but whenever I test it on an iOS browser I get the skipping issue. The player seems to be ignoring some of the calls or not finishing in time before it continues execution. Here is the code I'm working with: 

    await player.setVolume(0.0).then(() => {
      player.nextTrack();
    });

    const newPosition = tracksPosition + 1;
    setTracksPosition(newPosition);
    setAlbumArt(tracks[newPosition].album.images[1].url);

    setTimeout(async () => {
      if (tracks[newPosition].duration_ms > startTime + millisecondsPlayed) {
        await player.pause().then(() => {
          player.seek(startTime);
        });
      }

      setPaused(false);
    }, 1200);
    setTimeout(async () => {
      await player.setVolume(0.5).then(() => {
        player.resume();
      });
    }, 1700); // Needs at least 1.5 seconds to work on desktop browsers

 

 

Reply
0 Replies

Suggested posts

Let's introduce ourselves!

Hey there you,   Yeah, you! 😁   Welcome - we're glad you joined the Spotify Community!   While you here, let's have a fun game and get…

ModeratorStaff / Moderator/ 4 years ago  in Social & Random