//+-------------------------------------------------------------------------
//
//  Microsoft Windows
//  Copyright (c) Microsoft Corporation. All rights reserved.
//
//--------------------------------------------------------------------------
    
import "ocidl.idl";
import "docobj.idl";

#include <olectl.h>

#include "brdispid.h"

//----------------------------------------------------------------------
//+++++     MediaBar binary behavior interfaces:
//----------------------------------------------------------------------

interface IMediaBehavior;
interface IMediaItem;
interface IPlaylistInfo;


// NOTE the mediabar behavior exposes a subset of WMP7 object model
// where appropriate, object, property, method and event
// identifiers are slightly renamed to avoid name collisions
typedef
[
    helpstring( "State of opening process" ),
    public
]
enum mbOpenState // wmpos
{
    [ helpstring( "Undefined" ) ]                                   mbosUndefined,
    [ helpstring( "New Playlist is about to be loaded" ) ]          mbosPlaylistChanging,
    [ helpstring( "Locating the playlist" ) ]                       mbosPlaylistLocating,
    [ helpstring( "Connecting to the server holding a playlist" ) ] mbosPlaylistConnecting,
    [ helpstring( "Loading a playlist" ) ]                          mbosPlaylistLoading,
    [ helpstring( "Opening a playlist" ) ]                          mbosPlaylistOpening,
    [ helpstring( "Playlist is open" ) ]                            mbosPlaylistOpenNoMedia,
    [ helpstring( "Playlist has changed" ) ]                        mbosPlaylistChanged,
    [ helpstring( "New media is about to be loaded" ) ]             mbosMediaChanging,
    [ helpstring( "Locating the media" ) ]                          mbosMediaLocating,
    [ helpstring( "Connecting to the server holding media" ) ]      mbosMediaConnecting,
    [ helpstring( "Loading media" ) ]                               mbosMediaLoading,
    [ helpstring( "Opening a media" ) ]                             mbosMediaOpening,
    [ helpstring( "Media is open" ) ]                               mbosMediaOpen,
    [ helpstring( "Starting codec acquisition" ) ]                  mbosBeginCodecAcquisition,
    [ helpstring( "End codec acquisition" ) ]                       mbosEndCodecAcquisition,
    [ helpstring( "Starting license acquisition" ) ]                mbosBeginLicenseAcquisition,
    [ helpstring( "End license acquisition" ) ]                     mbosEndLicenseAcquisition,
    [ helpstring( "Starting individualization" ) ]                  mbosBeginIndividualization,
    [ helpstring( "End individualization" ) ]                       mbosEndIndividualization,
    [ helpstring( "Waiting for media" ) ]                           mbosMediaWaiting,    
    [ helpstring( "Opening an URL whose type is not known" ) ]      mbosOpeningUnknownURL,    
} mbOpenState;

typedef
[
    helpstring( "State of playback" ),
    public
]
enum mbPlayState
{
    [ helpstring( "State is undefined" ) ]                      mbpsUndefined,
    [ helpstring( "Playback is stopped" ) ]                     mbpsStopped,
    [ helpstring( "Playback is paused" ) ]                      mbpsPaused,
    [ helpstring( "Stream is playing" ) ]                       mbpsPlaying,
    [ helpstring( "Stream is Scanning forward" ) ]              mbpsScanForward,
    [ helpstring( "Stream is Scanning in reverse" ) ]           mbpsScanReverse,
    [ helpstring( "Media is being buffered" ) ]                 mbpsBuffering,
    [ helpstring( "Waiting for streaming data" ) ]              mbpsWaiting,
    [ helpstring( "End of media reached" ) ]                    mbpsMediaEnded,
    [ helpstring( "Preparing new media" ) ]                     mbpsTransitioning,
    [ helpstring( "Ready to begin playing" ) ]                  mbpsReady,
} mbPlayState;


[
	uuid(BB24BBE0-1EEC-422b-A397-EDBC31FB3A56),
	helpstring("IMediaBehavior Interface"),
    dual,
	pointer_default(unique)
]
interface IMediaBehavior : IDispatch
{
    [id (DISPID_MBBEHAVIOR_PLAYURL), helpstring( "load media from URL and start playing" ) ]
        HRESULT playURL(BSTR bstrURL, BSTR bstrMIME);
    [id (DISPID_MBBEHAVIOR_STOP), helpstring( "Stops playing current media" ) ]
        HRESULT stop();
    [id (DISPID_MBBEHAVIOR_PLAYNEXT), helpstring( "Starts playing the next media in playlist (if playlist is present)" ) ]
        HRESULT playNext();

    [ id(DISPID_MBBEHAVIOR_CURRENTITEM), propget, helpstring( "Returns the current media item" ) ]
        HRESULT currentItem( [out, retval] IMediaItem **ppMediaItem);
    [ id(DISPID_MBBEHAVIOR_NEXTITEM), propget, helpstring( "Returns the next media item in playlist (if any)" ) ]
        HRESULT nextItem( [out, retval] IMediaItem **ppMediaItem);
    [ id(DISPID_MBBEHAVIOR_PLAYLISTINFO), propget, helpstring( "Returns the playlist info (if any playlist)" ) ]
        HRESULT playlistInfo( [out, retval] IPlaylistInfo **ppPlaylistInfo);

    [ id(DISPID_MBBEHAVIOR_HASNEXTITEM), propget, helpstring( "Returns whether playlist has a next item." ) ]
        HRESULT hasNextItem( [out, retval] VARIANT_BOOL *pfhasNext );
    [ id(DISPID_MBBEHAVIOR_PLAYSTATE), propget, helpstring( "Returns the play state of the player" ) ]
        HRESULT playState( [out, retval] mbPlayState *pps );
    [ id(DISPID_MBBEHAVIOR_OPENSTATE), propget, helpstring( "Returns the open state of the player" ) ]
        HRESULT openState( [out, retval] mbOpenState *pos );
    [ id(DISPID_MBBEHAVIOR_ENABLED), propget, helpstring("Returns a boolen value specifying whether or not the control is enabled")]
        HRESULT enabled([out, retval] VARIANT_BOOL *pbEnabled);
    [ id(DISPID_MBBEHAVIOR_ENABLED), propput, helpstring("Sets a boolean value specifying whether or not the control is enabled")]
        HRESULT enabled([in] VARIANT_BOOL bEnable);
    [ id(DISPID_MBBEHAVIOR_DISABLEDUI), propget, helpstring("Returns a boolen value specifying whether or not the mediabar UI is disabled")]
        HRESULT disabledUI([out, retval] VARIANT_BOOL *pbDisabled);
    [ id(DISPID_MBBEHAVIOR_DISABLEDUI), propput, helpstring("Sets a boolean value specifying whether or not the mediabar UI is disabled")]
        HRESULT disabledUI([in] VARIANT_BOOL bDisable);
};

[
	uuid(BB24BBE1-1EEC-422b-A397-EDBC31FB3A56),
	helpstring("IMediaItem Interface"),
    dual,
	pointer_default(unique)
]
interface IMediaItem : IDispatch
{
    [ id(DISPID_MBMEDIAITEM_SOURCEURL), propget, helpstring( "Returns the media URL" ) ]
        HRESULT sourceURL( [out, retval] BSTR *pbstrSourceURL );
    [ id(DISPID_MBMEDIAITEM_NAME), propget, helpstring( "Returns the name of the media" ) ]
        HRESULT name( [out, retval] BSTR *pbstrName);
    [ id(DISPID_MBMEDIAITEM_DURATION), propget, helpstring( "Returns duration of current media" ) ]
        HRESULT duration( [out, retval] double * pDuration );
    [ id(DISPID_MBMEDIAITEM_ATTRIBUTECOUNT), propget, helpstring( "Returns the count of the attributes associated with this media" ) ]
        HRESULT attributeCount( [out, retval] long *plCount );
    [ id(DISPID_MBMEDIAITEM_GETATTRIBUTENAME), helpstring( "Returns the name of the attribute whose index has been specified" ) ]
        HRESULT getAttributeName( [in] long lIndex, [out, retval] BSTR *pbstrItemName );
    [ id(DISPID_MBMEDIAITEM_GETITEMINFO), helpstring( "Returns the value of specified attribute for this media" ) ]
        HRESULT getItemInfo( [in] BSTR bstrItemName, [out, retval] BSTR *pbstrVal );
};

[
	uuid(BB24BBE2-1EEC-422b-A397-EDBC31FB3A56),
	helpstring("IPlaylistInfo Interface"),
    dual,
	pointer_default(unique)
]
interface IPlaylistInfo : IDispatch
{
    [ id(DISPID_MBPLAYLISTINFO_NAME), propget, helpstring( "Returns the name of the playlist" ) ]
        HRESULT name( [out, retval] BSTR *pbstrName);
    [ id(DISPID_MBPLAYLISTINFO_ATTRIBUTECOUNT), propget, helpstring( "Returns the count of the attributes associated with this playlist" ) ]
        HRESULT attributeCount( [out, retval] long *plCount );
    [ id(DISPID_MBPLAYLISTINFO_GETATTRIBUTENAME), helpstring( "Returns the name of the attribute whose index has been specified" ) ]
        HRESULT getAttributeName( [in] long lIndex, [out, retval] BSTR *pbstrItemName );
    [ id(DISPID_MBPLAYLISTINFO_GETITEMINFO), helpstring( "Returns the value of specified attribute for this media" ) ]
        HRESULT getItemInfo( [in] BSTR bstrItemName, [out, retval] BSTR *pbstrVal );
};


// interfaces used to communicate between proxies (custom player in mstime and/or mediabar behavior) and mediabar
enum contentProxyEvent {
    OnOpenStateChange,
    OnPlayStateChange,
    OnShow,
    OnHide,
};

[
	uuid(EF508010-C806-4356-8492-D15E616F6F37),
	helpstring("IMediaHost"),
	pointer_default(unique)
]
interface IMediaHost : IUnknown
{
    HRESULT getMediaPlayer(IUnknown **ppPlayer);
    HRESULT playURL(BSTR bstrURL, BSTR bstrMIME);
    HRESULT addProxy(IUnknown *pProxy);
    HRESULT removeProxy(IUnknown *pProxy);
};


[
	uuid(EF508011-C806-4356-8492-D15E616F6F37),
	helpstring("IContentProxy"),
	pointer_default(unique)
]
interface IContentProxy : IUnknown
{
    HRESULT OnCreatedPlayer();
    HRESULT fireEvent(enum contentProxyEvent event);
    HRESULT detachPlayer();
};





///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//
//
//      T Y P E L I B R A R Y
//
//
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////


[
    uuid(B025F75A-CD86-4D11-A0C8-D7644FDBFB5A),
    version(1.0),
    lcid(0x0000),
    helpstring("Microsoft Browser Helpers")
]
library BrowseUI
{
    importlib("stdole32.tlb");
    importlib("stdole2.tlb");


    // interface only documents the custom events the media bar behavior will fire
    [
        uuid(BB24BBEF-1EEC-422b-A397-EDBC31FB3A56),
        helpstring("Event interface for MediaBar behavior"),
        hidden
    ]
    dispinterface _mbEvents
    {
        properties:
        methods:

        //////////////////////////////////////////////////////////////////////
        //      Events
        //////////////////////////////////////////////////////////////////////

        [ id(DISPID_MBBEHAVIOREVENT_ONOPENSTATECHANGE), helpstring( "Sent when the mediabar player changes OpenState" ) ]
            void OnOpenStateChange();
        [ id(DISPID_MBBEHAVIOREVENT_ONPLAYSTATECHANGE), helpstring( "Sent when the mediabar player changes PlayState" ) ]
            void OnPlayStateChange();
        [ id(DISPID_MBBEHAVIOREVENT_ONSHOW), helpstring( "Sent when the mediabar player becomes visible" ) ]
            void OnShow();
        [ id(DISPID_MBBEHAVIOREVENT_ONHIDE), helpstring( "Sent when the mediabar player is hidden" ) ]
            void OnHide();
    };

    //----------------------------------------------------------------------
    //+++++     MediaBar binary Behavior objects:
    //----------------------------------------------------------------------
	[
		uuid(BB24BBFF-1EEC-422b-A397-EDBC31FB3A56),
		helpstring("Media Behavior Class")
	]
	coclass MediaBehavior
	{
		[default] interface IMediaBehavior;
        [default, source] dispinterface _mbEvents;

        // communication to and from proxy in content pane to media player
        [source] interface IMediaHost;
        interface IContentProxy;
	};

	[
		uuid(BB24BBFE-1EEC-422b-A397-EDBC31FB3A56),
		helpstring("Media Item Class")
	]
	coclass MediaItem
	{
		[default] interface IMediaItem;
	};

	[
		uuid(BB24BBFD-1EEC-422b-A397-EDBC31FB3A56),
		helpstring("Playlist Info Class")
	]
	coclass PlaylistInfo
	{
		[default] interface IPlaylistInfo;
	};

};