#pragma once

#include "kpi_player.h"
#include "kpi_impl.h"
#include <dmusicc.h>
#include "dmusici.h"
#include <vector>
#include <string>
///////////////////////////////////////////////////////////////////////////////
class KbDMusicPlayer: public KbKpiUnknownImpl<IKpiPlayer>
{
private:
    KPI_MEDIAINFO             m_MediaInfo;
    IKpiFile                 *m_pFile;
    IDirectMusicLoader8      *m_pDML;
    IDirectMusicPerformance8 *m_pDMP;
    IDirectMusicSegment8     *m_pSeg;
    IDirectMusicCollection   *m_pCollection;
    IKpiConfig *m_pConfig;
    wchar_t m_szFileName[MAX_PATH];
    HANDLE  m_hEvent;
    BOOL    m_bRepeat;
    DWORD   m_dwStatus;
    REFERENCE_TIME m_rtStartTime;
    DWORD   m_dwPausedPos;
    std::vector<IKpiFile*> m_DlsFiles;
public:
    DWORD __fastcall Open(IKpiFile *pFile, IKpiFolder *pFolder);
    DWORD WINAPI Select(DWORD dwNumber,
                        const KPI_MEDIAINFO **ppInfo,
                        IKpiTagInfo *pTagInfo,
                        DWORD dwTagGetFlags);
    BOOL  WINAPI Play(DWORD dwStartpos, BOOL bVisible);
    BOOL  WINAPI Pause(void);
    BOOL  WINAPI Restart(void);
    void  WINAPI Stop(void);
    DWORD WINAPI GetPosition(void);
    DWORD WINAPI GetStatus(void);
    void  WINAPI SetTempo(int Tempo){};
    void  WINAPI SetVolume(int Volume){};
    void  WINAPI SetVisible(BOOL bVisible){};
    void  WINAPI GetWindowPosition(int *pLeft,  int *pTop,
                                   int *pVideoWidth, int *pVideoHeight){
        *pLeft = *pTop = *pVideoWidth = *pVideoHeight = 0;
    };
    void  WINAPI SetWindowPosition(int nLeft, int nTop,
        int nVideoWidth, int nVideoHeight){};
    void  WINAPI SetTopMost(BOOL bTopMost){};
    void  WINAPI SetRepeat(BOOL bRepeat);
    DWORD WINAPI UpdateConfig(void *pvReserved){return 0;}//設定が変更されたら呼ばれる

    static void __fastcall GetRefferenceFiles(IKpiFile *pFile,
                                              std::vector<std::wstring> *pFiles);
    KbDMusicPlayer(IKpiConfig *pConfig);
    virtual ~KbDMusicPlayer(void);
};
///////////////////////////////////////////////////////////////////////////////
