class Playwright::Video

def delete

def delete
  wait_for_artifact_and do |artifact|
    artifact.delete
  end
end

def initialize(page)

def initialize(page)
  @page = page
  @artifact = Concurrent::Promises.resolvable_future
  if @page.closed?
    on_page_closed
  else
    page.once('close', -> { on_page_closed })
  end
end

def on_page_closed

def on_page_closed
 @artifact.resolved?
ifact.reject('Page closed')

def path

def path
  if @page.send(:remote_connection?)
    raise 'Path is not available when using browserType.connect(). Use save_as() to save a local copy.'
  end
  wait_for_artifact_and do |artifact|
    artifact.absolute_path
  end
end

def save_as(path)

def save_as(path)
  wait_for_artifact_and do |artifact|
    artifact.save_as(path)
  end
end

def set_artifact(artifact)

called only from Page#on_video via send(:set_artifact, artifact)
def set_artifact(artifact)
act.fulfill(artifact)

def wait_for_artifact_and(&block)

def wait_for_artifact_and(&block)
ct = @artifact.value!
 artifact
e 'Page did not produce any video frames'
call(artifact)