Documentation

GraphQL API: Playback

Send elapsed time progress on a track

Some clients will remember progress of a song last played for a device. This is done by sending progress events as a track is playing.

The interval at which you send the progress update is determined by the progressFrequency property of the current source.  This will return an integer value or null.

Let's use the example of setting a new source for playback.  You would set the source using this mutation:



mutation {
  playback {
    setSource (deviceUuid: "deviceXYZ", sourceId: "PE:487611") {
      id
      type
      current {
        ... on PodcastEpisodeItem {
          podcastEpisode {
            name
            duration
            releaseDate
            podcast {
              name
              summary
              totalEpisodeCount
            }
          }
          index
          progressFrequency
        }
      }
    }
  }
}

* Add your OAuth bearer token to the Authorization header



curl 'https://ce.pandora.com/api/v1/graphql/graphql' \
  -H 'Authorization: Bearer ' \
  -H 'Content-Type: application/json' \
  -d '{"operationName":null,"variables":{},"query":"mutation {  playback { setSource(deviceUuid: \"deviceXYZ\", sourceId: \"PE:487611\") { id type current { ... on PodcastEpisodeItem { podcastEpisode { name duration releaseDate podcast { name summary totalEpisodeCount } } index progressFrequency } } }  }}"}'

Your response would look like this:



{
  "data": {
    "playback": {
      "setSource": {
        "id": "PC:4",
        "type": "PC",
        "current": {
          "podcastEpisode": {
            "name": "667: Wartime Radio",
            "duration": 3893,
            "releaseDate": "2019-02-03T23:00:00.000Z",
            "podcast": {
              "name": "This American Life",
              "summary": "This American Life is a weekly public radio show, heard by 2.2 million people on more than 500 stations. Another 2.5 million people download the weekly podcast.",
              "totalEpisodeCount": 168
            }
          },
          "index": 0,
          "progressFrequency": 60
        }
      }
    }
  }
}

The progressFrequency value can now be used to send progress on the track.  In this case you would send progress every 60 seconds.

If a value of null is received, you can decide how often you want to send progress.  The recommended frequency is 60 seconds, but progress calls can be omitted if limited resources are available to the application.  This is an example of a null frequency:



{
  "data": {
    "playback": {
      "setSource": {
        "id": "AL:1811731",
        "type": "AL",
        "current": {
          "track": {
            "name": "I Still Do"
          },
          "index": 0,
          "progressFrequency": null
        }
      }
    }
  }
}

The progress mutation is shown below:



mutation {
  playback {
    setProgress(deviceUuid: "deviceXYZ", sourceId: "AL:1811731", index: 0, elapsedTime: 200) {
      status
      current {
        ... on TrackItem {
          track {
            name
          }
        }
      }
    }
  }
}

* Add your OAuth bearer token to the Authorization header



curl 'https://ce.pandora.com/api/v1/graphql/graphql' \
  -H 'Authorization: Bearer ' \
  -H 'Content-Type: application/json' \
  -d '{"operationName":null,"variables":{},"query":"mutation {  playback { setProgress(deviceUuid: \"deviceXYZ\", sourceId: \"AL:1811731\", index: 0, elapsedTime: 200) { status current { ... on TrackItem { track { name } } } }  }}"}'

Response



{
  "data": {
    "playback": {
      "setProgress": {
        "status": "OK",
        "current": {
          "track": {
            "name": "I Still Do"
          }
        }
      }
    }
  }
}