summary refs log tree commit diff stats
path: root/plugins/wmpa/wmpplayer4.h
blob: 687d9361498c6f21fc2bfbbd3d8d20c706729d23 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#if !defined(AFX_WMPPLAYER4_H__A318AE12_803B_4EED_B586_1395637CDD35__INCLUDED_)
#define AFX_WMPPLAYER4_H__A318AE12_803B_4EED_B586_1395637CDD35__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// Machine generated IDispatch wrapper class(es) created by Microsoft Visual C++

// NOTE: Do not modify the contents of this file.  If this class is regenerated by
//  Microsoft Visual C++, your modifications will be overwritten.


// Dispatch interfaces referenced by this interface
class CWMPControls;
class CWMPSettings;
class CWMPMedia;
class CWMPMediaCollection;
class CWMPPlaylistCollection;
class CWMPNetwork;
class CWMPPlaylist;
class CWMPCdromCollection;
class CWMPClosedCaption;
class CWMPError;
class CWMPDVD;
class CWMPPlayerApplication;

/////////////////////////////////////////////////////////////////////////////
// CWMPPlayer4 wrapper class

class CWMPPlayer4 : public CWnd
{
protected:
	DECLARE_DYNCREATE(CWMPPlayer4)
public:
	CLSID const& GetClsid()
	{
		static CLSID const clsid
			= { 0x6bf52a52, 0x394a, 0x11d3, { 0xb1, 0x53, 0x0, 0xc0, 0x4f, 0x79, 0xfa, 0xa6 } };
		return clsid;
	}
	/*virtual BOOL Create(LPCTSTR lpszClassName,
		LPCTSTR lpszWindowName, DWORD dwStyle,
		const RECT& rect,
		CWnd* pParentWnd, UINT nID,
		CCreateContext* pContext = NULL)
	{ return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID); }*/

    BOOL Create(LPCTSTR lpszWindowName, DWORD dwStyle,
		const RECT& rect, CWnd* pParentWnd, UINT nID,
		CFile* pPersist = NULL, BOOL bStorage = FALSE,
		BSTR bstrLicKey = NULL)
	{ return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID,
		pPersist, bStorage, bstrLicKey); }

// Attributes
public:

// Operations
public:
	void close();
	CString GetUrl();
	void SetUrl(LPCTSTR lpszNewValue);
	long GetOpenState();
	long GetPlayState();
	CWMPControls GetControls();
	CWMPSettings GetSettings();
	CWMPMedia GetCurrentMedia();
	void SetCurrentMedia(LPDISPATCH newValue);
	CWMPMediaCollection GetMediaCollection();
	CWMPPlaylistCollection GetPlaylistCollection();
	CString GetVersionInfo();
	void launchURL(LPCTSTR bstrURL);
	CWMPNetwork GetNetwork();
	CWMPPlaylist GetCurrentPlaylist();
	void SetCurrentPlaylist(LPDISPATCH newValue);
	CWMPCdromCollection GetCdromCollection();
	CWMPClosedCaption GetClosedCaption();
	BOOL GetIsOnline();
	CWMPError GetError();
	CString GetStatus();
	CWMPDVD GetDvd();
	CWMPPlaylist newPlaylist(LPCTSTR bstrName, LPCTSTR bstrURL);
	CWMPMedia newMedia(LPCTSTR bstrURL);
	BOOL GetEnabled();
	void SetEnabled(BOOL bNewValue);
	BOOL GetFullScreen();
	void SetFullScreen(BOOL bNewValue);
	BOOL GetEnableContextMenu();
	void SetEnableContextMenu(BOOL bNewValue);
	void SetUiMode(LPCTSTR lpszNewValue);
	CString GetUiMode();
	BOOL GetStretchToFit();
	void SetStretchToFit(BOOL bNewValue);
	BOOL GetWindowlessVideo();
	void SetWindowlessVideo(BOOL bNewValue);
	BOOL GetIsRemote();
	CWMPPlayerApplication GetPlayerApplication();
	void openPlayer(LPCTSTR bstrURL);
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_WMPPLAYER4_H__A318AE12_803B_4EED_B586_1395637CDD35__INCLUDED_)
GIN_DISPATCH_MAP(CWMPADialog, CDialog) //{{AFX_DISPATCH_MAP(CWMPADialog) // NOTE - the ClassWizard will add and remove mapping macros here. //}}AFX_DISPATCH_MAP END_DISPATCH_MAP() // Note: we add support for IID_IWMPADialog to support typesafe binding // from VBA. This IID must match the GUID that is attached to the // dispinterface in the .ODL file. // {01C1B3AA-C7FC-4023-89A5-C814E1B62B9B} static const IID IID_IWMPADialog = { 0x1c1b3aa, 0xc7fc, 0x4023, { 0x89, 0xa5, 0xc8, 0x14, 0xe1, 0xb6, 0x2b, 0x9b } }; BEGIN_INTERFACE_MAP(CWMPADialog, CDialog) INTERFACE_PART(CWMPADialog, IID_IWMPADialog, Dispatch) END_INTERFACE_MAP() ///////////////////////////////////////////////////////////////////////////// // CWMPADialog message handlers void CWMPADialog::OnDblclkPlaylist() { // TODO: Add your control notification handler code here long index; // Get the playlist name index = m_PlaylistBox.GetCurSel(); CString playlistName; m_PlaylistBox.GetText(index, playlistName); // Get the playlist CWMPPlaylistCollection pc = m_WMP.GetPlaylistCollection(); CWMPPlaylistArray pa = pc.getByName((LPCTSTR) playlistName); CWMPPlaylist playlist = pa.Item(0); m_WMP.SetCurrentPlaylist(playlist); // Set the song list UpdateSongList(); m_WMP.GetControls().play(); if (autoAnnounce) { hexchat_commandf(ph, "me is playing %s", (LPCTSTR) wmpaGetSongTitle()); } else { hexchat_printf(ph, "WMPA: Playing %s", (LPCTSTR) wmpaGetSongTitle()); } } void CWMPADialog::OnShowWindow(BOOL bShow, UINT nStatus) { CDialog::OnShowWindow(bShow, nStatus); // TODO: Add your message handler code here if (bShow) { if (!trayInit) { ZeroMemory(&nid, sizeof(nid)); nid.cbSize = sizeof(nid); nid.hWnd = m_hWnd; nid.uID = ID_TRAY_ICON; nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; nid.uCallbackMessage = WM_TRAY_ICON; nid.hIcon = m_hIcon; strcpy(nid.szTip, "WMPA"); strcat(nid.szTip, VER_STRING); strcat(nid.szTip, "\nWindows Media\nPlayer Announcer"); nid.dwState = 0; nid.dwStateMask = 0; strcpy(nid.szInfo, "WMPA "); strcat(nid.szInfo, VER_STRING); nid.uTimeout = 10000; // 10 second time out strcat(nid.szInfoTitle, "WMPA"); nid.dwInfoFlags = 0; trayInit = TRUE; } } } void CWMPADialog::PostNcDestroy() { // TODO: Add your specialized code here and/or call the base class delete this; CDialog::PostNcDestroy(); } BOOL CWMPADialog::OnInitDialog() { CDialog::OnInitDialog(); CString title = "WMPA"; title += " "; title += VER_STRING; SetWindowText((LPCTSTR) title); UpdatePlayLists(); autoAnnounce = FALSE; trayInit = FALSE; trayClicked = FALSE; return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CWMPADialog::OnClose() { // TODO: Add your message handler code here and/or call default Shell_NotifyIcon(NIM_ADD, &nid); ShowWindow(SW_HIDE); // Don't let the user close the dialog // CDialog::OnClose(); } void CWMPADialog::OnCancel() { // this->DestroyWindow(); } void CWMPADialog::OnDblclkSonglist() { // TODO: Add your control notification handler code here int index = m_SongListBox.GetCurSel(); m_WMP.GetControls().playItem(m_WMP.GetCurrentPlaylist().GetItem(index)); if (autoAnnounce) { hexchat_commandf(ph, "me is playing %s", (LPCTSTR) wmpaGetSongTitle()); } else { hexchat_printf(ph, "WMPA: Playing %s", (LPCTSTR) wmpaGetSongTitle()); } } BEGIN_EVENTSINK_MAP(CWMPADialog, CDialog) //{{AFX_EVENTSINK_MAP(CWMPADialog) ON_EVENT(CWMPADialog, IDC_WMP, 5806 /* CurrentItemChange */, OnCurrentItemChangeWmp, VTS_DISPATCH) ON_EVENT(CWMPADialog, IDC_WMP, 5101 /* PlayStateChange */, OnPlayStateChangeWmp, VTS_I4) //}}AFX_EVENTSINK_MAP END_EVENTSINK_MAP() void CWMPADialog::OnCurrentItemChangeWmp(LPDISPATCH pdispMedia) { // TODO: Add your control notification handler code here int state = m_WMP.GetPlayState(); if (state == 3) { // Playing if (autoAnnounce) { hexchat_commandf(ph, "me is playing %s", (LPCTSTR) wmpaGetSongTitle()); } else { hexchat_printf(ph, "WMPA: Playing %s", (LPCTSTR) wmpaGetSongTitle()); } } SelectCurrentSong(); } void CWMPADialog::OnDestroy() { CDialog::OnDestroy(); // TODO: Add your message handler code here } void CWMPADialog::UpdateSongList() { char buffer[32]; CString name; CString artist; CString title; CString album; CString bitrate; CString duration; CString song; long index; long count; m_SongListBox.ResetContent(); CWMPPlaylist playlist = m_WMP.GetCurrentPlaylist(); count = playlist.GetCount(); m_SongListBox.ResetContent(); for (index = 0; index < count; index++) { name = playlist.GetItem(index).GetName(); artist = playlist.GetItem(index).getItemInfo("Artist"); title = playlist.GetItem(index).getItemInfo("Title"); album = playlist.GetItem(index).getItemInfo("Album"); bitrate = playlist.GetItem(index).getItemInfo("Bitrate"); duration = playlist.GetItem(index).GetDurationString(); long krate = strtoul((LPCTSTR) bitrate, NULL, 10) / 1000; _ultoa(krate, buffer, 10); bitrate = CString(buffer); if (album.IsEmpty()) { playlist.removeItem(playlist.GetItem(index)); count = playlist.GetCount(); } else { song = ""; song += artist; if (song.IsEmpty()) song = "Various"; song += " - "; song += title; song += " ("; song += album; song += ") ["; song += duration; song += "/"; song += bitrate; song += "Kbps]"; m_SongListBox.AddString((LPCTSTR) song); } } m_SongListBox.SetCurSel(0); } void CWMPADialog::SelectCurrentSong() { CWMPMedia media; long index; long count; count = m_WMP.GetCurrentPlaylist().GetCount(); for (index = 0; index < count; index++) { media = m_WMP.GetCurrentPlaylist().GetItem(index); if (m_WMP.GetCurrentMedia().GetIsIdentical(media)) { m_SongListBox.SetCurSel(index); } } } void CWMPADialog::UpdatePlayLists() { // TODO: Add extra initialization here CWMPPlaylistCollection pc = m_WMP.GetPlaylistCollection(); CWMPPlaylistArray pa = pc.getAll(); CWMPPlaylist playlist; int index; int count = pa.GetCount(); m_PlaylistBox.ResetContent(); for (index = 0; index < count; index++) { playlist = pa.Item(index); m_PlaylistBox.AddString((LPCTSTR) playlist.GetName()); } } void CWMPADialog::OnPlayStateChangeWmp(long NewState) { // TODO: Add your control notification handler code here } void CWMPADialog::OnSize(UINT nType, int cx, int cy) { CDialog::OnSize(nType, cx, cy); // TODO: Add your message handler code here switch (nType) { case SIZE_MINIMIZED: break; case SIZE_RESTORED: Shell_NotifyIcon(NIM_DELETE, &nid); break; default: break; } } LRESULT CWMPADialog::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { // TODO: Add your specialized code here and/or call the base class switch (message) { case WM_TRAY_ICON: switch (lParam) { case WM_LBUTTONDBLCLK: trayClicked = TRUE; break; case WM_LBUTTONUP: if (trayClicked == TRUE) { ShowWindow(SW_RESTORE); } break; default: trayClicked = FALSE; break; } return(TRUE); break; default: return CDialog::WindowProc(message, wParam, lParam); break; } } void CWMPADialog::DeleteTrayIcon() { Shell_NotifyIcon(NIM_DELETE, &nid); }