blob: 981b9c2a3f38b74f0c7a9dc431a68c6b3cc07b12 [file] [log] [blame]
# Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from import method_logger
class VideoScreenShotCollector(object):
Captures and collects screenshots of a video at specified time points.
def __init__(self, player, screenshot_namer, screenshot_capturer):
self.player = player
self.screnshot_namer = screenshot_namer
self.screnshot_capturer = screenshot_capturer
def collect_screenshot(self, timestamp):
Get a screenshot of video at a particular time.
Navigates player to a given time value, captures and saves a
screenshot at that time value.
@param timestamp: time_delta, the time value to capture screenshot for.
@returns a complete path to the screenshot captured.
filename = self.screnshot_namer.get_filename(timestamp)
return self.screnshot_capturer.capture(filename)
def ensure_player_is_ready(self):
Loads video and waits for player to be ready.
@raises whatever load_video() raises.
def collect_multiple_screenshots(self, timestamps):
Collects screenshots for each timevalue in a list.
@param timestamps: time_delta list, time values to collect
screenshots for.
@returns a list of complete paths for screenshot captured.
with self.screnshot_capturer:
return [self.collect_screenshot(t) for t in timestamps]