loadFromRemoteUrl static method

Audio? loadFromRemoteUrl(
  1. String url, {
  2. void onComplete()?,
  3. void onDuration(
    1. double duration
    )?,
  4. void onPosition(
    1. double position
    )?,
  5. void onError(
    1. String? message
    )?,
  6. bool looping = false,
  7. bool playInBackground = false,
})

Creates an Audio from a remote URL.

Returns null if url is invalid. Note that it returns an Audio sync'ly, though loading occurs async'ly. Note that onError will fire if remote loading fails (due to connectivity, invalid url, etc); this usually is fairly quick on iOS, but waits for a longer timeout on Android.

Implementation

static Audio? loadFromRemoteUrl(String url,
    {void onComplete()?,
    void onDuration(double duration)?,
    void onPosition(double position)?,
    void onError(String? message)?,
    bool looping = false,
    bool playInBackground = false}) {
  if (Uri.tryParse(url) == null) return null;
  final Audio audio = Audio._remoteUrl(url, onComplete, onDuration,
      onPosition, onError, looping, playInBackground)
    .._load();
  return audio;
}