playlist.cpp

来自「在WCE4.2下面用EVC开发的一个带图型界面的音乐播放器,带音乐播放的一般功能」· C++ 代码 · 共 91 行

CPP
91
字号
// Playlist.cpp: implementation of the CPlaylist class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "musicplayer.h"

#include "Playlist.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CPlaylist::CPlaylist()
{
	m_CurrentFile = 0;
	m_TotalFiles = 0;
	m_FileList.RemoveAll();
	m_FilePath = L"";
}

CPlaylist::~CPlaylist()
{

}

CString CPlaylist::GetNextWorkFileName(bool bForword, bool bRandom)
{
	
	if (bForword)			// 前一个文件pre
	{
		if (--m_CurrentFile < 0)
		{
			m_CurrentFile = m_TotalFiles - 1;
		}
	} 
	else			// 后一个文件next
	{
		if (++m_CurrentFile >= m_TotalFiles )
		{
			m_CurrentFile = 0;
		}
	}

	if (bRandom)		// 随机获取
	{	int  m = MakeRandom(m_CurrentFile);
		return m_FilePath + m_FileList.GetAt(m);
	}
	else		//顺序播放
	{	return m_FilePath + m_FileList.GetAt(m_CurrentFile);
	}
}



unsigned int CPlaylist::MakeRandom(int MaxNumber)
{
	return m_Seed[MaxNumber];
}



void CPlaylist::InitSeed()
{
	int NUM=m_TotalFiles;
	int k=0;
	int j=0;
	
	srand(Random());
	for (k=0;k<NUM;k++)
	{
		m_Seed[k]=rand()%NUM;
		for (j=0;j<k;j++) 
		{	
			if (m_Seed[j]==m_Seed[k]) 
			{	k--;						//重新取
				break;
			}
		}
	}
}



⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?