-
January 19th, 2011, 11:18 AM
#1
CListCrtl playing MP3s
Hi there!
For my grade 12 summative project, I decided that I wanted to make an mp3/wma player. At the moment, I have the basics(play, stop with a browse function).
I would like to list all of my mp3s and wmas from a fixed folder in the list control, and by clicking a song and then play, would play the song selected.
I tried to use insert item:
Code:
m_Songs.InsertItem(0,"H:\\My Documents\\Music\\*.mp3");
but it just inserted a string. I have only had minimal class time using MFC functions and codes, but I would really like to be able to do this.
Also, is there any way to reposition this:
Code:
m_Timer = NULL;
if(m_Timer == NULL)
{
m_Timer = MCIWndCreate(this->GetSafeHwnd(),
AfxGetInstanceHandle(),
WS_CHILD | WS_BORDER|WS_VISIBLE|MCIWNDF_NOMENU|MCIWNDF_SHOWNAME,m_Path);
}
else
{
MCIWndHome(m_Timer);
}
MCIWndPlay(m_Timer);
m_Play.EnableWindow(FALSE);
I want to make it near the bottom of the screen, but it always shows up at the top.
I dont neccicarily need code written, but if someone can explain to me what I would need to do or even functions to try, that would be wonderful.
-
January 19th, 2011, 11:40 AM
#2
Re: CListCrtl playing MP3s
Originally Posted by TarnishedHearts
Hi there!
For my grade 12 summative project, I decided that I wanted to make an mp3/wma player. At the moment, I have the basics(play, stop with a browse function).
I would like to list all of my mp3s and wmas from a fixed folder in the list control, and by clicking a song and then play, would play the song selected.
I tried to use insert item:
Code:
m_Songs.InsertItem(0,"H:\\My Documents\\Music\\*.mp3");
but it just inserted a string. I have only had minimal class time using MFC functions and codes, but I would really like to be able to do this.
Have a look at CListCtrl::SetItemText
Originally Posted by TarnishedHearts
Also, is there any way to reposition this:
Code:
m_Timer = NULL;
if(m_Timer == NULL)
{
m_Timer = MCIWndCreate(this->GetSafeHwnd(),
AfxGetInstanceHandle(),
WS_CHILD | WS_BORDER|WS_VISIBLE|MCIWNDF_NOMENU|MCIWNDF_SHOWNAME,m_Path);
}
...
I want to make it near the bottom of the screen, but it always shows up at the top.
The return value of MCIWndCreate is HWND (window handle)
You can use ::MoveWindow or ::SetWondowPos APIs to change this player window position: just pass the returned handle (m_Timer) as window handle and other necessary parameters (see MSDN for details).
Victor Nijegorodov
-
January 19th, 2011, 12:01 PM
#3
Re: CListCrtl playing MP3s
but it just inserted a string.
Because that is what you asked it to do . You can use the CFileFind class to find files from a pattern (*.mp3 for example). After that you can insert the found files one by one in the listcontrol.
-
January 21st, 2011, 11:24 AM
#4
Re: CListCrtl playing MP3s
Okay, Ive been trying to use ::MoveWindow and ::SetWindowPos, but nothing seems to work. Maybe I'm doing something wrong, but m_Timer doesn't react to pointers, ::'s or .'s.
So then I tried this:
Code:
m_Timer = NULL;
if(m_Timer == NULL)
{
m_Timer = MCIWndCreate(this->MoveWindow(225,325,100,50,TRUE),
AfxGetInstanceHandle(),
WS_CHILD|WS_BORDER|WS_VISIBLE|MCIWNDF_NOMENU|MCIWNDF_SHOWNAME,m_Path);
}
else
{
MCIWndHome(m_Timer);
}
MCIWndPlay(m_Timer);
m_Play.EnableWindow(false);
but I get an error:
Code:
H:\ICS4U\Summative\Mp3 Magic\Mp3 MagicDlg.cpp(222) : error C2664: 'MCIWndCreateA' : cannot convert parameter 1 from 'void' to 'struct HWND__ *'
Here is most of my code at the moment:
Code:
void CMp3MagicDlg::OnPlay()
{
// This causes the timer/slider to appear and begin to play the selected file
m_Timer = NULL;
if(m_Timer == NULL)
{
m_Timer = MCIWndCreate(this->MoveWindow(225,325,100,50,TRUE),
AfxGetInstanceHandle(),
WS_CHILD|WS_BORDER|WS_VISIBLE|MCIWNDF_NOMENU|MCIWNDF_SHOWNAME,m_Path);
}
else
{
MCIWndHome(m_Timer);
}
MCIWndPlay(m_Timer);
m_Play.EnableWindow(false);
}
void CMp3MagicDlg::OnBrowse()
{
//Here I am going to direct the user
m_Timer = NULL;
if(m_Timer == NULL)
{
CFileDialog mp3(TRUE,NULL,NULL,OFN_HIDEREADONLY,"MP3 Files (*.mp3)|*.mp3|(*.WMA)|*wma|");
if(mp3.DoModal() == IDOK)
{
m_Path = mp3.GetPathName();
UpdateData(FALSE);
}
}
}
void CMp3MagicDlg::OnStop()
{
// TODO: Add your control notification handler code here
MCIWndStop(m_Timer);
if(m_Timer !=NULL)
{
MCIWndDestroy(m_Timer);
}
m_Play.EnableWindow(TRUE);
}
I've even gone through MSDN, but I can't figure out whats going wrong.
Am I missing something? Or is there another way I can go about moving the player?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|