startWithTracks method

Future<PlaybackState?> startWithTracks(
  1. List<String> trackUris, {
  2. String? deviceId,
  3. int positionMs = 0,
  4. bool retrievePlaybackState = true,
})

Start a new playback context with given trackUris and with given optional deviceId. If not provided, the user's currently active device is the target. Playback can also start at positionMs, which is set to 0 by default. retrievePlaybackState is optional. If true, the current PlaybackState will be retrieved. Default's to true.

Note: Before starting a new playback context check the playbackState if necessary before resumeing, otherwise you overwrite the current context.

Implementation

Future<PlaybackState?> startWithTracks(List<String> trackUris,
    {String? deviceId,
    int positionMs = 0,
    bool retrievePlaybackState = true}) async {
  assert(trackUris.isNotEmpty, 'Cannot start playback with empty track uris');
  assert(positionMs >= 0, 'Position must be greater than or equal to 0');

  var options = StartWithUrisOptions(uris: trackUris, positionMs: positionMs);
  return startOrResume(
      deviceId: deviceId,
      options: options,
      retrievePlaybackState: retrievePlaybackState);
}