loopPlaylist method

dynamic loopPlaylist(
  1. dynamic times
)

loop @param times {int|String} ->/ number n - loop n times
'inf' - loop infinitely often
'no' - switch loop to off

if times is not set, this method will toggle the loop state, if any looping is set, either 'inf' or a fixed number it will be switched off

Implementation

loopPlaylist(times) async {
  // if times was set, use it. Times can be any number > 0, 'inf' and 'no'
  if (times != null) {
    return setProperty('loop-playlist', times);
  }
  // if times was not set, net loop toggle the mute property
  else {
    // get the loop status
    // if any loop status was set, either 'inf' or a fixed number, switch loop to off
    // if no loop status was set, switch it on to 'inf'
    var loopStatus = await getProperty('loop-playlist');
    return setProperty('loop-playlist', loopStatus != null ? 'inf' : 'no');
  }
}