/*
 * Copyright (C) 2013, 2014 Apple Inc. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 */

enum DeviceType {
    "none",
    "airplay",
    "tvout"
};

[
    Conditional=MEDIA_CONTROLS_SCRIPT,
    ImplementationLacksVTable,
    NoInterfaceObject,
] interface MediaControlsHost {
    sequence<TextTrack> sortedTrackListForMenu(TextTrackList trackList);
    sequence<AudioTrack> sortedTrackListForMenu(AudioTrackList trackList);
    DOMString displayNameForTrack((TextTrack or AudioTrack)? track);
    readonly attribute TextTrack captionMenuOffItem;
    readonly attribute TextTrack captionMenuAutomaticItem;
    readonly attribute DOMString captionDisplayMode;
    void setSelectedTextTrack(TextTrack? track);
    readonly attribute HTMLElement textTrackContainer;
    readonly attribute boolean allowsInlineMediaPlayback;
    readonly attribute boolean supportsFullscreen;
    readonly attribute boolean isVideoLayerInline;
    readonly attribute boolean userGestureRequired;
    readonly attribute boolean isInMediaDocument;
    readonly attribute boolean shouldForceControlsDisplay;
    readonly attribute boolean compactMode;

    readonly attribute DOMString externalDeviceDisplayName;
    readonly attribute DeviceType externalDeviceType;

    attribute boolean controlsDependOnPageScaleFactor;
    
    void updateTextTrackContainer();
    void enteredFullscreen();
    void exitedFullscreen();

    DOMString generateUUID();

    [EnabledAtRuntime=ModernMediaControls] readonly attribute DOMString shadowRootCSSText;
    [EnabledAtRuntime=ModernMediaControls] DOMString base64StringForIconNameAndType(DOMString iconName, DOMString iconType);
    [EnabledAtRuntime=ModernMediaControls] DOMString formattedStringForDuration(unrestricted double durationInSeconds);
};
