'Scenario: Video component is rendered in the LMS in Youtube mode without HTML5 sources
Given the course has a Video component in "Youtube" mode
And I play the video
And I watch 5 seconds of it
And I pause the video
Then a "load_video" event is emitted
And a "play_video" event is emitted
And a "pause_video" event is emitted'

def test_video_control_events(self):

    def is_video_event(event):
        'Filter    out    anything    other    than    the    video    events    of    interest'
        return (event['event_type'] in ('load_video', 'play_video', 'pause_video'))
    captured_events = []
    with self.capture_events(is_video_event, number_of_matches=3, captured_events=captured_events):
        self.navigate_to_video()
        self.video.click_player_button('play')
        self.video.wait_for_position('0:05')
        self.video.click_player_button('pause')
    for (idx, video_event) in enumerate(captured_events):
        self.assert_payload_contains_ids(video_event)
        if (idx == 0):
            assert_event_matches({'event_type': 'load_video'}, video_event)
        elif (idx == 1):
            assert_event_matches({'event_type': 'play_video'}, video_event)
            self.assert_valid_control_event_at_time(video_event, 0)
        elif (idx == 2):
            assert_event_matches({'event_type': 'pause_video'}, video_event)
            self.assert_valid_control_event_at_time(video_event, self.video.seconds)
