当前位置: 首页>>代码示例>>C++>>正文


C++ Playlist::readPlaylist方法代码示例

本文整理汇总了C++中Playlist::readPlaylist方法的典型用法代码示例。如果您正苦于以下问题:C++ Playlist::readPlaylist方法的具体用法?C++ Playlist::readPlaylist怎么用?C++ Playlist::readPlaylist使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Playlist的用法示例。


在下文中一共展示了Playlist::readPlaylist方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

void main(void)
{
	Playlist playlistObj;
	vector <string> musicVector;
	unsigned char key;
	bool exitProgram = false;
	string fileName;
	string musicPath;
	unsigned musicCounter = 0;
	
	musicVector.push_back("sample_song");

	while (exitProgram == false)
	{
		cout << "Welcome to the Simple Audio Player" << endl;
		cout << "Experimental Version 1.0" << endl << endl;

		//will play sounds store on the vector
		wstring song = wstring(musicVector.at(musicCounter).begin(), musicVector.at(musicCounter).end());
		
		cout << "Now Playing: " << musicVector.at(musicCounter).c_str() << endl;
		
		PlaySound( song.c_str()  , NULL, SND_ASYNC | SND_LOOP);

		//Receives user input for next action
		cin >> key;

		switch (key)
		{
		case 'q':
		case 'Q': //exits program
			exitProgram = true;
			break;
		
		case 'r':
		case 'R': //reads playlist file

			cout << "Enter playlist file name" << endl;
			cin >> fileName;
			musicVector =   playlistObj.readPlaylist(fileName);
			musicCounter = 0; //resets to the start of the playlist
			break;

		case 'n': //next on playlist
		case 'N':
			if ((musicCounter + 1) >= musicVector.size() )
				musicCounter = 0;
			else
				musicCounter++;
			break;

		case 'b': //next on playlist
		case 'B':
			if ((musicCounter - 1) <= 0 )
				musicCounter = musicVector.size() - 1;
			else
				musicCounter--;
			break;
		
		default:
			cout << "Please enter a valid option" << endl;
			break;

		}
		system("CLS");
	}

}
开发者ID:rafbel,项目名称:theSimpleAudioPlayer,代码行数:68,代码来源:theSimpleAudioPlayer.cpp


注:本文中的Playlist::readPlaylist方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。