资源简介
实现了播放器的绝大多数功能,例如:添加歌曲,保存列表,删除歌曲,删除重复,歌曲根据不同的关键字排序,播放模式的选择,调节音量,进度,显示歌曲进度时间和剩余时间,保存上次播放配置...。
代码片段和文件信息
// MusicList.cpp : implementation file
//
#include “stdafx.h“
#include “MusicPalyer.h“
#include “MusicList.h“
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMusicList
CMusicList::CMusicList()
{
}
CMusicList::~CMusicList()
{
//m_StringArray.RemoveAll();
m_vecArray.clear();
}
BEGIN_MESSAGE_MAP(CMusicList CListBox)
//{{AFX_MSG_MAP(CMusicList)
ON_WM_RBUTTONDOWN()
//}}AFX_MSG_MAP
ON_COMMAND(IDM_OpenCurrentPath OnMenuOpenCurrentPath)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMusicList message handlers
//将歌曲添加到列表
void CMusicList::AddToList(CString strFilePath int nTimes std::string time = “ “)
{
MusicInfo mTmp(strFilePath nTimes time);
m_vecArray.push_back(mTmp);
CString strFileName = GetName(strFilePath);
AddString(Formattitle(strFileName));
}
//得到歌曲名
CString CMusicList::GetName(CString strFilePath)
{
CString str;
int nPos=-1;
int nOldPos=-1;
while((nPos=strFilePath.Find(“\\“nPos+1))>0)
nOldPos=nPos;
str=strFilePath.Right(strFilePath.GetLength()-nOldPos-1);
strFilePath=str.Left(str.GetLength()-4);
return strFilePath;
}
//格式化歌曲名
CString CMusicList::Formattitle(CString strFileName)
{
CString strTmp;
int size = m_vecArray.size();
if (size >= 1 && size <= 9)
strTmp.Format(“0%d “ size);
else if (size >= 10 && size <= 99)
strTmp.Format(“%d “ size);
else
strTmp.Format(“%d “ size);
return strTmp + strFileName;
}
//要播放的路径
CString CMusicList::GetMusicName(int iIndex)
{
if (iIndex < 0)
iIndex = 0;
return m_vecArray.at(iIndex).strMusic;
}
//获得歌曲数量
int CMusicList::GetCount()
{
return m_vecArray.size();
}
//上一曲、下一曲是否能用(多余了)
BOOL CMusicList::IsEnable()
{
return m_vecArray.size() > 1 ? TRUE :FALSE;
}
//初始化歌曲列表
void CMusicList::InitFile()
{
m_strExePath = GetWorkPath();
CString m_strLstPath;
m_strLstPath = m_strExePath + “\\000.lst“;
std::ifstream ifile(m_strLstPath);
if (!ifile)
return ;
std::string strTmp;
CString strTmpFilePath;
int nTimes;
std::string time;
int select = 0;
while (std::getline(ifile strTmp))
{
switch (select)
{
case 0:
strTmpFilePath.Format(“%s“ strTmp.c_str());
select = 1;
break;
case 1:
nTimes = atoi(strTmp.c_str());
select = 2;
break;
case 2:
time = strTmp;
select = 0;
break;
}
if (select == 0)
AddToList(strTmpFilePath nTimes time);
}
ifile.close();
}
//将歌曲路径添加到文件
void CMusicList::AddToFile(CString str int nTimes = 0)
{
SYSTEMTIME st;
GetLocalTime(&st);
CString strDate strTime;
strDate.Format(“%4d-%2d-%2d“ st.wYear st.wMonth st.wDay);
strTime.Format(“ %2d-%2d-%2d“ st.wHour st.wMinute st.wSecond);
strTime = strDate + strTime;
std::string time;
time = (LPCTSTR)strTime;
m_vecAr
- 上一篇:人脸跟踪基于opencv
- 下一篇:c++ 计算m点问题
相关资源
- 基于MFC的TCP调试助手源码95706
- 基于mfc的多线程文件传输
- MFC数字钟(基于VC6.0)
- VC++MFC小游戏实例教程(实例)+MFC类库
- ChartCtrl控件库(可在VS2019中使用)
- 商品库存管理系统 C++ MFC
- mfc 调用redis
- MFC视频播放器源码(支持avi/wma/mp3等格
- mfc绘图大全(画直线、矩形、椭圆)
- MFC控件重绘
- hook,捕获所有案件,查找所有窗口,
- (学习)VS2010之MFC入门到精通教程
- MFC文档_视图_框架_模板结构体系深入
- 简单员工管理系统(适合初学MFC)
- MFC五子棋游戏
- MFC UDP编程
- MFC的异步网络通讯应用程序
- C++MFC模块讲解,黑发程序员课程整理
- 一个简单而强大的基于MFC的web server源
- 基于MFC的VC++仿QQ浏览器源码(雏形)
- MFCaccess.rar
- VC++MFC课程设计的学生成绩管理系统
- MFC 日历控件 万年历 Calendar自绘
- CrystalDiskInfo-HDD/SSD硬盘信息,SMART信息
- MFC自定义界面HUI,高效简单,含详细
- 仿射密码-Affine cipher
- c++MFC车牌自动识别定位,只能定位和
- mfc+sql 酒店客房管理系统
- 基于图割的图像分割OpenCV+MFC实现
- MFC绘制Bezier曲线B样条曲线曲线拟合
评论
共有 条评论