1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
6 #include "core/html/track/VideoTrackList.h"
8 #include "core/html/HTMLMediaElement.h"
9 #include "core/html/track/VideoTrack.h"
13 PassRefPtrWillBeRawPtr<VideoTrackList> VideoTrackList::create(HTMLMediaElement& mediaElement)
15 return adoptRefWillBeRefCountedGarbageCollected(new VideoTrackList(mediaElement));
18 VideoTrackList::~VideoTrackList()
22 VideoTrackList::VideoTrackList(HTMLMediaElement& mediaElement)
23 : TrackListBase<VideoTrack>(&mediaElement)
25 ScriptWrappable::init(this);
28 const AtomicString& VideoTrackList::interfaceName() const
30 return EventTargetNames::VideoTrackList;
33 int VideoTrackList::selectedIndex() const
35 for (unsigned i = 0; i < length(); ++i) {
36 VideoTrack* track = anonymousIndexedGetter(i);
38 if (track->selected())
45 void VideoTrackList::trackSelected(blink::WebMediaPlayer::TrackId selectedTrackId)
47 // Clear the selected flag on the previously selected track, if any.
48 for (unsigned i = 0; i < length(); ++i) {
49 VideoTrack* track = anonymousIndexedGetter(i);
51 if (track->trackId() != selectedTrackId)
52 track->clearSelected();
54 ASSERT(track->selected());
57 scheduleChangeEvent();