<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic TypeError: Cannot add negative msPlayed value in Spotify for Developers</title>
    <link>https://community.spotify.com/t5/Spotify-for-Developers/TypeError-Cannot-add-negative-msPlayed-value/m-p/5324142#M3892</link>
    <description>&lt;P&gt;Im bring to use the web api to play songs (one by one - not playlist)&lt;/P&gt;&lt;P&gt;and I get the following at the html.&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;[Error] TypeError: Cannot add negative msPlayed value: -9&lt;/DIV&gt;&lt;DIV&gt;(anonymous function) (index.js:18:264819)&lt;/DIV&gt;&lt;DIV&gt;(anonymous function) (index.js:18:259217)&lt;/DIV&gt;&lt;DIV&gt;(anonymous function) (index.js:18:219226)&lt;/DIV&gt;&lt;DIV&gt;(anonymous function)&lt;/DIV&gt;&lt;DIV&gt;[Error] Unhandled Promise Rejection: TypeError: Cannot add negative msPlayed value: -10&lt;/DIV&gt;&lt;DIV&gt;(anonymous function)&lt;/DIV&gt;&lt;DIV&gt;rejectPromise&lt;/DIV&gt;&lt;DIV&gt;promiseReactionJob&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;can you please help?&lt;/DIV&gt;</description>
    <pubDate>Thu, 06 Jan 2022 21:43:36 GMT</pubDate>
    <dc:creator>OBO1</dc:creator>
    <dc:date>2022-01-06T21:43:36Z</dc:date>
    <item>
      <title>TypeError: Cannot add negative msPlayed value</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/TypeError-Cannot-add-negative-msPlayed-value/m-p/5324142#M3892</link>
      <description>&lt;P&gt;Im bring to use the web api to play songs (one by one - not playlist)&lt;/P&gt;&lt;P&gt;and I get the following at the html.&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;[Error] TypeError: Cannot add negative msPlayed value: -9&lt;/DIV&gt;&lt;DIV&gt;(anonymous function) (index.js:18:264819)&lt;/DIV&gt;&lt;DIV&gt;(anonymous function) (index.js:18:259217)&lt;/DIV&gt;&lt;DIV&gt;(anonymous function) (index.js:18:219226)&lt;/DIV&gt;&lt;DIV&gt;(anonymous function)&lt;/DIV&gt;&lt;DIV&gt;[Error] Unhandled Promise Rejection: TypeError: Cannot add negative msPlayed value: -10&lt;/DIV&gt;&lt;DIV&gt;(anonymous function)&lt;/DIV&gt;&lt;DIV&gt;rejectPromise&lt;/DIV&gt;&lt;DIV&gt;promiseReactionJob&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;can you please help?&lt;/DIV&gt;</description>
      <pubDate>Thu, 06 Jan 2022 21:43:36 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/TypeError-Cannot-add-negative-msPlayed-value/m-p/5324142#M3892</guid>
      <dc:creator>OBO1</dc:creator>
      <dc:date>2022-01-06T21:43:36Z</dc:date>
    </item>
    <item>
      <title>Re: TypeError: Cannot add negative msPlayed value</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/TypeError-Cannot-add-negative-msPlayed-value/m-p/5324768#M3900</link>
      <description>Hey &lt;a href="https://community.spotify.com/t5/user/viewprofilepage/user-id/20000408"&gt;@OBO1&lt;/a&gt;, thanks for reporting this!&lt;BR /&gt;&lt;BR /&gt;Hmm, could you send over a bit of your code? What endpoint are you using? I'll try to do some digging.&lt;BR /&gt;&lt;BR /&gt;Thanks, keep me posted!&lt;BR /&gt;Hubo</description>
      <pubDate>Sat, 08 Jan 2022 13:30:30 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/TypeError-Cannot-add-negative-msPlayed-value/m-p/5324768#M3900</guid>
      <dc:creator>Hubo</dc:creator>
      <dc:date>2022-01-08T13:30:30Z</dc:date>
    </item>
    <item>
      <title>Re: TypeError: Cannot add negative msPlayed value</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/TypeError-Cannot-add-negative-msPlayed-value/m-p/5324850#M3904</link>
      <description>&lt;P&gt;Hi @Hubo,&lt;BR /&gt;Thanks for your response !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First of all ill mention that this only occurs on Safari.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I use the Web API to play tracks by their ids.&lt;/P&gt;&lt;P&gt;I'm using a code that is based on the docs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var accessToken //Being updated every 45 minuts with a refresh_token request&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;window.onSpotifyWebPlaybackSDKReady = () =&amp;gt; { ...
 player = new Spotify.Player({
                    name: 'Votify',
                    getOAuthToken: cb =&amp;gt; { cb(accessToken); }
                });
 listeners ... 
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Function loadTrack(currentTrack) {
   //Fetches the track from the database...
   if (player) {
       playOnSpotify({
          spotify_uri: currentTrack.uri,
          playerInstance: player
       });
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;and the playOnSpotify is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt; const playOnSpotify = ({
                spotify_uri,
                playerInstance: {
                    _options: {
                        getOAuthToken,
                        device_Id
                    }
                }
            }) =&amp;gt; { 
                console.log('playOnSpot ==&amp;gt;' + spotify_uri + ', deviceId =&amp;gt;&amp;gt;&amp;gt; ' + deviceId)

                getOAuthToken(access_token =&amp;gt; {
                    console.log('getOAuthToken ==&amp;gt;' + access_token)

                    fetch(`https://api.spotify.com/v1/me/player/play?device_id=${deviceId}`, {
                        method: 'PUT',
                        body: JSON.stringify({ uris: [spotify_uri] }),
                        headers: {
                            'Content-Type': 'application/json',
                            'Authorization': `Bearer ${access_token}`
                        },
                    })
                });
            };&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 08 Jan 2022 18:38:13 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/TypeError-Cannot-add-negative-msPlayed-value/m-p/5324850#M3904</guid>
      <dc:creator>OBO1</dc:creator>
      <dc:date>2022-01-08T18:38:13Z</dc:date>
    </item>
    <item>
      <title>Re: TypeError: Cannot add negative msPlayed value</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/TypeError-Cannot-add-negative-msPlayed-value/m-p/5328158#M3937</link>
      <description>&lt;P&gt;I see this on Mac / Safari too. I almost never see it on Chrome. Steps to reproduce fairly reliably here:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- in Safari desktop or mobile initialize the web playback SDK and start a song per the docs&lt;/P&gt;&lt;P&gt;- See player_state_changed events as expected&lt;/P&gt;&lt;P&gt;- on Spotify Desktop see that a song is playing in the web playback device and advance the song position towards the end of the track&lt;/P&gt;&lt;P&gt;- Get `Unhandled Promise Rejection: TypeError: Cannot add negative msPlayed value: -5`&lt;/P&gt;&lt;P&gt;- Don't see any more&amp;nbsp;player_state_changed events as expected&lt;/P&gt;&lt;P&gt;- Playing a new track through the web SDK also gives the&amp;nbsp;TypeError&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jan 2022 02:24:53 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/TypeError-Cannot-add-negative-msPlayed-value/m-p/5328158#M3937</guid>
      <dc:creator>nzoschke1</dc:creator>
      <dc:date>2022-01-17T02:24:53Z</dc:date>
    </item>
    <item>
      <title>Re: TypeError: Cannot add negative msPlayed value</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/TypeError-Cannot-add-negative-msPlayed-value/m-p/5328162#M3938</link>
      <description>&lt;P&gt;To clarify, you don't have to advance the track position in Spotify Desktop, it's just that the error happens at the end of a track so this is a faster way to trigger it.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jan 2022 02:31:04 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/TypeError-Cannot-add-negative-msPlayed-value/m-p/5328162#M3938</guid>
      <dc:creator>nzoschke1</dc:creator>
      <dc:date>2022-01-17T02:31:04Z</dc:date>
    </item>
    <item>
      <title>Betreff: TypeError: Cannot add negative msPlayed value</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/TypeError-Cannot-add-negative-msPlayed-value/m-p/5329844#M3951</link>
      <description>&lt;P&gt;I can reproduce the same error here on Mac/Safari 15.2 and iOS 15.1/Safari (Chrome works flawlessly). I built a simple album player, and when the tracks position reaches its end, the unhandled promise rejection pops up (not always, but most of the time). The source of this error is to be found in the file &lt;A href="https://sdk.scdn.co/embedded/index.js" target="_blank"&gt;https://sdk.scdn.co/embedded/index.js&lt;/A&gt;&amp;nbsp;on line 9819/9820. Maybe the solution for the Spotify developers would be as&amp;nbsp;simple&amp;nbsp;as changing line 9820 to e = 0; ?&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":thinking_face:"&gt;🤔&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jan 2022 21:23:52 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/TypeError-Cannot-add-negative-msPlayed-value/m-p/5329844#M3951</guid>
      <dc:creator>robertweiss_dus</dc:creator>
      <dc:date>2022-01-19T21:23:52Z</dc:date>
    </item>
    <item>
      <title>Re: TypeError: Cannot add negative msPlayed value</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/TypeError-Cannot-add-negative-msPlayed-value/m-p/5337068#M4012</link>
      <description>&lt;P&gt;I see this on Mac 12.0.1 / Firefox Dev Edition 96.0b10 (64-bit) too.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Seems to occur about 1 of 5 times that I call the `seek` method of the player.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Feb 2022 01:09:26 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/TypeError-Cannot-add-negative-msPlayed-value/m-p/5337068#M4012</guid>
      <dc:creator>gtarking11</dc:creator>
      <dc:date>2022-02-02T01:09:26Z</dc:date>
    </item>
    <item>
      <title>Re: TypeError: Cannot add negative msPlayed value</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/TypeError-Cannot-add-negative-msPlayed-value/m-p/5348973#M4149</link>
      <description>&lt;P&gt;I am also seeing this error on iOS &amp;amp; MacOS Safari when the current track finishes and you send a request to play the next track. I am playing tracks individually rather than from a playlist.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a solution to this?&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2022 13:34:06 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/TypeError-Cannot-add-negative-msPlayed-value/m-p/5348973#M4149</guid>
      <dc:creator>edwardhorsey</dc:creator>
      <dc:date>2022-03-01T13:34:06Z</dc:date>
    </item>
    <item>
      <title>Re: TypeError: Cannot add negative msPlayed value</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/TypeError-Cannot-add-negative-msPlayed-value/m-p/5355047#M4208</link>
      <description>&lt;P&gt;I'm also seeing this issue on the latest macOS with Safari.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2022 21:50:39 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/TypeError-Cannot-add-negative-msPlayed-value/m-p/5355047#M4208</guid>
      <dc:creator>jfost784</dc:creator>
      <dc:date>2022-03-15T21:50:39Z</dc:date>
    </item>
  </channel>
</rss>

