本文整理汇总了C++中MediaPlayer::GetPlayListItem方法的典型用法代码示例。如果您正苦于以下问题:C++ MediaPlayer::GetPlayListItem方法的具体用法?C++ MediaPlayer::GetPlayListItem怎么用?C++ MediaPlayer::GetPlayListItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MediaPlayer
的用法示例。
在下文中一共展示了MediaPlayer::GetPlayListItem方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetTitle
LPCTSTR PlayListPane::GetTitle(UINT idx)
{
PrgAPI* pAPI = PRGAPI();
switch (idx % 5)
{
case 0:
return pAPI->GetString(IDS_PLAYLIST);
break;//=== Show the default (at the end)
case 1:
{
MediaPlayer* pl = pAPI->GetMediaPlayer();
INT ACmode = 0;
MediaPlayerNextMode mpm = pl->GetNextMode(&ACmode);
if (mpm == MPNM_AutoContinue)
{
//INT mode = pAPI->GetOption(OPT_PL_AutoContinueMode);
_sntprintf(m_stringBuffer, 500, _T("%s: %s [%s]"),
pAPI->GetString(IDS_MODE),
pAPI->GetStringForPlayListMode(mpm),
pAPI->GetStringForRandomMode(RandomTrackModeEnum(ACmode)));
}
else
_sntprintf(m_stringBuffer, 500, _T("%s: %s"),
pAPI->GetString(IDS_MODE),
pAPI->GetStringForPlayListMode(MediaPlayerNextMode(mpm)));
}
break;
case 2:
{
MediaPlayer* pl = pAPI->GetMediaPlayer();
INT totalTracks = pl->GetPlayListCount();
_sntprintf(m_stringBuffer, 500, _T("%s: %d"), pAPI->GetString(IDS_TRACKS), totalTracks);
}
break;
case 3:
{
MediaPlayer* pl = pAPI->GetMediaPlayer();
INT totalTracks = pl->GetPlayListCount();
INT totalSeconds = 0;
MediaPlayListItem mpli;
BOOL bHasZeroLength = FALSE;
for (INT i = 0; i < totalTracks; i++)
{
if (pl->GetPlayListItem(mpli, i))
{
if (mpli.length == 0)
bHasZeroLength = TRUE;
totalSeconds += mpli.length;
}
}
TCHAR time[40];
if (totalSeconds >= 3600)
_sntprintf(time, 40, _T("%d:%02d:%02d"), INT (totalSeconds / 3600), INT((totalSeconds % 3600)/60), INT(totalSeconds) % 60);
else
_sntprintf(time, 40, _T("%d:%02d"), INT (totalSeconds / 60), INT(totalSeconds) % 60);
_sntprintf(m_stringBuffer, 500, _T("%s: %s%s"), pAPI->GetString(IDS_DURATION), time, bHasZeroLength ? _T(" +") : _T(""));
}
break;
case 4:
_sntprintf(m_stringBuffer, 500, _T("%s: [F4]"), pAPI->GetString(IDS_FOCUS));
break;
default:
ASSERT(0);
return NULL;
}
return m_stringBuffer;
}
示例2: Draw
void TrayToolTipDlg::Draw(CDC& dc)
{
TRACEST(_T("TrayToolTipDlg::Draw"));
CRect rcMemDC(0, 0, m_ff.GetWidth(), m_ff.GetHeight());
PrgAPI* pAPI = PRGAPI();
MediaPlayer* pMP = pAPI->GetMediaPlayer();
//FullTrackRecordSP m_rec;
MediaPlayListItem mpli;
BOOL mpliIsValid = FALSE;
INT playListPos = pMP->GetPlayListPos();
if (playListPos != -1)
mpliIsValid = pMP->GetPlayListItem(mpli, playListPos);
CRect rcCalc(rcMemDC);
dc.SetBkMode(TRANSPARENT);
dc.SelectStockObject(NULL_BRUSH);
dc.SelectStockObject(DC_PEN);
INT maxTextWidth = 0;
m_pictureWidth = 0;
INT textLine1Width = 0;
INT textLine2Width = 0;
using namespace Gdiplus;
Graphics graphics(dc.GetSafeHdc());
graphics.SetSmoothingMode(SmoothingModeAntiAlias);
graphics.SetInterpolationMode(InterpolationModeHighQualityBicubic);
COLORREF outlineColor = RGB(220,220,220);
INT r = GetRValue(m_colors[COL_TitleText]) + GetGValue(m_colors[COL_TitleText]) + GetBValue(m_colors[COL_TitleText]);
if (r > (256 * 3) / 2)
outlineColor = RGB(30,30,30);
if (mpliIsValid == FALSE)
{
Gdiplus::SolidBrush br(GdiplusUtilities::COLORREF2Color(m_colors[COL_Bk]));
graphics.FillRectangle(&br, GdiplusUtilities::RECT2GdiplusRect(rcMemDC));
//rcMemDC.bottom = GetTotalHeight();
//CFont* pOldFont = dc.SelectObject(&m_font[FNT_Title]);
//dc.SetTextColor(m_colors[COL_TitleText]);
//rcMemDC.right = m_minWidth;
//dc.DrawText(CTeenSpiritApp::sAppTitle, -1, &rcMemDC, DT_SINGLELINE | DT_END_ELLIPSIS | DT_VCENTER | DT_NOPREFIX | DT_CENTER);
//dc.SelectObject(pOldFont);
//maxTextWidth = rcCalc.Width();
CRect rcItem = rcMemDC;
rcItem.bottom = GetTotalHeight() - 30;
rcItem.right = m_minWidth;
LOGFONT lf;
m_font[FNT_Title].GetLogFont(&lf);
GdiplusUtilities::DrawTextOutline(graphics, CTeenSpiritApp::sAppTitle, _tcslen(CTeenSpiritApp::sAppTitle), &rcItem,
DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_CENTER,
lf, m_colors[COL_TitleText], outlineColor, 2);
}
else
{
SQLManager* pSM = pAPI->GetSQLManager();
FullTrackRecordSP rec;
BOOL bRecIsValid = pSM->GetFullTrackRecordByLocation(rec, mpli.url);
if (bRecIsValid)
{
mpli.artist = rec->artist.name.c_str();
mpli.title = rec->track.name.c_str();
mpli.rating = rec->track.rating;
if (mpli.length == 0)
mpli.length = rec->track.duration;
}
//=== Picture
if (bRecIsValid)
{
LocalPictureManager* pLPM = pAPI->GetLocalPictureManager();
SQLManager* pSM = pAPI->GetSQLManager();
LPCTSTR imgPath = NULL;
FullAlbumRecordSP albumRec;
if (pSM->GetFullAlbumRecordByID(albumRec, rec->album.ID))
{
imgPath = pLPM->GetMainAlbumPicture(albumRec->artist.name.c_str(), albumRec->album.name.c_str(), TRUE);
if (imgPath == NULL)
imgPath = pLPM->GetMainArtistPicture(albumRec->artist.name.c_str(), TRUE);
}
if (imgPath != NULL)
{
//.........这里部分代码省略.........
示例3: WindowProc
LRESULT CTeenSpiritDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
if (message == WM_GETTEXT && wParam > GTB_First && wParam < GTB_Last && lParam != 0)//External commands interface
{
INT ret = 0;
LPCTSTR str = NULL;
LPTSTR externalBuffer = (LPTSTR) lParam;
externalBuffer[0] = 0;
MediaPlayer* pPlayer = PRGAPI()->GetMediaPlayer();
INT curTrack = pPlayer->GetPlayListPos();
if (curTrack >= 0)
{
MediaPlayListItem mpli;
if (pPlayer->GetPlayListItem(mpli, curTrack))
{
switch (wParam)
{
case GTB_Artist:
str = mpli.artist;
break;
case GTB_Title:
str = mpli.title;
break;
default:
ASSERT(0);
break;
}
}
}
if (str == NULL)
return 0;
_tcsncpy(externalBuffer, str, wParam);
return _tcslen(str);
}
else if (message == WM_COMMAND)//External commands interface
{
MediaPlayer* pPlayer = PRGAPI()->GetMediaPlayer();
if (pPlayer != NULL)
{
BOOL bHandled = TRUE;
switch (wParam)
{
case EXTERNALCOMMAND_Play: //Returns 0 on success
pPlayer->Start();
break;
case EXTERNALCOMMAND_Pause: //Returns 0 on success
pPlayer->Pause();
break;
case EXTERNALCOMMAND_Stop: //Returns 0 on success
pPlayer->Stop();
break;
case EXTERNALCOMMAND_Next: //Returns 0 on success
pPlayer->Next();
break;
case GTB_Artist:
case EXTERNALCOMMAND_Previous: //Returns 0 on success
pPlayer->Previous();
break;
case EXTERNALCOMMAND_ShowHidePlayer: //lparam=1 to show. 0 to hide. Returns 0 on success
if (IsWindowVisible() && lParam == 0)
PostMessage(WM_SYSCOMMAND, SC_MINIMIZE);
else if (!IsWindowVisible() && lParam == 1)
PostMessage(WM_SYSCOMMAND, SC_RESTORE);
break;
case EXTERNALCOMMAND_GetVolume: //Return vol 0-100. Returns 0-100 on success
return pPlayer->GetVolume();
case EXTERNALCOMMAND_SetVolume: //lParam is the new value(0-100) retunrns 0 on success
pPlayer->SetVolume(lParam);
PRGAPI()->GetStateManager()->SendMessage(SM_PlayerVolumeChanged);
break;
case EXTERNALCOMMAND_GetMute: //Returns 1 on mute ON. 0 on Mute off
return pPlayer->GetMute();
case EXTERNALCOMMAND_SetMute: //lparam=1 for mute ON. 0 Returns 0 on success
pPlayer->SetMute(lParam != 0);
PRGAPI()->GetStateManager()->PostMessage(SM_PlayerSettingsChanged);
break;
case EXTERNALCOMMAND_GetMediaLength: //returns the number of seconds
return INT(pPlayer->GetMediaLength());
case EXTERNALCOMMAND_GetMediaPos: //returns the number of seconds
return INT(pPlayer->GetMediaPos());
case EXTERNALCOMMAND_SetMediaPos: //lparam=1 for mute ON. 0 Returns 0 on success
pPlayer->SetMediaPos(lParam);
break;
default:
bHandled = FALSE;
}
if (bHandled)
return 0;
}
}
else if (message == WM_KEYDOWN || message == WM_SYSKEYDOWN)
{
TRACE(_T("CTeenSpiritDlg::WindowProc. KeyDown: %d-%d\r\n"), wParam, lParam);
}
return CDialog::WindowProc(message, wParam, lParam);
}
示例4: OnStateChanged
BOOL CTeenSpiritDlg::OnStateChanged(UINT stateMessage)
{
if (stateMessage == SM_MediaChanged)
{
MediaPlayListItem mpli;
PrgAPI* pAPI = PRGAPI();
MediaPlayer* pMP = pAPI->GetMediaPlayer();
INT nPos = pMP->GetPlayListPos();
if (nPos != -1 && pMP->GetPlayListItem(mpli, nPos))
{
if (mpli.artist == NULL) mpli.artist = _T("");
if (mpli.title == NULL) mpli.title = mpli.url;
//=== Show Tray ToolTip
//pAPI->GetTrayToolTipDlg()->OnMediaChanged(pAPI->GetOption(OPT_GEN_ShowToolTipOnMediaChanged));
//==== NOTIFIERS
TrackerTrack track;
track.artist = mpli.artist;
track.title = mpli.title;
track.rating = mpli.rating;
track.length = (UINT)pMP->GetMediaLength();
pAPI->GetTracker()->SubmitTrack(ITracker::ACT_Started, track, GetCurrentUnixTimeStamp());
}
return TRUE;
}
// case SM_MediaChanged:
// {
// MediaPlayer* pPlayer = pAPI->GetMediaPlayer();
// INT curMediaIdx = pPlayer->GetPlayListPos();
// if (curMediaIdx >= 0)
// {
// MediaPlayListItem mpli;
// if (pPlayer->GetPlayListItem(mpli, curMediaIdx))
// {
// //==== NOTIFIERS
// if (mpli.artist == NULL) mpli.artist = _T("");
// if (mpli.title == NULL) mpli.title = mpli.url;
// TrackerTrack track;
// track.artist = mpli.artist;
// track.title = mpli.title;
// track.rating = mpli.rating;
// track.length = (UINT)pPlayer->GetMediaLength();
// pAPI->GetTracker()->SubmitTrack(ITracker::ACT_Started, track, GetCurrentUnixTimeStamp());
// //==== Info Control
// if (pAPI->GetOption(OPT_VIEWER_Auto))// m_ViewerPane.GetAutoViewerMode())
// {
// TrackTypesEnum tt = GetTrackType(mpli.url);
// if (tt < TTYPE_FIRSTVIDEO)
// {
// m_ViewerPane.SetMode(CViewerPane::MOD_NormalInfo);
// }
// else if (tt < TTYPE_FIRSTVIRTUAL)
// {
// m_ViewerPane.SetMode(CViewerPane::MOD_Visualizations);
// }
// else
// {
// m_ViewerPane.SetMode(CViewerPane::MOD_Browser);
// }
// }
// if (m_ViewerPane.GetMode() == CViewerPane::MOD_NormalInfo && pAPI->GetOption(OPT_VIEWER_SyncWithPlayer))
// {
// MediaPlayListItem mpli;
// if (pPlayer->GetPlayListItem(mpli, curMediaIdx))
// {
// FullTrackRecordSP rec;
// if (pAPI->GetSQLManager()->GetFullTrackRecordByLocation(rec, mpli.url))
// {
// CInfoCtrl* pIC = m_ViewerPane.GetInfoControl();
// if (pIC != NULL)
// {
// pIC->SetActiveItem(rec);
// pIC->SetStyle(IT_Track);
// pIC->Refresh(100);
// }
// }
// }
// }
// }
//
// }
//
// }
//
// break;
return FALSE;
}
示例5: HandlePlayerCommands
BOOL MenuManager::HandlePlayerCommands(MediaPlayer& player, MenuCommandsEnum cmd, INT playlistPos)
{
TRACEST(_T("MenuManager::HandlePlayerCommands"));
PrgAPI* pAPI = PRGAPI();
ActionManager* pAM = pAPI->GetActionManager();
switch (cmd)
{
//=== Play Control =========================================
case MENU_PlayControl:
player.Start();
break;
case MENU_PauseControl:
if (player.GetPlayState() == PS_Paused)
player.Start();
else
player.Pause();
break;
case MENU_StopControl:
player.Stop();
break;
case MENU_NextControl:
player.Next();
break;
case MENU_PrevControl:
player.Previous();
break;
//=== Playlist Serialization =========================================
case MENU_LoadList:
pAM->InsertPlayList(&player, -1);
break;
case MENU_SaveList:
pAM->SavePlayList(&player);
break;
case MENU_InsertList:
pAM->InsertPlayList(&player, playlistPos);
break;
default:
//=== PlayModes =========================================
if (cmd>= MENU_PlayModesHolder && cmd < MENU_PlayModesHolder + MPNM_Last)
player.SetNextMode(MediaPlayerNextMode(cmd - MENU_PlayModesHolder), -1);
else if (cmd >= MENU_AutoContinueModeHolder && cmd < MENU_AutoContinueModeHolder + RTM_Last)
{
player.SetNextMode(player.GetNextMode(NULL), cmd - MENU_AutoContinueModeHolder);
}
//=== Rating =========================================
else if (cmd>= MENU_RatingHolder && cmd <= MENU_RatingHolder + 5)
{
int idx = playlistPos;
if (idx >= 0)
{
SQLManager* pSM = PRGAPI()->GetSQLManager();
MediaPlayListItem mpli;
if (player.GetPlayListItem(mpli, idx))
{
FullTrackRecordSP rec;
if (pSM->GetFullTrackRecordByLocation(rec, mpli.url))
{
FullTrackRecordCollection col;
col.push_back(rec);
ActionManager* pAM = PRGAPI()->GetActionManager();
pAM->SetTrackRating(col, Stars2Rating((FLOAT)(cmd - MENU_RatingHolder)));
}
}
}
}
else
return FALSE;
}
return TRUE;
}