Future<Video> clone()

Clone this video instance and the underlying HTML VideoElement to play the new video independantly from this video.

Source

Future <Video> clone() {

  var videoElement = this.videoElement.clone(true) as VideoElement;
  Completer<Video> completer = new Completer<Video>();
  StreamSubscription onCanPlaySubscription;
  StreamSubscription onErrorSubscription;

  void onCanPlay(html.Event e) {
    var video = new Video._(videoElement);
    video.volume = this.volume;
    video.muted = this.muted;
    onCanPlaySubscription.cancel();
    onErrorSubscription.cancel();
    completer.complete(video);
  }

  void onError(html.Event e) {
    onCanPlaySubscription.cancel();
    onErrorSubscription.cancel();
    var error = videoElement.error;
    var loadError = new LoadError("Failed to clone video.", error);
    completer.completeError(loadError);
  }

  onCanPlaySubscription = videoElement.onCanPlay.listen(onCanPlay);
  onErrorSubscription = videoElement.onError.listen(onError);
  return completer.future;
}